Skip to content

Commit 7b5aa43

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 68ba28b + 473c319 commit 7b5aa43

File tree

16 files changed

+695
-45
lines changed

16 files changed

+695
-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: 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')
@@ -371,6 +375,7 @@ ifeq ($(uname_S),Windows)
371375
NEEDS_LIBICONV = YesPlease
372376
NO_STRTOUMAX = YesPlease
373377
NO_MKDTEMP = YesPlease
378+
NO_INTTYPES_H = YesPlease
374379
# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
375380
# so we don't need this.
376381
#
@@ -406,6 +411,9 @@ ifeq ($(uname_S),Windows)
406411
compat/win32/dirent.o compat/win32/fscache.o
407412
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
408413
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
414+
# invalidcontinue.obj allows Git's source code to close the same file
415+
# handle twice, or to access the osfhandle of an already-closed stdout
416+
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
409417
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
410418
PTHREAD_LIBS =
411419
lib =
@@ -438,6 +446,11 @@ ifeq ($(uname_S),Windows)
438446
# release mode) to force a PDB to be generated (like RelWithDebInfo).
439447
BASIC_CFLAGS += -Zi
440448
BASIC_LDFLAGS += -debug
449+
450+
ifdef NO_SAFESEH
451+
LDFLAGS += -SAFESEH:NO
452+
endif
453+
441454
ifndef DEBUG
442455
BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
443456
BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
@@ -448,6 +461,65 @@ endif
448461
X = .exe
449462

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

