Skip to content

Commit

Permalink
Merge branch 'visual-studio'
Browse files Browse the repository at this point in the history
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 <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Nov 30, 2016
2 parents 6ce069a + 38c56e3 commit 056b413
Show file tree
Hide file tree
Showing 33 changed files with 748 additions and 73 deletions.
5 changes: 3 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* whitespace=!indent,trail,space
*.[ch] whitespace=indent,trail,space diff=cpp
*.sh whitespace=indent,trail,space
*.[ch] whitespace=indent,trail,space diff=cpp eol=lf
*.sh whitespace=indent,trail,space eol=lf
*.{perl,pm,txt} eol=lf
47 changes: 45 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,43 @@
/gitweb/gitweb.cgi
/gitweb/static/gitweb.js
/gitweb/static/gitweb.min.*
/libgit
/test-chmtime
/test-ctype
/test-config
/test-date
/test-delta
/test-dump-cache-tree
/test-dump-split-index
/test-dump-untracked-cache
/test-fake-ssh
/test-scrap-cache-tree
/test-genrandom
/test-hashmap
/test-index-version
/test-line-buffer
/test-match-trees
/test-mergesort
/test-mktemp
/test-parse-options
/test-path-utils
/test-prio-queue
/test-read-cache
/test-regex
/test-revision-walking
/test-run-command
/test-sha1
/test-sha1-array
/test-sigchain
/test-string-list
/test-submodule-config
/test-subprocess
/test-svn-fe
/test-urlmatch-normalization
/test-wildmatch
/common-cmds.h
/vcs-svn_lib
/xdiff_lib
*.tar.gz
*.dsc
*.deb
Expand Down Expand Up @@ -220,9 +256,16 @@
*.idb
*.pdb
*.ilk
*.iobj
*.ipdb
*.dll
.vs/
/Debug/
/Release/
*.manifest
Debug/
Release/
/UpgradeLog*.htm
/git.VC.VC.opendb
/git.VC.db
/.vagrant/
/vagrant2[0-9][0-9][0-9]*-*-*
/d2[0-9][0-9][0-9]*-*-*
6 changes: 6 additions & 0 deletions .nuget/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="..\compat\vcbuild\GEN.PKGS" />
</config>
</configuration>
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,7 @@ exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
'-DBINDIR="$(bindir_relative_SQ)"' \
'-DPREFIX="$(prefix_SQ)"'
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'

builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
Expand Down Expand Up @@ -2217,6 +2217,7 @@ GIT-BUILD-OPTIONS: FORCE
@echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@+
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
@echo X=\'$(X)\' >>$@+
ifdef TEST_OUTPUT_DIRECTORY
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
endif
Expand Down Expand Up @@ -2245,6 +2246,9 @@ ifdef GIT_PERF_MAKE_OPTS
endif
ifdef TEST_GIT_INDEX_VERSION
@echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@+
endif
ifdef MSVC_DEPS
@echo MSVC_DEPS=\''$(subst ','\'',$(subst ','\'',$(MSVC_DEPS)))'\' >>$@+
endif
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi

Expand All @@ -2269,7 +2273,7 @@ bin-wrappers/%: wrap-for-bin.sh
@mkdir -p bin-wrappers
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \
chmod +x $@

# GNU make supports exporting all variables by "export" without parameters.
Expand Down
3 changes: 2 additions & 1 deletion builtin/rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
mark_edges_uninteresting(&revs, show_edge);

