Skip to content

Commit 379eca2

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 bee5113 + 0e06dae commit 379eca2

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
@@ -187,6 +187,42 @@
187187
/gitweb/static/gitweb.js
188188
/gitweb/static/gitweb.min.*
189189
/command-list.h
190+
/libgit
191+
/test-chmtime
192+
/test-ctype
193+
/test-config
194+
/test-date
195+
/test-delta
196+
/test-dump-cache-tree
197+
/test-dump-split-index
198+
/test-dump-untracked-cache
199+
/test-fake-ssh
200+
/test-scrap-cache-tree
201+
/test-genrandom
202+
/test-hashmap
203+
/test-index-version
204+
/test-line-buffer
205+
/test-match-trees
206+
/test-mergesort
207+
/test-mktemp
208+
/test-parse-options
209+
/test-path-utils
210+
/test-prio-queue
211+
/test-read-cache
212+
/test-regex
213+
/test-revision-walking
214+
/test-run-command
215+
/test-sha1
216+
/test-sha1-array
217+
/test-sigchain
218+
/test-string-list
219+
/test-submodule-config
220+
/test-subprocess
221+
/test-svn-fe
222+
/test-urlmatch-normalization
223+
/test-wildmatch
224+
/vcs-svn_lib
225+
/xdiff_lib
190226
*.tar.gz
191227
*.dsc
192228
*.deb
@@ -225,6 +261,13 @@
225261
*.idb
226262
*.pdb
227263
*.ilk
264+
*.iobj
265+
*.ipdb
266+
*.dll
228267
.vs/
229-
/Debug/
230-
/Release/
268+
*.manifest
269+
Debug/
270+
Release/
271+
/UpgradeLog*.htm
272+
/git.VC.VC.opendb
273+
/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
@@ -2583,6 +2583,7 @@ GIT-BUILD-OPTIONS: FORCE
25832583
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
25842584
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
25852585
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
2586+
@echo X=\'$(X)\' >>$@+
25862587
ifdef TEST_OUTPUT_DIRECTORY
25872588
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
25882589
endif
@@ -2617,6 +2618,9 @@ ifdef GIT_INTEROP_MAKE_OPTS
26172618
endif
26182619
ifdef TEST_GIT_INDEX_VERSION
26192620
@echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@+
2621+
endif
2622+
ifdef MSVC_DEPS
2623+
@echo MSVC_DEPS=\''$(subst ','\'',$(subst ','\'',$(MSVC_DEPS)))'\' >>$@+
26202624
endif
26212625
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
26222626

@@ -2641,7 +2645,7 @@ bin-wrappers/%: wrap-for-bin.sh
26412645
@mkdir -p bin-wrappers
26422646
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
26432647
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2644-
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \
2648+
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \
26452649
chmod +x $@
26462650

26472651
# 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)