contrib/buildsystems/Generators/Vcproj.pm

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ my @GUIDS = (
5252
"{00785268-A9CC-4E40-AC29-BAC0019159CE}",
5353
"{4C06F56A-DCDB-46A6-B67C-02339935CF12}",
5454
"{3A62D3FD-519E-4EC9-8171-D2C1BFEA022F}",
55-
"{3A62D3FD-519E-4EC9-8171-D2C1BFEA022F}",
5655
"{9392EB58-D7BA-410B-B1F0-B2FAA6BC89A7}",
5756
"{2ACAB2D5-E0CE-4027-BCA0-D78B2D7A6C66}",
5857
"{86E216C3-43CE-481A-BCB2-BE5E62850635}",
@@ -63,7 +62,14 @@ my @GUIDS = (
6362
"{294BDC5A-F448-48B6-8110-DD0A81820F8C}",
6463
"{4B9F66E9-FAC9-47AB-B1EF-C16756FBFD06}",
6564
"{72EA49C6-2806-48BD-B81B-D4905102E19C}",
66-
"{5728EB7E-8929-486C-8CD5-3238D060E768}"
65+
"{5728EB7E-8929-486C-8CD5-3238D060E768}",
66+
"{A3E300FC-5630-4850-A470-E9F2C2EFA7E7}",
67+
"{CEA071D4-D9F3-4250-98F7-44AFDC8ACAA1}",
68+
"{3FD87BB4-2236-4A1B-ADD2-46211A302442}",
69+
"{49B03F41-5157-4079-95A7-64D728BCF74F}",
70+
"{95D5A28B-80E2-40A9-BEA3-C52B9CA488E3}",
71+
"{B85E6545-D523-4323-9F29-45389D090343}",
72+
"{06840CEF-746C-4B71-9442-C395DD6590A5}"
6773
);
6874

6975
sub generate {
@@ -106,6 +112,8 @@ sub createLibProject {
106112
my $includes= join(";", sort(map("&quot;$rel_dir\\$_&quot;", @{$$build_structure{"LIBS_${libname}_INCLUDES"}})));
107113
my $cflags = join(" ", sort(@{$$build_structure{"LIBS_${libname}_CFLAGS"}}));
108114
$cflags =~ s/\"/&quot;/g;
115+
$cflags =~ s/</&lt;/g;
116+
$cflags =~ s/>/&gt;/g;
109117

110118
my $cflags_debug = $cflags;
111119
$cflags_debug =~ s/-MT/-MTd/;
@@ -127,6 +135,8 @@ sub createLibProject {
127135

128136
$defines =~ s/-D//g;
129137
$defines =~ s/\"/\\&quot;/g;
138+
$defines =~ s/</&lt;/g;
139+
$defines =~ s/>/&gt;/g;
130140
$defines =~ s/\'//g;
131141
$includes =~ s/-I//g;
132142
mkdir "$target" || die "Could not create the directory $target for lib project!\n";
@@ -162,9 +172,6 @@ sub createLibProject {
162172
<Tool
163173
Name="VCXMLDataGeneratorTool"
164174
/>
165-
<Tool
166-
Name="VCWebServiceProxyGeneratorTool"
167-
/>
168175
<Tool
169176
Name="VCMIDLTool"
170177
/>
@@ -228,9 +235,6 @@ sub createLibProject {
228235
<Tool
229236
Name="VCXMLDataGeneratorTool"
230237
/>
231-
<Tool
232-
Name="VCWebServiceProxyGeneratorTool"
233-
/>
234238
<Tool
235239
Name="VCMIDLTool"
236240
/>
@@ -325,6 +329,8 @@ sub createAppProject {
325329
my $includes= join(";", sort(map("&quot;$rel_dir\\$_&quot;", @{$$build_structure{"APPS_${appname}_INCLUDES"}})));
326330
my $cflags = join(" ", sort(@{$$build_structure{"APPS_${appname}_CFLAGS"}}));
327331
$cflags =~ s/\"/&quot;/g;
332+
$cflags =~ s/</&lt;/g;
333+
$cflags =~ s/>/&gt;/g;
328334

329335
my $cflags_debug = $cflags;
330336
$cflags_debug =~ s/-MT/-MTd/;
@@ -351,6 +357,8 @@ sub createAppProject {
351357

352358
$defines =~ s/-D//g;
353359
$defines =~ s/\"/\\&quot;/g;
360+
$defines =~ s/</&lt;/g;
361+
$defines =~ s/>/&gt;/g;
354362
$defines =~ s/\'//g;
355363
$defines =~ s/\\\\/\\/g;
356364
$includes =~ s/-I//g;
@@ -387,9 +395,6 @@ sub createAppProject {
387395
<Tool
388396
Name="VCXMLDataGeneratorTool"
389397
/>
390-
<Tool
391-
Name="VCWebServiceProxyGeneratorTool"
392-
/>
393398
<Tool
394399
Name="VCMIDLTool"
395400
/>
@@ -458,9 +463,6 @@ sub createAppProject {
458463
<Tool
459464
Name="VCXMLDataGeneratorTool"
460465
/>
461-
<Tool
462-
Name="VCWebServiceProxyGeneratorTool"
463-
/>
464466
<Tool
465467
Name="VCMIDLTool"
466468
/>
@@ -561,20 +563,18 @@ sub createGlueProject {
561563
foreach (@apps) {
562564
$_ =~ s/\//_/g;
563565
$_ =~ s/\.exe//;
564-
push(@tmp, $_);
566+
if ($_ eq "git" ) {
567+
unshift(@tmp, $_);
568+
} else {
569+
push(@tmp, $_);
570+
}
565571
}
566572
@apps = @tmp;
567573

568574
open F, ">git.sln" || die "Could not open git.sln for writing!\n";
569575
binmode F, ":crlf";
570576
print F "$SLN_HEAD";
571-
foreach (@libs) {
572-
my $libname = $_;
573-
my $uuid = $build_structure{"LIBS_${libname}_GUID"};
574-
print F "$SLN_PRE";
575-
print F "\"${libname}\", \"${libname}\\${libname}.vcproj\", \"${uuid}\"";
576-
print F "$SLN_POST";
577-
}
577+
578578
my $uuid_libgit = $build_structure{"LIBS_libgit_GUID"};
579579
my $uuid_xdiff_lib = $build_structure{"LIBS_xdiff_lib_GUID"};
580580
foreach (@apps) {
@@ -588,6 +588,13 @@ sub createGlueProject {
588588
print F " EndProjectSection";
589589
print F "$SLN_POST";
590590
}
591+
foreach (@libs) {
592+
my $libname = $_;
593+
my $uuid = $build_structure{"LIBS_${libname}_GUID"};
594+
print F "$SLN_PRE";
595+
print F "\"${libname}\", \"${libname}\\${libname}.vcproj\", \"${uuid}\"";
596+
print F "$SLN_POST";
597+
}
591598

592599
print F << "EOM";
593600
Global
@@ -599,17 +606,17 @@ EOM
599606
print F << "EOM";
600607
GlobalSection(ProjectConfigurationPlatforms) = postSolution
601608
EOM
602-
foreach (@libs) {
603-
my $libname = $_;
604-
my $uuid = $build_structure{"LIBS_${libname}_GUID"};
609+
foreach (@apps) {
610+
my $appname = $_;
611+
my $uuid = $build_structure{"APPS_${appname}_GUID"};
605612
print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n";
606613
print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n";
607614
print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n";
608615
print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n";
609616
}
610-
foreach (@apps) {
611-
my $appname = $_;
612-
my $uuid = $build_structure{"APPS_${appname}_GUID"};
617+
foreach (@libs) {
618+
my $libname = $_;
619+
my $uuid = $build_structure{"LIBS_${libname}_GUID"};
613620
print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n";
614621
print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n";
615622
print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n";

0 commit comments

Comments
 (0)