Skip to content

Commit 59752e7

Browse files
committed
Merge branch 'visual-studio'
This topic branch teaches the project generator to generate a Visual Studio solution, ready to be opened in Visual Studio 2010 or later. The idea, of course, is to let some automatic build job generate and commit the project files with make MSVC=1 vcxproj and then (force-)push to a special-purpose branch. The major part of this branch thicket concerns itself not only with generating the Visual Studio project files, but making sure that the user can then run the test suite from a regular Git Bash (i.e. *not* requiring a Git for Windows SDK), e.g. by running cd t prove --timer --jobs 15 ./t[0-9]*.sh Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 2497df0 + bfbc4f3 commit 59752e7

32 files changed

+747
-72
lines changed

.gitattributes

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* whitespace=!indent,trail,space
2-
*.[ch] whitespace=indent,trail,space diff=cpp
3-
*.sh whitespace=indent,trail,space
2+
*.[ch] whitespace=indent,trail,space diff=cpp eol=lf
3+
*.sh whitespace=indent,trail,space eol=lf
4+
*.{perl,pm,txt} eol=lf

.gitignore

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,43 @@
181181
/gitweb/gitweb.cgi
182182
/gitweb/static/gitweb.js
183183
/gitweb/static/gitweb.min.*
184+
/libgit
185+
/test-chmtime
186+
/test-ctype
187+
/test-config
188+
/test-date
189+
/test-delta
190+
/test-dump-cache-tree
191+
/test-dump-split-index
192+
/test-dump-untracked-cache
193+
/test-fake-ssh
194+
/test-scrap-cache-tree
195+
/test-genrandom
196+
/test-hashmap
197+
/test-index-version
198+
/test-line-buffer
199+
/test-match-trees
200+
/test-mergesort
201+
/test-mktemp
202+
/test-parse-options
203+
/test-path-utils
204+
/test-prio-queue
205+
/test-read-cache
206+
/test-regex
207+
/test-revision-walking
208+
/test-run-command
209+
/test-sha1
210+
/test-sha1-array
211+
/test-sigchain
212+
/test-string-list
213+
/test-submodule-config
214+
/test-subprocess
215+
/test-svn-fe
216+
/test-urlmatch-normalization
217+
/test-wildmatch
184218
/common-cmds.h
219+
/vcs-svn_lib
220+
/xdiff_lib
185221
*.tar.gz
186222
*.dsc
187223
*.deb
@@ -220,6 +256,13 @@
220256
*.idb
221257
*.pdb
222258
*.ilk
259+
*.iobj
260+
*.ipdb
261+
*.dll
223262
.vs/
224-
/Debug/
225-
/Release/
263+
*.manifest
264+
Debug/
265+
Release/
266+
/UpgradeLog*.htm
267+
/git.VC.VC.opendb
268+
/git.VC.db

.nuget/NuGet.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<config>
4+
<add key="repositoryPath" value="..\compat\vcbuild\GEN.PKGS" />
5+
</config>
6+
</configuration>

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
20232023
exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
20242024
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
20252025
'-DBINDIR="$(bindir_relative_SQ)"' \
2026-
'-DPREFIX="$(prefix_SQ)"'
2026+
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
20272027

20282028
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
20292029
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
@@ -2219,6 +2219,7 @@ GIT-BUILD-OPTIONS: FORCE
22192219
@echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@+
22202220
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
22212221
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
2222+
@echo X=\'$(X)\' >>$@+
22222223
ifdef TEST_OUTPUT_DIRECTORY
22232224
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
22242225
endif
@@ -2247,6 +2248,9 @@ ifdef GIT_PERF_MAKE_OPTS
22472248
endif
22482249
ifdef TEST_GIT_INDEX_VERSION
22492250
@echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@+
2251+
endif
2252+
ifdef MSVC_DEPS
2253+
@echo MSVC_DEPS=\''$(subst ','\'',$(subst ','\'',$(MSVC_DEPS)))'\' >>$@+
22502254
endif
22512255
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
22522256

@@ -2271,7 +2275,7 @@ bin-wrappers/%: wrap-for-bin.sh
22712275
@mkdir -p bin-wrappers
22722276
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
22732277
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2274-
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \
2278+
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \
22752279
chmod +x $@
22762280

22772281
# GNU make supports exporting all variables by "export" without parameters.

builtin/rev-list.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
388388
mark_edges_uninteresting(&revs, show_edge);
389389

