Skip to content

Commit e99f9eb

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 37ba527 + b41b102 commit e99f9eb

31 files changed

+745
-71
lines changed

.gitattributes

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* whitespace=!indent,trail,space
2-
*.[ch] whitespace=indent,trail,space diff=cpp
3-
*.sh whitespace=indent,trail,space
2+
*.[ch] whitespace=indent,trail,space diff=cpp eol=lf
3+
*.sh whitespace=indent,trail,space eol=lf
4+
*.{perl,pm,txt} eol=lf

.gitignore

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

20212021
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
20222022
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
@@ -2226,6 +2226,7 @@ GIT-BUILD-OPTIONS: FORCE
22262226
@echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@+
22272227
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
22282228
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
2229+
@echo X=\'$(X)\' >>$@+
22292230
ifdef TEST_OUTPUT_DIRECTORY
22302231
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
22312232
endif
@@ -2257,6 +2258,9 @@ ifdef GIT_INTEROP_MAKE_OPTS
22572258
endif
22582259
ifdef TEST_GIT_INDEX_VERSION
22592260
@echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@+
2261+
endif
2262+
ifdef MSVC_DEPS
2263+
@echo MSVC_DEPS=\''$(subst ','\'',$(subst ','\'',$(MSVC_DEPS)))'\' >>$@+
22602264
endif
22612265
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
22622266

@@ -2281,7 +2285,7 @@ bin-wrappers/%: wrap-for-bin.sh
22812285
@mkdir -p bin-wrappers
22822286
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
22832287
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2284-
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \
2288+
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \
22852289
chmod +x $@
22862290

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

builtin/rev-list.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
388388
mark_edges_uninteresting(&revs, show_edge);
389389

390390
if (bisect_list) {
391-
int reaches = reaches, all = all;
391+
FAKE_INIT(int, reaches, 0);
392+
FAKE_INIT(int, all, 0);
392393

393394
revs.commits = find_bisection(revs.commits, &reaches, &all,
394395
bisect_find_all);

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
@@ -493,7 +493,7 @@ __extension__ \
493493
( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \
494494
((((h)->temp.tempint > 0 \
495495
&& (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \
496-
? (int) ((h)->next_free = (h)->object_base \
496+
? (ptrdiff_t) ((h)->next_free = (h)->object_base \
497497
= (h)->temp.tempint + (char *) (h)->chunk) \
498498
: (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
499499

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')
@@ -346,6 +350,7 @@ ifeq ($(uname_S),Windows)
346350
NEEDS_LIBICONV = YesPlease
347351
NO_STRTOUMAX = YesPlease
348352
NO_MKDTEMP = YesPlease
353+
NO_INTTYPES_H = YesPlease
349354
# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
350355
# so we don't need this.
351356
#
@@ -379,6 +384,9 @@ ifeq ($(uname_S),Windows)
379384
compat/win32/dirent.o compat/win32/fscache.o
380385
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
381386
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
387+
# invalidcontinue.obj allows Git's source code to close the same file
388+
# handle twice, or to access the osfhandle of an already-closed stdout
389+
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
382390
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
383391
PTHREAD_LIBS =
384392
lib =
@@ -411,6 +419,11 @@ ifeq ($(uname_S),Windows)
411419
# release mode) to force a PDB to be generated (like RelWithDebInfo).
412420
BASIC_CFLAGS += -Zi
413421
BASIC_LDFLAGS += -debug
422+
423+
ifdef NO_SAFESEH
424+
LDFLAGS += -SAFESEH:NO
425+
endif
426+
414427
ifndef DEBUG
415428
BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
416429
BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
@@ -421,6 +434,65 @@ endif
421434
X = .exe
422435

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