Merge pull request #1304 from jeffhostetler/vs2017_vcpkg

VS2017 vcpkg support.
This commit is contained in:
Johannes Schindelin
2018-06-08 18:38:34 +02:00
18 changed files with 344 additions and 398 deletions

1
.gitattributes vendored
View File

@@ -5,6 +5,7 @@
*.pl eof=lf diff=perl
*.pm eol=lf diff=perl
*.py eol=lf diff=python
*.bat eol=crlf
/Documentation/git-*.txt eol=lf
/command-list.txt eol=lf
/GIT-VERSION-GEN eol=lf

1
.gitignore vendored
View File

@@ -1,7 +1,6 @@
/GIT-BUILD-OPTIONS
/GIT-CFLAGS
/GIT-LDFLAGS
/GIT-MSVC-GEN
/GIT-PREFIX
/GIT-PERL-DEFINES
/GIT-PERL-HEADER

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="..\compat\vcbuild\GEN.PKGS" />
</config>
</configuration>

View File

@@ -2602,9 +2602,6 @@ ifdef GIT_INTEROP_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
@@ -2754,8 +2751,6 @@ install: all
$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
ifdef MSVC
$(INSTALL) compat/vcbuild/GEN.DEPS/bin/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'
$(INSTALL) compat/vcbuild/GEN.DEPS/bin/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
# We DO NOT install the individual foo.o.pdb files because they
# have already been rolled up into the exe's pdb file.
# We DO NOT have pdb files for the builtin commands (like git-status.exe)
@@ -2774,6 +2769,13 @@ ifdef MSVC
$(INSTALL) git-remote-testsvn.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-sh-i18n--envsubst.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-show-index.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
ifndef DEBUG
$(INSTALL) $(vcpkg_rel_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'
$(INSTALL) $(vcpkg_rel_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
else
$(INSTALL) $(vcpkg_dbg_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'
$(INSTALL) $(vcpkg_dbg_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
endif
endif
$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
@@ -2978,9 +2980,15 @@ endif
ifdef MSVC
$(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))
$(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))
$(RM) $(patsubst %.exe,%.iobj,$(OTHER_PROGRAMS))
$(RM) $(patsubst %.exe,%.ipdb,$(OTHER_PROGRAMS))
$(RM) $(patsubst %.exe,%.pdb,$(PROGRAMS))
$(RM) $(patsubst %.exe,%.iobj,$(PROGRAMS))
$(RM) $(patsubst %.exe,%.ipdb,$(PROGRAMS))
$(RM) $(patsubst %.exe,%.pdb,$(TEST_PROGRAMS))
$(RM) GIT-MSVC-GEN
$(RM) $(patsubst %.exe,%.iobj,$(TEST_PROGRAMS))
$(RM) $(patsubst %.exe,%.ipdb,$(TEST_PROGRAMS))
$(RM) compat/vcbuild/MSVC-DEFS-GEN
endif
.PHONY: all install profile-clean cocciclean clean strip

View File

@@ -1 +1,3 @@
GEN.*
/vcpkg/
/MSVC-DEFS-GEN
/VCPKG-DEFS

View File

@@ -1,147 +0,0 @@
## Makefile to install nuget package dependencies.
##################################################################
INST=GEN.DEPS
INST_INC=$(INST)/include
INST_LIB=$(INST)/lib
INST_BIN=$(INST)/bin
PKGDIR=GEN.PKGS
NUGET ?= nuget.exe
ifneq ($(shell $(NUGET) help 2>/dev/null; echo $$?),0)
NUGET := /usr/src/build-extra/nuget/nuget.exe
endif
##################################################################
all: unpack expat libssh libssh_redist curl curl_redist openssl zlib \
libiconv libiconv_redist
unpack:
[ -d $(PKGDIR) ] || mkdir $(PKGDIR)
"$(NUGET)" restore packages.config -ConfigFile nuget.config \
-NonInteractive -OutputDirectory $(PKGDIR)
insdir:
[ -d $(INST) ] || mkdir $(INST)
[ -d $(INST_INC) ] || mkdir $(INST_INC)
[ -d $(INST_BIN) ] || mkdir $(INST_BIN)
[ -d $(INST_LIB) ] || mkdir $(INST_LIB)
##################################################################
## We place the expat headers in their own subdirectory.
## The custom is to reference <expat.h>, so compile with:
## -I$(INST_INC)/expat
EXPAT_VER=2.1.0.11
EXPAT_ROOT=$(PKGDIR)/expat.$(EXPAT_VER)/build/native
EXPAT_INC=$(EXPAT_ROOT)/include
EXPAT_LIB=$(EXPAT_ROOT)/lib/v110/x64/Release/dynamic/utf8
expat: insdir
[ -d $(INST_INC)/expat ] || mkdir $(INST_INC)/expat
cp -r $(EXPAT_INC)/* $(INST_INC)/expat/
cp -r $(EXPAT_LIB)/* $(INST_LIB)/
##################################################################
LIBICONV_VER=1.14.0.11
LIBICONV_ROOT=$(PKGDIR)/libiconv.$(LIBICONV_VER)/build/native
LIBICONV_INC=$(LIBICONV_ROOT)/include
LIBICONV_LIB=$(LIBICONV_ROOT)/lib/v110/x64/Release/dynamic/cdecl
libiconv: insdir
cp -r $(LIBICONV_INC)/* $(INST_INC)/
cp -r $(LIBICONV_LIB)/libiconv.lib $(INST_LIB)/iconv.lib
LIBICONV_REDIST_ROOT=$(PKGDIR)/libiconv.redist.$(LIBICONV_VER)/build/native
LIBICONV_REDIST_BIN=$(LIBICONV_REDIST_ROOT)/bin/v110/x64/Release/dynamic/cdecl
libiconv_redist: insdir
cp -r $(LIBICONV_REDIST_BIN)/* $(INST_BIN)/
##################################################################
LIBSSH_VER=1.4.3.3
LIBSSH_ROOT=$(PKGDIR)/libssh2.$(LIBSSH_VER)/build/native
LIBSSH_INC=$(LIBSSH_ROOT)/include
LIBSSH_LIB=$(LIBSSH_ROOT)/lib/v110/x64/Release/dynamic/cdecl
libssh: insdir
[ -d $(INST_INC)/libssh2 ] || mkdir $(INST_INC)/libssh2
cp -r $(LIBSSH_INC)/* $(INST_INC)/libssh2
cp -r $(LIBSSH_LIB)/* $(INST_LIB)/
LIBSSH_REDIST_ROOT=$(PKGDIR)/libssh2.redist.$(LIBSSH_VER)/build/native
LIBSSH_REDIST_BIN=$(LIBSSH_REDIST_ROOT)/bin/v110/x64/Release/dynamic/cdecl
libssh_redist: insdir
cp -r $(LIBSSH_REDIST_BIN)/* $(INST_BIN)/
##################################################################
## We place the curl headers in their own subdirectory.
## The custom is to reference <curl/curl.h>, so compile with:
## -I$(INST_INC)
CURL_VER=7.30.0.2
CURL_ROOT=$(PKGDIR)/curl.$(CURL_VER)/build/native
CURL_INC=$(CURL_ROOT)/include/curl
CURL_LIB=$(CURL_ROOT)/lib/v110/x64/Release/dynamic
curl: insdir
[ -d $(INST_INC)/curl ] || mkdir $(INST_INC)/curl
cp -r $(CURL_INC)/* $(INST_INC)/curl
cp -r $(CURL_LIB)/* $(INST_LIB)/
CURL_REDIST_ROOT=$(PKGDIR)/curl.redist.$(CURL_VER)/build/native
CURL_REDIST_BIN=$(CURL_REDIST_ROOT)/bin/v110/x64/Release/dynamic
curl_redist: insdir
cp -r $(CURL_REDIST_BIN)/* $(INST_BIN)/
##################################################################
## We place the openssl headers in their own subdirectory.
## The custom is to reference <openssl/sha.h>, so compile with:
## -I$(INST_INC)
OPENSSL_VER=1.0.2.1
OPENSSL_ROOT=$(PKGDIR)/openssl.v140.windesktop.msvcstl.dyn.rt-dyn.x64.$(OPENSSL_VER)
OPENSSL_INC=$(OPENSSL_ROOT)/build/native/include/openssl
OPENSSL_LIB=$(OPENSSL_ROOT)/lib/native/v140/windesktop/msvcstl/dyn/rt-dyn/x64/release
openssl: insdir
[ -d $(INST_INC)/openssl ] || mkdir $(INST_INC)/openssl
cp -r $(OPENSSL_INC)/* $(INST_INC)/openssl
cp -r $(OPENSSL_LIB)/*.lib $(INST_LIB)/
cp -r $(OPENSSL_LIB)/*.dll $(INST_BIN)/
cp -r $(OPENSSL_LIB)/*.pdb $(INST_BIN)/
##################################################################
## We place the zlib headers in their own subdirectory.
## The custom is to reference <zlib.h>, so compile with:
## -I$(INST_INC)/zlib
ZLIB_VER=1.2.8.8
ZLIB_ROOT=$(PKGDIR)/zlib.v140.windesktop.msvcstl.dyn.rt-dyn.$(ZLIB_VER)
ZLIB_INC=$(ZLIB_ROOT)/build/native/include
ZLIB_LIB=$(ZLIB_ROOT)/lib/native/v140/windesktop/msvcstl/dyn/rt-dyn/x64/RelWithDebInfo
zlib: insdir
[ -d $(INST_INC)/zlib ] || mkdir $(INST_INC)/zlib
cp -r $(ZLIB_INC)/* $(INST_INC)/zlib
cp -r $(ZLIB_LIB)/*.lib $(INST_LIB)/
cp -r $(ZLIB_LIB)/*.dll $(INST_BIN)/
cp -r $(ZLIB_LIB)/*.pdb $(INST_BIN)/
##################################################################
clean:
rm -rf $(INST)
clobber: clean
rm -rf $(PKGDIR)

View File

@@ -1,3 +1,54 @@
The Steps to Build Git with VS2015 or VS2017 from the command line.
1. Install the "vcpkg" open source package manager and build essential
third-party libaries. The steps for this have been captured in a
set of convenience scripts. These can be run from a stock Command
Prompt or from an SDK bash window:
$ cd <repo_root>
$ ./compat/vcbuild/vcpkg_install.bat
The vcpkg tools and all of the third-party sources will be installed
in this folder:
<repo_root>/compat/vcbuild/vcpkg/
A file will be created with a set of Makefile macros pointing to a
unified "include", "lib", and "bin" directory (release and debug) for
all of the required packages. This file will be included by the main
Makefile:
<repo_root>/compat/vcbuild/MSVC-DEFS-GEN
2. OPTIONALLY copy the third-party *.dll and *.pdb files into the repo
root to make it easier to run and debug git.exe without having to
manipulate your PATH. This is especially true for debug sessions in
Visual Studio.
Use ONE of the following forms which should match how you want to
compile git.exe.
$ ./compat/vcbuild/vcpkg_copy_packages.bat debug
$ ./compat/vcbuild/vcpkg_copy_packages.bat release
3. Build git using MSVC from an SDK bash window using one of the
following commands:
$ make MSVC=1
$ make MSVC=1 DEBUG=1
================================================================
Alternatively, run `make MSVC=1 vcxproj` and then load the generated
git.sln in Visual Studio. The initial build will install the vcpkg
system and build the dependencies automatically. This will take a while.
Note that this will automatically add and commit the generated
.sln and .vcxproj files to the repo. You may want to drop this
commit before submitting a Pull Request....
Or maybe we should put the .sln/.vcxproj files in the .gitignores
and not do this. I'm not sure.
================================================================
The Steps of Build Git with VS2008
1. You need the build environment, which contains the Git dependencies

View File

@@ -1,54 +0,0 @@
Instructions for building Git for Windows using VS2015.
================================================================
Installing third-party dependencies:
====================================
[1] Install nuget.exe somewhere on your system and add it to your PATH.
https://docs.nuget.org/consume/command-line-reference
https://dist.nuget.org/index.html
[2] Download required nuget packages for third-party libraries.
Using a terminal window, type:
make -C compat/vcbuild
This will download the packages, unpack them into GEN.PKGS,
and populate the {include, lib, bin} directories in GEN.DEPS.
Building Git for Windows using VS2015:
======================================
[3] Build 64-bit version of Git for Windows.
Using a terminal window:
make MSVC=1 DEBUG=1
[4] Add compat/vcbuild/GEN.DEPS/bin to your PATH.
[5] You should then be able to run the test suite and any interactive
commands.
[6] To debug/profile in VS, open the git.exe in VS and run/debug
it. (Be sure to add GEN.DEPS/bin to the PATH in the debug
dialog.)
TODO List:
==========
[A] config.mak.uname currently contains hard-coded paths
to the various MSVC and SDK libraries for the 64-bit
version of the compilers and libaries.
See: SANE_TOOL_PATH, MSVC_DEPS, MSVC_SDK*, MSVC_VCDIR.
Long term, we need to figure out how to properly import
values for %VCINSTALLDIR%, %LIB%, %LIBPATH%, and the
other values normally set by "vsvars32.bat" when a
developer command prompt is started. This would also
allow us to switch between 32- and 64-bit tool chains.
[B] We need to build SLN or VCPROJ files.

View File

@@ -25,7 +25,7 @@ REM
REM The output of this script should be written to a make "include
REM file" and referenced by the top-level Makefile.
REM
REM See "config.mak.uname" (look for GIT-MSVC-GEN).
REM See "config.mak.uname" (look for compat/vcbuild/MSVC-DEFS-GEN).
REM ================================================================
REM The provided command prompts are custom to each VS release and
REM filled with lots of internal knowledge (such as Registry settings);
@@ -154,7 +154,9 @@ REM ================================================================
REM Include DOS-style and BASH-style path for bin dir.
echo msvc_bin_dir=%msvc_bin_dir%
echo msvc_bin_dir_msys=%msvc_bin_dir:C:=/C%
SET X1=%msvc_bin_dir:C:=/C%
SET X2=%X1:\=/%
echo msvc_bin_dir_msys=%X2%
echo msvc_includes=%msvc_includes%
echo msvc_libs=%msvc_libs%

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<!--
Used to specify the default location to expand packages.
See: NuGet.exe help install
See: NuGet.exe help update
-->
<add key="repositoryPath" value="Nupkg" />
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="False" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<activePackageSource>
<!-- this tells only one given source is active -->
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</activePackageSource>
</configuration>

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="curl" version="7.30.0.2" />
<package id="curl.redist" version="7.30.0.2" />
<package id="expat" version="2.1.0.11" />
<package id="libiconv" version="1.14.0.11" />
<package id="libiconv.redist" version="1.14.0.11" />
<package id="libssh2" version="1.4.3.3" />
<package id="libssh2.redist" version="1.4.3.3" />
<package id="openssl" 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" />
<package id="zlib" version="1.2.8.8" />
<package id="zlib.v140.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" />
</packages>

View File

@@ -14,8 +14,15 @@ my @args = ();
my @cflags = ();
my @lflags = ();
my $is_linking = 0;
my $is_debug = 0;
while (@ARGV) {
my $arg = shift @ARGV;
if ("$arg" eq "-DDEBUG") {
# Some vcpkg-based libraries have different names for release
# and debug versions. This hack assumes that -DDEBUG comes
# before any "-l*" flags.
$is_debug = 1;
}
if ("$arg" =~ /^-[DIMGOZ]/) {
push(@cflags, $arg);
} elsif ("$arg" eq "-o") {
@@ -30,9 +37,13 @@ while (@ARGV) {
push(@args, "-Fd$file_out.pdb");
}
} elsif ("$arg" eq "-lz") {
if ($is_debug) {
push(@args, "zlibd.lib");
} else{
push(@args, "zlib.lib");
}
} elsif ("$arg" eq "-liconv") {
push(@args, "iconv.lib");
push(@args, "libiconv.lib");
} elsif ("$arg" eq "-lcrypto") {
push(@args, "libeay32.lib");
} elsif ("$arg" eq "-lssl") {
@@ -40,7 +51,7 @@ while (@ARGV) {
} elsif ("$arg" eq "-lcurl") {
push(@args, "libcurl.lib");
} elsif ("$arg" eq "-lexpat") {
push(@args, "libexpat.lib");
push(@args, "expat.lib");
} elsif ("$arg" =~ /^-L/ && "$arg" ne "-LTCG") {
$arg =~ s/^-L/-LIBPATH:/;
push(@lflags, $arg);

View File

@@ -0,0 +1,39 @@
@ECHO OFF
REM ================================================================
REM This script is an optional step. It copies the *.dll and *.pdb
REM files (created by vcpkg_install.bat) into the top-level directory
REM of the repo so that you can type "./git.exe" and find them without
REM having to fixup your PATH.
REM
REM NOTE: Because the names of some DLL files change between DEBUG and
REM NOTE: RELEASE builds when built using "vcpkg.exe", you will need
REM NOTE: to copy up the corresponding version.
REM ================================================================
SETLOCAL EnableDelayedExpansion
@FOR /F "delims=" %%D IN ("%~dp0") DO @SET cwd=%%~fD
cd %cwd%
SET arch=x64-windows
SET inst=%cwd%vcpkg\installed\%arch%
IF [%1]==[release] (
echo Copying RELEASE mode DLLs to repo root...
) ELSE IF [%1]==[debug] (
SET inst=%inst%\debug
echo Copying DEBUG mode DLLs to repo root...
) ELSE (
echo ERROR: Invalid argument.
echo Usage: %~0 release
echo Usage: %~0 debug
EXIT /B 1
)
xcopy /e/s/v/y %inst%\bin\*.dll ..\..\
xcopy /e/s/v/y %inst%\bin\*.pdb ..\..\
xcopy /e/s/v/y %inst%\bin\*.dll ..\..\t\helper\
xcopy /e/s/v/y %inst%\bin\*.pdb ..\..\t\helper\
EXIT /B 0

View File

@@ -0,0 +1,81 @@
@ECHO OFF
REM ================================================================
REM This script installs the "vcpkg" source package manager and uses
REM it to build the third-party libraries that git requires when it
REM is built using MSVC.
REM
REM [1] Install VCPKG.
REM [a] Create <root>/compat/vcbuild/vcpkg/
REM [b] Download "vcpkg".
REM [c] Compile using the currently installed version of VS.
REM [d] Create <root>/compat/vcbuild/vcpkg/vcpkg.exe
REM
REM [2] Install third-party libraries.
REM [a] Download each (which may also install CMAKE).
REM [b] Compile in RELEASE mode and install in:
REM vcpkg/installed/<arch>/{bin,lib}
REM [c] Compile in DEBUG mode and install in:
REM vcpkg/installed/<arch>/debug/{bin,lib}
REM [d] Install headers in:
REM vcpkg/installed/<arch>/include
REM
REM [3] Create a set of MAKE definitions for the top-level
REM Makefile to allow "make MSVC=1" to find the above
REM third-party libraries.
REM [a] Write vcpkg/VCPGK-DEFS
REM
REM https://blogs.msdn.microsoft.com/vcblog/2016/09/19/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows/
REM https://github.com/Microsoft/vcpkg
REM https://vcpkg.readthedocs.io/en/latest/
REM ================================================================
SETLOCAL EnableDelayedExpansion
@FOR /F "delims=" %%D IN ("%~dp0") DO @SET cwd=%%~fD
cd %cwd%
dir vcpkg\vcpkg.exe >nul 2>nul && GOTO :install_libraries
echo Fetching vcpkg in %cwd%vcpkg
git.exe clone https://github.com/Microsoft/vcpkg vcpkg
IF ERRORLEVEL 1 ( EXIT /B 1 )
cd vcpkg
echo Building vcpkg
powershell -exec bypass scripts\bootstrap.ps1
IF ERRORLEVEL 1 ( EXIT /B 1 )
echo Successfully installed %cwd%vcpkg\vcpkg.exe
:install_libraries
SET arch=x64-windows
echo Installing third-party libraries...
FOR %%i IN (zlib expat libiconv openssl libssh2 curl) DO (
cd %cwd%vcpkg
SET p="packages\%%i_%arch%"
IF NOT EXIST "%p%" CALL :sub__install_one %%i
IF ERRORLEVEL 1 ( EXIT /B 1 )
)
:install_defines
cd %cwd%
SET inst=%cwd%vcpkg\installed\%arch%
echo vcpkg_inc=-I"%inst%\include">VCPKG-DEFS
echo vcpkg_rel_lib=-L"%inst%\lib">>VCPKG-DEFS
echo vcpkg_rel_bin="%inst%\bin">>VCPKG-DEFS
echo vcpkg_dbg_lib=-L"%inst%\debug\lib">>VCPKG-DEFS
echo vcpkg_dbg_bin="%inst%\debug\bin">>VCPKG-DEFS
EXIT /B 0
:sub__install_one
echo Installing package %1...
.\vcpkg.exe install %1:%arch%
IF ERRORLEVEL 1 ( EXIT /B 1 )
echo Finished %1
goto :EOF

View File

@@ -18,9 +18,18 @@ ifdef MSVC
# Generate and include makefile variables that point to the
# currently installed set of MSVC command line tools.
GIT-MSVC-GEN: ./compat/vcbuild/find_vs_env.bat
@./compat/vcbuild/find_vs_env.bat | sed 's|\\|/|g' >GIT-MSVC-GEN
-include GIT-MSVC-GEN
compat/vcbuild/MSVC-DEFS-GEN: compat/vcbuild/find_vs_env.bat
@"$<" | tr '\\' / >"$@"
include compat/vcbuild/MSVC-DEFS-GEN
# See if vcpkg and the vcpkg-build versions of the third-party
# libraries that we use are installed. We include the result
# to get $(vcpkg_*) variables defined for the Makefile.
ifeq (,$(SKIP_VCPKG))
compat/vcbuild/VCPKG-DEFS: compat/vcbuild/vcpkg_install.bat
@"$<"
include compat/vcbuild/VCPKG-DEFS
endif
endif
# We choose to avoid "if .. else if .. else .. endif endif"
@@ -427,13 +436,13 @@ ifeq ($(uname_S),Windows)
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
PTHREAD_LIBS =
lib =
# Path to the unpacked third-party libraries
MSVC_DEPS = compat/vcbuild/GEN.DEPS
BASIC_CFLAGS += \
-I$(MSVC_DEPS)/include -I$(MSVC_DEPS)/include/expat -I$(MSVC_DEPS)/include/zlib \
-L$(MSVC_DEPS)/lib \
$(sdk_includes) $(sdk_libs) \
$(msvc_includes) $(msvc_libs)
BASIC_CFLAGS += $(vcpkg_inc) $(sdk_includes) $(msvc_includes)
ifndef DEBUG
BASIC_CFLAGS += $(vcpkg_rel_lib)
else
BASIC_CFLAGS += $(vcpkg_dbg_lib)
endif
BASIC_CFLAGS += $(sdk_libs) $(msvc_libs)
# Optionally enable memory leak reporting.
# BASIC_CLFAGS += -DUSE_MSVC_CRTDBG
@@ -457,65 +466,6 @@ 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 command-list.h
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 command-list.h
git add -f command-list.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) $(LIB_PERL_GEN)
git add -f perl/build
# 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
@@ -717,3 +667,77 @@ ifeq ($(uname_S),QNX)
NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease
endif
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/*}/*.vcxproj
# Generate the LinkOrCopyBuiltins.targets file
(echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
for name in $(BUILT_INS);\
do \
echo ' <Copy SourceFiles="$$(OutDir)\git.exe" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
done && \
for name in $(REMOTE_CURL_ALIASES); \
do \
echo ' <Copy SourceFiles="$$(OutDir)\'"$(REMOTE_CURL_PRIMARY)"'" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
done && \
echo ' </Target>' && \
echo '</Project>') >git/LinkOrCopyBuiltins.targets
git add -f git/LinkOrCopyBuiltins.targets
# Add command-list.h
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 command-list.h
git add -f command-list.h
# Add scripts
rm -f perl/perl.mak
$(MAKE) MSVC=1 SKIP_VCPKG=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) $(LIB_PERL_GEN)
git add -f perl/build
# Add bin-wrappers, for testing
rm -rf bin-wrappers/
$(MAKE) MSVC=1 SKIP_VCPKG=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 SKIP_VCPKG=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) $@\`"

View File

@@ -123,62 +123,24 @@ sub createProject {
my $defines = join(";", sort(@{$$build_structure{"$prefix${name}_DEFINES"}}));
my $includes= join(";", sort(map { s/^-I//; s/\//\\/g; File::Spec->file_name_is_absolute($_) ? $_ : "$rel_dir\\$_" } @{$$build_structure{"$prefix${name}_INCLUDES"}}));
my $cflags = join(" ", sort(map { s/^-[GLMOZ].*//; s/.* .*/"$&"/; $_; } @{$$build_structure{"$prefix${name}_CFLAGS"}}));
$cflags =~ s/\"/&quot;/g;
$cflags =~ s/</&lt;/g;
$cflags =~ s/>/&gt;/g;
my $libs = '';
my $libs_release = "\n ";
my $libs_debug = "\n ";
if (!$static_library) {
$libs = join(";", sort(grep /^(?!libgit\.lib|xdiff\/lib\.lib|vcs-svn\/lib\.lib|libcurl\.lib|libeay32\.lib|libiconv\.lib|ssleay32\.lib|zlib\.lib)/, @{$$build_structure{"$prefix${name}_LIBS"}}));
$libs_release = join(";", sort(grep /^(?!libgit\.lib|xdiff\/lib\.lib|vcs-svn\/lib\.lib)/, @{$$build_structure{"$prefix${name}_LIBS"}}));
$libs_debug = $libs_release;
$libs_debug =~ s/zlib\.lib/zlibd\.lib/;
}
$defines =~ s/-D//g;
$defines =~ s/\"/&quot;/g;
$defines =~ s/</&lt;/g;
$defines =~ s/>/&gt;/g;
$defines =~ s/\'//g;
die "Could not create the directory $target for $label project!\n" unless (-d "$target" || mkdir "$target");
use File::Copy;
copy("$git_dir/compat/vcbuild/packages.config", "$target/packages.config");
my $needsCurl = grep(/libcurl.lib/, @{$$build_structure{"$prefix${name}_LIBS"}});
my $targetsImport = '';
my $targetsErrors = '';
my $afterTargets = '';
open F, "<$git_dir/compat/vcbuild/packages.config";
while (<F>) {
if (/<package id="([^"]+)" version="([^"]+)"/) {
if ($1 eq 'libiconv') {
# we have to link with the Release builds already because libiconv
# is only available targeting v100 and v110, see
# https://github.com/coapp-packages/libiconv/issues/2
$libs .= ";$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.$2\\build\\native\\lib\\v110\\\$(Platform)\\Release\\dynamic\\cdecl\\libiconv.lib";
$afterTargets .= "\n <Copy SourceFiles=\"$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.redist.$2\\build\\native\\bin\\v110\\\$(Platform)\\Release\\dynamic\\cdecl\\libiconv.dll\" DestinationFolder=\"\$(TargetDir)\" SkipUnchangedFiles=\"true\" />";
} elsif ($needsCurl && $1 eq 'curl') {
# libcurl is only available targeting v100 and v110
$libs .= ";$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.$2\\build\\native\\lib\\v110\\\$(Platform)\\Release\\dynamic\\libcurl.lib";
$afterTargets .= "\n <Copy SourceFiles=\"$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.redist.$2\\build\\native\\bin\\v110\\\$(Platform)\\Release\\dynamic\\libcurl.dll\" DestinationFolder=\"\$(TargetDir)\" SkipUnchangedFiles=\"true\" />";
} elsif ($needsCurl && $1 eq 'expat') {
# libexpat is only available targeting v100 and v110
$libs .= ";$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.$2\\build\\native\\lib\\v110\\\$(Platform)\\Release\\dynamic\\utf8\\libexpat.lib";
} elsif ($1 eq 'zlib') {
# zlib
$libs .= ";$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.v140.windesktop.msvcstl.dyn.rt-dyn.$2\\lib\\native\\v140\\windesktop\\msvcstl\\dyn\\rt-dyn\\x64\\RelWithDebInfo\\zlib.lib";
} elsif ($1 eq 'openssl') {
# openssl
$libs .= ";$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.v140.windesktop.msvcstl.dyn.rt-dyn.x64.$2\\lib\\native\\v140\\windesktop\\msvcstl\\dyn\\rt-dyn\\x64\\release\\libeay32.lib";
$libs .= ";$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.v140.windesktop.msvcstl.dyn.rt-dyn.x64.$2\\lib\\native\\v140\\windesktop\\msvcstl\\dyn\\rt-dyn\\x64\\release\\ssleay32.lib";
}
next if ($1 =~ /^(zlib$|openssl(?!.*(x64|x86)$))/);
my $targetsFile = "$rel_dir\\compat\\vcbuild\\GEN.PKGS\\$1.$2\\build\\native\\$1.targets";
$targetsImport .= "\n <Import Project=\"$targetsFile\" Condition=\"Exists('$targetsFile')\" />";
$targetsErrors .= "\n <Error Condition=\"!Exists('$targetsFile')\" Text=\"\$([System.String]::Format('\$(ErrorText)', '$targetsFile'))\" />";
}
}
close F;
open F, ">$vcxproj" or die "Could not open $vcxproj for writing!\n";
binmode F, ":crlf :utf8";
print F chr(0xFEFF);
@@ -206,6 +168,16 @@ sub createProject {
<PropertyGroup Label="Globals">
<ProjectGuid>$uuid</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<VCPKGArch Condition="'\$(Platform)'=='Win32'">x86-windows</VCPKGArch>
<VCPKGArch Condition="'\$(Platform)'!='Win32'">x64-windows</VCPKGArch>
<VCPKGArchDirectory>$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)</VCPKGArchDirectory>
<VCPKGBinDirectory Condition="'\(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\bin</VCPKGBinDirectory>
<VCPKGLibDirectory Condition="'\(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\lib</VCPKGLibDirectory>
<VCPKGBinDirectory Condition="'\(Configuration)'!='Debug'">\$(VCPKGArchDirectory)\\bin</VCPKGBinDirectory>
<VCPKGLibDirectory Condition="'\(Configuration)'!='Debug'">\$(VCPKGArchDirectory)\\lib</VCPKGLibDirectory>
<VCPKGIncludeDirectory>\$(VCPKGArchDirectory)\\include</VCPKGIncludeDirectory>
<VCPKGLibs Condition="'\(Configuration)'=='Debug'">$libs_debug</VCPKGLibs>
<VCPKGLibs Condition="'\(Configuration)'!='Debug'">$libs_release</VCPKGLibs>
</PropertyGroup>
<Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'\$(Configuration)'=='Debug'" Label="Configuration">
@@ -239,7 +211,7 @@ sub createProject {
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>$cflags %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$cdup;$cdup\\compat;$cdup\\compat\\regex;$cdup\\compat\\win32;$cdup\\compat\\poll;$cdup\\compat\\vcbuild\\include;\$(VCPKGIncludeDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<EnableParallelCodeGeneration />
<MinimalRebuild>true</MinimalRebuild>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
@@ -250,11 +222,23 @@ sub createProject {
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
<Link>
<AdditionalDependencies>$libs;\$(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>\$(VCPKGLibDirectory);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>\$(VCPKGLibs);\$(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>invalidcontinue.obj %(AdditionalOptions)</AdditionalOptions>
<ManifestFile>$cdup\\compat\\win32\\git.manifest</ManifestFile>
<SubSystem>Console</SubSystem>
</Link>
EOM
if ($target eq 'libgit') {
print F << "EOM";
<PreBuildEvent Condition="!Exists('$cdup\\compat\\vcbuild\\vcpkg') OR (!Exists('$cdup\\compat\\vcbuild\\vcpkg\\installed\\x64-windows\\include\\openssl\\ssl.h') AND !Exists('$cdup\\compat\\vcbuild\\vcpkg\\installed\\x86-windows\\include\\openssl\\ssl.h'))">
<Message>Initialize VCPKG</Message>
<Command>del "$cdup\\compat\\vcbuild\\vcpkg"</Command>
<Command>call "$cdup\\compat\\vcbuild\\vcpkg_install.bat" </Command>
</PreBuildEvent>
EOM
}
print F << "EOM";
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'\$(Platform)'=='Win32'">
<Link>
@@ -296,7 +280,7 @@ EOM
print F << "EOM";
</ItemGroup>
EOM
if (!$static_library) {
if (!$static_library || $target =~ 'vcs-svn') {
my $uuid_libgit = $$build_structure{"LIBS_libgit_GUID"};
my $uuid_xdiff_lib = $$build_structure{"LIBS_xdiff/lib_GUID"};
@@ -325,24 +309,21 @@ EOM
EOM
}
print F << "EOM";
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">$targetsImport
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>$targetsErrors
</Target>
EOM
if (!$static_library && $afterTargets ne '') {
if (!$static_library) {
print F << "EOM";
<Target Name="${target}_AfterBuild" AfterTargets="AfterBuild">$afterTargets
<Target Name="${target}_AfterBuild" AfterTargets="AfterBuild">
<ItemGroup>
<DLLsAndPDBs Include="\$(VCPKGBinDirectory)\\*.dll;\$(VCPKGBinDirectory)\\*.pdb" />
</ItemGroup>
<Copy SourceFiles="@(DLLsAndPDBs)" DestinationFolder="\$(OutDir)" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />
</Target>
EOM
}
if ($target eq 'git') {
print F " <Import Project=\"LinkOrCopyBuiltins.targets\" />\n";
}
print F << "EOM";
</Project>
EOM

View File

@@ -57,6 +57,8 @@ while (@ARGV) {
open(F, "<$infile") || die "Couldn't open file $infile";
@makedry = <F>;
close(F);
} else {
die "Unknown option: " . $arg;
}
}
@@ -80,7 +82,8 @@ EOM
# Capture the make dry stderr to file for review (will be empty for a release build).
my $ErrsFile = "msvc-build-makedryerrors.txt";
@makedry = `cd $git_dir && make -n MSVC=1 V=1 2>$ErrsFile` if !@makedry;
@makedry = `make -C $git_dir -n MSVC=1 SKIP_VCPKG=1 V=1 2>$ErrsFile`
if !@makedry;
# test for an empty Errors file and remove it
unlink $ErrsFile if -f -z $ErrsFile;
@@ -345,6 +348,8 @@ sub handleLinkLine
push(@libs, "ssleay32.lib");
} elsif ("$part" eq "-lcurl") {
push(@libs, "libcurl.lib");
} elsif ("$part" eq "-lexpat") {
push(@libs, "expat.lib");
} elsif ("$part" eq "-liconv") {
push(@libs, "libiconv.lib");
} elsif ($part =~ /^[-\/]/) {

View File

@@ -57,9 +57,6 @@ fi
. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
export PERL_PATH SHELL_PATH
test -z "$MSVC_DEPS" ||
PATH="$GIT_BUILD_DIR/$MSVC_DEPS/bin:$PATH"
################################################################
# It appears that people try to run tests without building...
test -n "$GIT_TEST_INSTALLED" || "$GIT_BUILD_DIR/git$X" >/dev/null ||