Skip to content

Commit 4c0c0ec

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 56b3945 + 2589140 commit 4c0c0ec

19 files changed

+704
-54
lines changed

.gitignore

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,43 @@
179179
/gitweb/gitweb.cgi
180180
/gitweb/static/gitweb.js
181181
/gitweb/static/gitweb.min.*
182+
/libgit
183+
/test-chmtime
184+
/test-ctype
185+
/test-config
186+
/test-date
187+
/test-delta
188+
/test-dump-cache-tree
189+
/test-dump-split-index
190+
/test-dump-untracked-cache
191+
/test-fake-ssh
192+
/test-scrap-cache-tree
193+
/test-genrandom
194+
/test-hashmap
195+
/test-index-version
196+
/test-line-buffer
197+
/test-match-trees
198+
/test-mergesort
199+
/test-mktemp
200+
/test-parse-options
201+
/test-path-utils
202+
/test-prio-queue
203+
/test-read-cache
204+
/test-regex
205+
/test-revision-walking
206+
/test-run-command
207+
/test-sha1
208+
/test-sha1-array
209+
/test-sigchain
210+
/test-string-list
211+
/test-submodule-config
212+
/test-subprocess
213+
/test-svn-fe
214+
/test-urlmatch-normalization
215+
/test-wildmatch
182216
/common-cmds.h
217+
/vcs-svn_lib
218+
/xdiff_lib
183219
*.tar.gz
184220
*.dsc
185221
*.deb
@@ -217,6 +253,13 @@
217253
*.idb
218254
*.pdb
219255
*.ilk
256+
*.iobj
257+
*.ipdb
258+
*.dll
220259
.vs/
221-
/Debug/
222-
/Release/
260+
*.manifest
261+
Debug/
262+
Release/
263+
/UpgradeLog*.htm
264+
/git.VC.VC.opendb
265+
/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
@@ -2147,7 +2147,7 @@ exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
21472147
exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
21482148
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
21492149
'-DBINDIR="$(bindir_relative_SQ)"' \
2150-
'-DPREFIX="$(prefix_SQ)"'
2150+
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
21512151

21522152
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
21532153
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
@@ -2410,6 +2410,7 @@ GIT-BUILD-OPTIONS: FORCE
24102410
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
24112411
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
24122412
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
2413+
@echo X=\'$(X)\' >>$@+
24132414
ifdef TEST_OUTPUT_DIRECTORY
24142415
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
24152416
endif
@@ -2444,6 +2445,9 @@ ifdef GIT_INTEROP_MAKE_OPTS
24442445
endif
24452446
ifdef TEST_GIT_INDEX_VERSION
24462447
@echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@+
2448+
endif
2449+
ifdef MSVC_DEPS
2450+
@echo MSVC_DEPS=\''$(subst ','\'',$(subst ','\'',$(MSVC_DEPS)))'\' >>$@+
24472451
endif
24482452
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
24492453

@@ -2468,7 +2472,7 @@ bin-wrappers/%: wrap-for-bin.sh
24682472
@mkdir -p bin-wrappers
24692473
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
24702474
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2471-
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \
2475+
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \
24722476
chmod +x $@
24732477

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

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')
@@ -353,6 +357,7 @@ ifeq ($(uname_S),Windows)
353357
NEEDS_LIBICONV = YesPlease
354358
NO_STRTOUMAX = YesPlease
355359
NO_MKDTEMP = YesPlease
360+
NO_INTTYPES_H = YesPlease
356361
# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
357362
# so we don't need this.
358363
#
@@ -387,6 +392,9 @@ ifeq ($(uname_S),Windows)
387392
compat/win32/dirent.o compat/win32/fscache.o
388393
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
389394
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
395+
# invalidcontinue.obj allows Git's source code to close the same file
396+
# handle twice, or to access the osfhandle of an already-closed stdout
397+
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
390398
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
391399
PTHREAD_LIBS =
392400
lib =
@@ -419,6 +427,11 @@ ifeq ($(uname_S),Windows)
419427
# release mode) to force a PDB to be generated (like RelWithDebInfo).
420428
BASIC_CFLAGS += -Zi
421429
BASIC_LDFLAGS += -debug
430+
431+
ifdef NO_SAFESEH
432+
LDFLAGS += -SAFESEH:NO
433+
endif
434+
422435
ifndef DEBUG
423436
BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
424437
BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
@@ -429,6 +442,65 @@ endif
429442
X = .exe
430443

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