Skip to content

Commit 2a8356c

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 2ddda64 + c6585c2 commit 2a8356c

16 files changed

+692
-40
lines changed

.gitignore

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,42 @@
186186
/gitweb/static/gitweb.js
187187
/gitweb/static/gitweb.min.*
188188
/command-list.h
189+
/libgit
190+
/test-chmtime
191+
/test-ctype
192+
/test-config
193+
/test-date
194+
/test-delta
195+
/test-dump-cache-tree
196+
/test-dump-split-index
197+
/test-dump-untracked-cache
198+
/test-fake-ssh
199+
/test-scrap-cache-tree
200+
/test-genrandom
201+
/test-hashmap
202+
/test-index-version
203+
/test-line-buffer
204+
/test-match-trees
205+
/test-mergesort
206+
/test-mktemp
207+
/test-parse-options
208+
/test-path-utils
209+
/test-prio-queue
210+
/test-read-cache
211+
/test-regex
212+
/test-revision-walking
213+
/test-run-command
214+
/test-sha1
215+
/test-sha1-array
216+
/test-sigchain
217+
/test-string-list
218+
/test-submodule-config
219+
/test-subprocess
220+
/test-svn-fe
221+
/test-urlmatch-normalization
222+
/test-wildmatch
223+
/vcs-svn_lib
224+
/xdiff_lib
189225
*.tar.gz
190226
*.dsc
191227
*.deb
@@ -224,6 +260,13 @@
224260
*.idb
225261
*.pdb
226262
*.ilk
263+
*.iobj
264+
*.ipdb
265+
*.dll
227266
.vs/
228-
/Debug/
229-
/Release/
267+
*.manifest
268+
Debug/
269+
Release/
270+
/UpgradeLog*.htm
271+
/git.VC.VC.opendb
272+
/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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2602,6 +2602,9 @@ ifdef GIT_INTEROP_MAKE_OPTS
26022602
endif
26032603
ifdef TEST_GIT_INDEX_VERSION
26042604
@echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@+
2605+
endif
2606+
ifdef MSVC_DEPS
2607+
@echo MSVC_DEPS=\''$(subst ','\'',$(subst ','\'',$(MSVC_DEPS)))'\' >>$@+
26052608
endif
26062609
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
26072610

@@ -2626,7 +2629,7 @@ bin-wrappers/%: wrap-for-bin.sh
26262629
@mkdir -p bin-wrappers
26272630
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
26282631
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2629-
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \
2632+
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \
26302633
chmod +x $@
26312634

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

compat/mingw.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3207,6 +3207,10 @@ static void adjust_symlink_flags(void)
32073207

32083208
#if defined(_MSC_VER)
32093209

3210+
#ifdef _DEBUG
3211+
#include <crtdbg.h>
3212+
#endif
3213+
32103214
/*
32113215
* This routine sits between wmain() and "main" in git.exe.
32123216
* We receive UNICODE (wchar_t) values for argv and env.
@@ -3231,6 +3235,10 @@ int msc_startup(int argc, wchar_t **w_argv, wchar_t **w_env)
32313235
int maxlen;
32323236
int k, exit_status;
32333237

3238+
#ifdef _DEBUG
3239+
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
3240+
#endif
3241+
32343242
#ifdef USE_MSVC_CRTDBG
32353243
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
32363244
#endif

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
@@ -492,7 +492,7 @@ __extension__ \
492492
( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \
493493
((((h)->temp.tempint > 0 \
494494
&& (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \
495-
? (int) ((h)->next_free = (h)->object_base \
495+
? (ptrdiff_t) ((h)->next_free = (h)->object_base \
496496
= (h)->temp.tempint + (char *) (h)->chunk) \
497497
: (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
498498

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')
@@ -383,6 +387,7 @@ ifeq ($(uname_S),Windows)
383387
NEEDS_LIBICONV = YesPlease
384388
NO_STRTOUMAX = YesPlease
385389
NO_MKDTEMP = YesPlease
390+
NO_INTTYPES_H = YesPlease
386391
# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
387392
# so we don't need this.
388393
#
@@ -416,6 +421,9 @@ ifeq ($(uname_S),Windows)
416421
compat/win32/dirent.o compat/win32/fscache.o
417422
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
418423
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
424+
# invalidcontinue.obj allows Git's source code to close the same file
425+
# handle twice, or to access the osfhandle of an already-closed stdout
426+
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
419427
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
420428
PTHREAD_LIBS =
421429
lib =
@@ -434,6 +442,11 @@ ifeq ($(uname_S),Windows)
434442
# release mode) to force a PDB to be generated (like RelWithDebInfo).
435443
BASIC_CFLAGS += -Zi
436444
BASIC_LDFLAGS += -debug
445+
446+
ifdef NO_SAFESEH
447+
LDFLAGS += -SAFESEH:NO
448+
endif
449+
437450
ifndef DEBUG
438451
BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
439452
BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
@@ -444,6 +457,65 @@ endif
444457
X = .exe
445458

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