Skip to content

Commit 4e6fa82

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 90d30cb + f119ff0 commit 4e6fa82

File tree

16 files changed

+710
-45
lines changed

16 files changed

+710
-45
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2572,6 +2572,7 @@ GIT-BUILD-OPTIONS: FORCE
25722572
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
25732573
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
25742574
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
2575+
@echo X=\'$(X)\' >>$@+
25752576
ifdef TEST_OUTPUT_DIRECTORY
25762577
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
25772578
endif
@@ -2606,6 +2607,9 @@ ifdef GIT_INTEROP_MAKE_OPTS
26062607
endif
26072608
ifdef TEST_GIT_INDEX_VERSION
26082609
@echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@+
2610+
endif
2611+
ifdef MSVC_DEPS
2612+
@echo MSVC_DEPS=\''$(subst ','\'',$(subst ','\'',$(MSVC_DEPS)))'\' >>$@+
26092613
endif
26102614
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
26112615

@@ -2630,7 +2634,7 @@ bin-wrappers/%: wrap-for-bin.sh
26302634
@mkdir -p bin-wrappers
26312635
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
26322636
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2633-
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \
2637+
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \
26342638
chmod +x $@
26352639

26362640
# 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: 87 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')
@@ -361,6 +365,7 @@ ifeq ($(uname_S),Windows)
361365
NEEDS_LIBICONV = YesPlease
362366
NO_STRTOUMAX = YesPlease
363367
NO_MKDTEMP = YesPlease
368+
NO_INTTYPES_H = YesPlease
364369
# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
365370
# so we don't need this.
366371
#
@@ -396,6 +401,9 @@ ifeq ($(uname_S),Windows)
396401
compat/win32/dirent.o compat/win32/fscache.o
397402
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
398403
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
404+
# invalidcontinue.obj allows Git's source code to close the same file
405+
# handle twice, or to access the osfhandle of an already-closed stdout
406+
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
399407
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
400408
PTHREAD_LIBS =
401409
lib =
@@ -428,6 +436,11 @@ ifeq ($(uname_S),Windows)
428436
# release mode) to force a PDB to be generated (like RelWithDebInfo).
429437
BASIC_CFLAGS += -Zi
430438
BASIC_LDFLAGS += -debug
439+
440+
ifdef NO_SAFESEH
441+
LDFLAGS += -SAFESEH:NO
442+
endif
443+
431444
ifndef DEBUG
432445
BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
433446
BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
@@ -438,6 +451,80 @@ endif
438451
X = .exe
439452

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