390390
if (bisect_list) {
391-
int reaches = reaches, all = all;
391+
FAKE_INIT(int, reaches, 0);
392+
FAKE_INIT(int, all, 0);
392393

393394
revs.commits = find_bisection(revs.commits, &reaches, &all,
394395
bisect_find_all);

compat/msvc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include <malloc.h>
77
#include <io.h>
88

9+
#pragma warning(disable: 4018) /* signed/unsigned comparison */
10+
#pragma warning(disable: 4244) /* type conversion, possible loss of data */
11+
#pragma warning(disable: 4090) /* 'function' : different 'const' qualifiers (ALLOC_GROW etc.)*/
12+
913
/* porting function */
1014
#define inline __inline
1115
#define __inline__ __inline

compat/obstack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ __extension__ \
493493
( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \
494494
((((h)->temp.tempint > 0 \
495495
&& (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \
496-
? (int) ((h)->next_free = (h)->object_base \
496+
? (ptrdiff_t) ((h)->next_free = (h)->object_base \
497497
= (h)->temp.tempint + (char *) (h)->chunk) \
498498
: (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
499499

compat/terminal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#ifndef NO_INTTYPES_H
12
#include <inttypes.h>
3+
#endif
24
#include "git-compat-util.h"
35
#include "run-command.h"
46
#include "compat/terminal.h"

config.mak.uname

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Platform specific Makefile tweaks based on uname detection
22

3+
# Define NO_SAFESEH if you need MSVC/Visual Studio to ignore the lack of
4+
# Microsoft's Safe Exception Handling in libraries (such as zlib).
5+
# Typically required for VS2013+/32-bit compilation on Vista+ versions.
6+
37
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
48
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
59
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
@@ -362,6 +366,7 @@ ifeq ($(uname_S),Windows)
362366
NO_STRTOUMAX = YesPlease
363367
NO_MKDTEMP = YesPlease
364368
NO_MKSTEMPS = YesPlease
369+
NO_INTTYPES_H = YesPlease
365370
# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
366371
# so we don't need this.
367372
#
@@ -395,6 +400,9 @@ ifeq ($(uname_S),Windows)
395400
compat/win32/dirent.o compat/win32/fscache.o
396401
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
397402
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
403+
# invalidcontinue.obj allows Git's source code to close the same file
404+
# handle twice, or to access the osfhandle of an already-closed stdout
405+
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
398406
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
399407
PTHREAD_LIBS =
400408
lib =
@@ -427,6 +435,11 @@ ifeq ($(uname_S),Windows)
427435
# release mode) to force a PDB to be generated (like RelWithDebInfo).
428436
BASIC_CFLAGS += -Zi
429437
BASIC_LDFLAGS += -debug
438+
439+
ifdef NO_SAFESEH
440+
LDFLAGS += -SAFESEH:NO
441+
endif
442+
430443
ifndef DEBUG
431444
BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
432445
BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
@@ -437,6 +450,65 @@ endif
437450
X = .exe
438451

439452
compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS
453+
454+
vcxproj:
455+
# Require clean work tree
456+
git update-index -q --refresh && \
457+
git diff-files --quiet && \
458+
git diff-index --cached --quiet HEAD --
459+
460+
# Make .vcxproj files and add them
461+
unset QUIET_GEN QUIET_BUILT_IN; \
462+
perl contrib/buildsystems/generate -g Vcxproj
463+
git add -f git.sln {*,*/lib,t/helper/*}/{packages.config,*.vcxproj}
464+
465+
# Add common-cmds.h
466+
$(MAKE) MSVC=1 prefix=/mingw64 common-cmds.h
467+
git add -f common-cmds.h
468+
469+
# Add scripts
470+
rm -f perl/perl.mak
471+
$(MAKE) MSVC=1 prefix=/mingw64 \
472+
$(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
473+
# Strip out the sane tool path, needed only for building
474+
sed -i '/^git_broken_path_fix ".*/d' git-sh-setup
475+
git add -f $(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
476+
477+
# Add Perl module
478+
$(MAKE) -C perl
479+
git add -f perl/blib/lib
480+
481+
# Add bin-wrappers, for testing
482+
rm -rf bin-wrappers/
483+
$(MAKE) MSVC=1 prefix=/mingw64 $(test_bindir_programs)
484+
# Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute
485+
# path of the repository is not hard-coded (GIT_EXEC_PATH will be set
486+
# by test-lib.sh according to the current setup)
487+
sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\
488+
\1="$$(cygpath -u "$$\1")"/' \
489+
-e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/*
490+
# Ensure that test-* helpers find the .dll files copied to top-level
491+
sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-*
492+
# We do not want to force hard-linking builtins
493+
sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \
494+
bin-wrappers/git-{receive-pack,upload-archive}
495+
git add -f $(test_bindir_programs)
496+
# remote-ext is a builtin, but invoked as if it were external
497+
sed 's|receive-pack|remote-ext|g' \
498+
<bin-wrappers/git-receive-pack >bin-wrappers/git-remote-ext
499+
git add -f bin-wrappers/git-remote-ext
500+
501+
# Add templates
502+
$(MAKE) -C templates
503+
git add -f templates/boilerplates.made templates/blt/
504+
505+
# Add build options
506+
$(MAKE) MSVC=1 prefix=/mingw64 GIT-BUILD-OPTIONS
507+
git add -f GIT-BUILD-OPTIONS
508+
509+
# Commit the whole shebang
510+
git commit -m "Generate Visual Studio solution" \
511+
-m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`"
440512
endif
441513
ifeq ($(uname_S),Interix)
442514
NO_INITGROUPS = YesPlease

contrib/buildsystems/Generators.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BEGIN {
1717
$me = dirname($me);
1818
if (opendir(D,"$me/Generators")) {
1919
foreach my $gen (readdir(D)) {
20-
next if ($gen =~ /^\.\.?$/);
20+
next unless ($gen =~ /\.pm$/);
2121
require "${me}/Generators/$gen";
2222
$gen =~ s,\.pm,,;
2323
push(@AVAILABLE, $gen);

0 commit comments

Comments
 (0)