Skip to content

Commit af5161d

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 594f388 + 016738e commit af5161d

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
@@ -185,6 +185,42 @@
185185
/gitweb/static/gitweb.js
186186
/gitweb/static/gitweb.min.*
187187
/command-list.h
188+
/libgit
189+
/test-chmtime
190+
/test-ctype
191+
/test-config
192+
/test-date
193+
/test-delta
194+
/test-dump-cache-tree
195+
/test-dump-split-index
196+
/test-dump-untracked-cache
197+
/test-fake-ssh
198+
/test-scrap-cache-tree
199+
/test-genrandom
200+
/test-hashmap
201+
/test-index-version
202+
/test-line-buffer
203+
/test-match-trees
204+
/test-mergesort
205+
/test-mktemp
206+
/test-parse-options
207+
/test-path-utils
208+
/test-prio-queue
209+
/test-read-cache
210+
/test-regex
211+
/test-revision-walking
212+
/test-run-command
213+
/test-sha1
214+
/test-sha1-array
215+
/test-sigchain
216+
/test-string-list
217+
/test-submodule-config
218+
/test-subprocess
219+
/test-svn-fe
220+
/test-urlmatch-normalization
221+
/test-wildmatch
222+
/vcs-svn_lib
223+
/xdiff_lib
188224
*.tar.gz
189225
*.dsc
190226
*.deb
@@ -223,6 +259,13 @@
223259
*.idb
224260
*.pdb
225261
*.ilk
262+
*.iobj
263+
*.ipdb
264+
*.dll
226265
.vs/
227-
/Debug/
228-
/Release/
266+
*.manifest
267+
Debug/
268+
Release/
269+
/UpgradeLog*.htm
270+
/git.VC.VC.opendb
271+
/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
@@ -2567,6 +2567,7 @@ GIT-BUILD-OPTIONS: FORCE
25672567
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
25682568
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
25692569
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
2570+
@echo X=\'$(X)\' >>$@+
25702571
ifdef TEST_OUTPUT_DIRECTORY
25712572
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
25722573
endif
@@ -2601,6 +2602,9 @@ ifdef GIT_INTEROP_MAKE_OPTS
26012602
endif
26022603
ifdef TEST_GIT_INDEX_VERSION
26032604
@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)))'\' >>$@+
26042608
endif
26052609
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
26062610

@@ -2625,7 +2629,7 @@ bin-wrappers/%: wrap-for-bin.sh
26252629
@mkdir -p bin-wrappers
26262630
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
26272631
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2628-
-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)))|' < $< > $@ && \
26292633
chmod +x $@
26302634

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