if (bisect_list) {
int reaches = reaches, all = all;
FAKE_INIT(int, reaches, 0);
FAKE_INIT(int, all, 0);

revs.commits = find_bisection(revs.commits, &reaches, &all,
bisect_find_all);
Expand Down
4 changes: 4 additions & 0 deletions compat/msvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <malloc.h>
#include <io.h>

#pragma warning(disable: 4018) /* signed/unsigned comparison */
#pragma warning(disable: 4244) /* type conversion, possible loss of data */
#pragma warning(disable: 4090) /* 'function' : different 'const' qualifiers (ALLOC_GROW etc.)*/

/* porting function */
#define inline __inline
#define __inline__ __inline
Expand Down
2 changes: 1 addition & 1 deletion compat/obstack.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ __extension__ \
( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \
((((h)->temp.tempint > 0 \
&& (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \
? (int) ((h)->next_free = (h)->object_base \
? (ptrdiff_t) ((h)->next_free = (h)->object_base \
= (h)->temp.tempint + (char *) (h)->chunk) \
: (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))

Expand Down
2 changes: 2 additions & 0 deletions compat/terminal.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifndef NO_INTTYPES_H
#include <inttypes.h>
#endif
#include "git-compat-util.h"
#include "run-command.h"
#include "compat/terminal.h"
Expand Down
2 changes: 1 addition & 1 deletion compat/vcbuild/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<package id="openssl" version="1.0.2.1" />
<package id="openssl.v120.windesktop.msvcstl.dyn.rt-dyn" version="1.0.2.1" />
<package id="openssl.v120.windesktop.msvcstl.dyn.rt-dyn.x64" version="1.0.2" />
<package id="openssl.v120.windesktop.msvcstl.dyn.rt-dyn.x64" version="1.0.2.0" />
<package id="openssl.v120.windesktop.msvcstl.dyn.rt-dyn.x86" version="1.0.2.1" />
<package id="openssl.v140.windesktop.msvcstl.dyn.rt-dyn" version="1.0.2.1" />
<package id="openssl.v140.windesktop.msvcstl.dyn.rt-dyn.x64" version="1.0.2.1" />
Expand Down
72 changes: 72 additions & 0 deletions config.mak.uname
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Platform specific Makefile tweaks based on uname detection

# Define NO_SAFESEH if you need MSVC/Visual Studio to ignore the lack of
# Microsoft's Safe Exception Handling in libraries (such as zlib).
# Typically required for VS2013+/32-bit compilation on Vista+ versions.

uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
Expand Down Expand Up @@ -362,6 +366,7 @@ ifeq ($(uname_S),Windows)
NO_STRTOUMAX = YesPlease
NO_MKDTEMP = YesPlease
NO_MKSTEMPS = YesPlease
NO_INTTYPES_H = YesPlease
# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
# so we don't need this.
#
Expand Down Expand Up @@ -395,6 +400,9 @@ ifeq ($(uname_S),Windows)
compat/win32/dirent.o compat/win32/fscache.o
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
# invalidcontinue.obj allows Git's source code to close the same file
# handle twice, or to access the osfhandle of an already-closed stdout
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
PTHREAD_LIBS =
lib =
Expand Down Expand Up @@ -427,6 +435,11 @@ ifeq ($(uname_S),Windows)
# release mode) to force a PDB to be generated (like RelWithDebInfo).
BASIC_CFLAGS += -Zi
BASIC_LDFLAGS += -debug

ifdef NO_SAFESEH
LDFLAGS += -SAFESEH:NO
endif

ifndef DEBUG
BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
Expand All @@ -437,6 +450,65 @@ endif
X = .exe

compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS

vcxproj:
# Require clean work tree
git update-index -q --refresh && \
git diff-files --quiet && \
git diff-index --cached --quiet HEAD --

# Make .vcxproj files and add them
unset QUIET_GEN QUIET_BUILT_IN; \
perl contrib/buildsystems/generate -g Vcxproj
git add -f git.sln {*,*/lib,t/helper/*}/{packages.config,*.vcxproj}

# Add common-cmds.h
$(MAKE) MSVC=1 prefix=/mingw64 common-cmds.h
git add -f common-cmds.h

# Add scripts
rm -f perl/perl.mak
$(MAKE) MSVC=1 prefix=/mingw64 \
$(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
# Strip out the sane tool path, needed only for building
sed -i '/^git_broken_path_fix ".*/d' git-sh-setup
git add -f $(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)

# Add Perl module
$(MAKE) -C perl
git add -f perl/blib/lib

# Add bin-wrappers, for testing
rm -rf bin-wrappers/
$(MAKE) MSVC=1 prefix=/mingw64 $(test_bindir_programs)
# Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute
# path of the repository is not hard-coded (GIT_EXEC_PATH will be set
# by test-lib.sh according to the current setup)
sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\
\1="$$(cygpath -u "$$\1")"/' \
-e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/*
# Ensure that test-* helpers find the .dll files copied to top-level
sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-*
# We do not want to force hard-linking builtins
sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \
bin-wrappers/git-{receive-pack,upload-archive}
git add -f $(test_bindir_programs)
# remote-ext is a builtin, but invoked as if it were external
sed 's|receive-pack|remote-ext|g' \
<bin-wrappers/git-receive-pack >bin-wrappers/git-remote-ext
git add -f bin-wrappers/git-remote-ext

# Add templates
$(MAKE) -C templates
git add -f templates/boilerplates.made templates/blt/

# Add build options
$(MAKE) MSVC=1 prefix=/mingw64 GIT-BUILD-OPTIONS
git add -f GIT-BUILD-OPTIONS

# Commit the whole shebang
git commit -m "Generate Visual Studio solution" \
-m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`"
endif
ifeq ($(uname_S),Interix)
NO_INITGROUPS = YesPlease
Expand Down
2 changes: 1 addition & 1 deletion contrib/buildsystems/Generators.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BEGIN {
$me = dirname($me);
if (opendir(D,"$me/Generators")) {
foreach my $gen (readdir(D)) {
next if ($gen =~ /^\.\.?$/);
next unless ($gen =~ /\.pm$/);
require "${me}/Generators/$gen";
$gen =~ s,\.pm,,;
push(@AVAILABLE, $gen);
Expand Down
Loading

0 comments on commit 056b413

Please sign in to comment.