Skip to content

Commit 3189231

Browse files
jeffhostetlerdscho
authored andcommitted
msvc: add NuGet scripts for building with VS2015
This commit contains a GNU Makefile and NuGet configuration scripts to download and install the various third-party libraries that we will need to build/link with when using VS2015 to build Git. The file "compat/vcbuild/README_VS2015.txt" contains instructions for using this. In this commit, "compat/vcbuild/Makefile" contains hard-coded version numbers of the packages we require. These are set to the current versions as of the time of this commit. We use "nuget restore" to install them explicitly using a "package.config". A future improvement would try to use some of the automatic package management functions and eliminate the need to specify exact versions. I tried, but could not get this to work. NuGet was happy dowload "minimum requirements" rather than "lastest" for dependencies -- and only look at one package at a time. For example, both curl and openssl depend upon zlib and have different minimums. It was unclear which version of zlib would be installed and seemed to be dependent on the order of the top-level packages. So, I'm skipping that for now. We need to be very precise when specifying NuGet package versions: while nuget.exe auto-completes a version, say, 1.0.2 to 1.0.2.0, we will want to parse packages.config ourselves, to generate the Visual Studio solution, and there we need the exact version number to be able to generate the exact path to the correct .targets file. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 286b1bb commit 3189231

File tree

5 files changed

+231
-0
lines changed

5 files changed

+231
-0
lines changed

compat/vcbuild/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GEN.*

compat/vcbuild/Makefile

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
## Makefile to install nuget package dependencies.
2+
##################################################################
3+
4+
INST=GEN.DEPS
5+
INST_INC=$(INST)/include
6+
INST_LIB=$(INST)/lib
7+
INST_BIN=$(INST)/bin
8+
9+
PKGDIR=GEN.PKGS
10+
11+
##################################################################
12+
all: unpack expat libssh libssh_redist curl curl_redist openssl zlib
13+
14+
unpack:
15+
[ -d $(PKGDIR) ] || mkdir $(PKGDIR)
16+
nuget.exe restore packages.config -ConfigFile nuget.config \
17+
-NonInteractive -OutputDirectory $(PKGDIR)
18+
19+
insdir:
20+
[ -d $(INST) ] || mkdir $(INST)
21+
[ -d $(INST_INC) ] || mkdir $(INST_INC)
22+
[ -d $(INST_BIN) ] || mkdir $(INST_BIN)
23+
[ -d $(INST_LIB) ] || mkdir $(INST_LIB)
24+
25+
##################################################################
26+
## We place the expat headers in their own subdirectory.
27+
## The custom is to reference <expat.h>, so compile with:
28+
## -I$(INST_INC)/expat
29+
30+
EXPAT_VER=2.1.0.11
31+
EXPAT_ROOT=$(PKGDIR)/expat.$(EXPAT_VER)/build/native
32+
EXPAT_INC=$(EXPAT_ROOT)/include
33+
EXPAT_LIB=$(EXPAT_ROOT)/lib/v110/x64/Release/dynamic/utf8
34+
35+
expat: insdir
36+
[ -d $(INST_INC)/expat ] || mkdir $(INST_INC)/expat
37+
cp -r $(EXPAT_INC)/* $(INST_INC)/expat/
38+
cp -r $(EXPAT_LIB)/* $(INST_LIB)/
39+
40+
41+
##################################################################
42+
43+
LIBSSH_VER=1.4.3.3
44+
LIBSSH_ROOT=$(PKGDIR)/libssh2.$(LIBSSH_VER)/build/native
45+
LIBSSH_INC=$(LIBSSH_ROOT)/include
46+
LIBSSH_LIB=$(LIBSSH_ROOT)/lib/v110/x64/Release/dynamic/cdecl
47+
48+
libssh: insdir
49+
[ -d $(INST_INC)/libssh2 ] || mkdir $(INST_INC)/libssh2
50+
cp -r $(LIBSSH_INC)/* $(INST_INC)/libssh2
51+
cp -r $(LIBSSH_LIB)/* $(INST_LIB)/
52+
53+
54+
LIBSSH_REDIST_ROOT=$(PKGDIR)/libssh2.redist.$(LIBSSH_VER)/build/native
55+
LIBSSH_REDIST_BIN=$(LIBSSH_REDIST_ROOT)/bin/v110/x64/Release/dynamic/cdecl
56+
57+
libssh_redist: insdir
58+
cp -r $(LIBSSH_REDIST_BIN)/* $(INST_BIN)/
59+
60+
61+
##################################################################
62+
## We place the curl headers in their own subdirectory.
63+
## The custom is to reference <curl/curl.h>, so compile with:
64+
## -I$(INST_INC)
65+
66+
CURL_VER=7.30.0.2
67+
CURL_ROOT=$(PKGDIR)/curl.$(CURL_VER)/build/native
68+
CURL_INC=$(CURL_ROOT)/include/curl
69+
CURL_LIB=$(CURL_ROOT)/lib/v110/x64/Release/dynamic
70+
71+
curl: insdir
72+
[ -d $(INST_INC)/curl ] || mkdir $(INST_INC)/curl
73+
cp -r $(CURL_INC)/* $(INST_INC)/curl
74+
cp -r $(CURL_LIB)/* $(INST_LIB)/
75+
76+
77+
CURL_REDIST_ROOT=$(PKGDIR)/curl.redist.$(CURL_VER)/build/native
78+
CURL_REDIST_BIN=$(CURL_REDIST_ROOT)/bin/v110/x64/Release/dynamic
79+
80+
curl_redist: insdir
81+
cp -r $(CURL_REDIST_BIN)/* $(INST_BIN)/
82+
83+
84+
##################################################################
85+
## We place the openssl headers in their own subdirectory.
86+
## The custom is to reference <openssl/sha.h>, so compile with:
87+
## -I$(INST_INC)
88+
89+
OPENSSL_VER=1.0.2.1
90+
OPENSSL_ROOT=$(PKGDIR)/openssl.v140.windesktop.msvcstl.dyn.rt-dyn.x64.$(OPENSSL_VER)
91+
OPENSSL_INC=$(OPENSSL_ROOT)/build/native/include/openssl
92+
OPENSSL_LIB=$(OPENSSL_ROOT)/lib/native/v140/windesktop/msvcstl/dyn/rt-dyn/x64/release
93+
94+
openssl: insdir
95+
[ -d $(INST_INC)/openssl ] || mkdir $(INST_INC)/openssl
96+
cp -r $(OPENSSL_INC)/* $(INST_INC)/openssl
97+
cp -r $(OPENSSL_LIB)/*.lib $(INST_LIB)/
98+
cp -r $(OPENSSL_LIB)/*.dll $(INST_BIN)/
99+
cp -r $(OPENSSL_LIB)/*.pdb $(INST_BIN)/
100+
101+
##################################################################
102+
## We place the zlib headers in their own subdirectory.
103+
## The custom is to reference <zlib.h>, so compile with:
104+
## -I$(INST_INC)/zlib
105+
106+
ZLIB_VER=1.2.8.8
107+
ZLIB_ROOT=$(PKGDIR)/zlib.v140.windesktop.msvcstl.dyn.rt-dyn.$(ZLIB_VER)
108+
ZLIB_INC=$(ZLIB_ROOT)/build/native/include
109+
ZLIB_LIB=$(ZLIB_ROOT)/lib/native/v140/windesktop/msvcstl/dyn/rt-dyn/x64/Release
110+
111+
zlib: insdir
112+
[ -d $(INST_INC)/zlib ] || mkdir $(INST_INC)/zlib
113+
cp -r $(ZLIB_INC)/* $(INST_INC)/zlib
114+
cp -r $(ZLIB_LIB)/*.lib $(INST_LIB)/
115+
cp -r $(ZLIB_LIB)/*.dll $(INST_BIN)/
116+
117+
##################################################################
118+
clean:
119+
rm -rf $(INST)
120+
121+
clobber: clean
122+
rm -rf $(PKGDIR)

compat/vcbuild/README_VS2015.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Instructions for building Git for Windows using VS2015.
2+
================================================================
3+
4+
Installing third-party dependencies:
5+
====================================
6+
7+
[1] Install nuget.exe somewhere on your system and add it to your PATH.
8+
https://docs.nuget.org/consume/command-line-reference
9+
https://dist.nuget.org/index.html
10+
11+
[2] Download required nuget packages for third-party libraries.
12+
Using a terminal window, type:
13+
14+
make -C compat/vcbuild
15+
16+
This will download the packages, unpack them into GEN.PKGS,
17+
and populate the {include, lib, bin} directories in GEN.DEPS.
18+
19+
20+
Building Git for Windows using VS2015:
21+
======================================
22+
23+
[3] Build 64-bit version of Git for Windows.
24+
Using a terminal window:
25+
26+
make MSVC=1 DEBUG=1
27+
28+
29+
[4] Add compat/vcbuild/GEN.DEPS/bin to your PATH.
30+
31+
[5] You should then be able to run the test suite and any interactive
32+
commands.
33+
34+
[6] To debug/profile in VS, open the git.exe in VS and run/debug
35+
it. (Be sure to add GEN.DEPS/bin to the PATH in the debug
36+
dialog.)
37+
38+
39+
TODO List:
40+
==========
41+
42+
[A] config.mak.uname currently contains hard-coded paths
43+
to the various MSVC and SDK libraries for the 64-bit
44+
version of the compilers and libaries.
45+
46+
See: SANE_TOOL_PATH, MSVC_DEPS, MSVC_SDK*, MSVC_VCDIR.
47+
48+
Long term, we need to figure out how to properly import
49+
values for %VCINSTALLDIR%, %LIB%, %LIBPATH%, and the
50+
other values normally set by "vsvars32.bat" when a
51+
developer command prompt is started. This would also
52+
allow us to switch between 32- and 64-bit tool chains.
53+
54+
[B] Currently, we leave the third-party DLLs we reference in
55+
"compat/vcbuild/GEN.DEPS/bin". We need an installer
56+
step to move them next to git.exe (or into libexec/git-core).
57+
58+
[C] We need to build SLN or VCPROJ files.

compat/vcbuild/nuget.config

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<config>
4+
<!--
5+
Used to specify the default location to expand packages.
6+
See: NuGet.exe help install
7+
See: NuGet.exe help update
8+
-->
9+
<add key="repositoryPath" value="Nupkg" />
10+
</config>
11+
<packageSources>
12+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
13+
</packageSources>
14+
<packageRestore>
15+
<!-- Allow NuGet to download missing packages -->
16+
<add key="enabled" value="True" />
17+
<!-- Automatically check for missing packages during build in Visual Studio -->
18+
<add key="automatic" value="False" />
19+
</packageRestore>
20+
<bindingRedirects>
21+
<add key="skip" value="False" />
22+
</bindingRedirects>
23+
<activePackageSource>
24+
<!-- this tells only one given source is active -->
25+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
26+
</activePackageSource>
27+
</configuration>

compat/vcbuild/packages.config

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="curl" version="7.30.0.2" />
4+
<package id="curl.redist" version="7.30.0.2" />
5+
6+
<package id="expat" version="2.1.0.11" />
7+
8+
<package id="libssh2" version="1.4.3.3" />
9+
<package id="libssh2.redist" version="1.4.3.3" />
10+
11+
<package id="openssl" version="1.0.2.1" />
12+
<package id="openssl.v120.windesktop.msvcstl.dyn.rt-dyn" version="1.0.2.1" />
13+
<package id="openssl.v120.windesktop.msvcstl.dyn.rt-dyn.x64" version="1.0.2.0" />
14+
<package id="openssl.v120.windesktop.msvcstl.dyn.rt-dyn.x86" version="1.0.2.1" />
15+
<package id="openssl.v140.windesktop.msvcstl.dyn.rt-dyn" version="1.0.2.1" />
16+
<package id="openssl.v140.windesktop.msvcstl.dyn.rt-dyn.x64" version="1.0.2.1" />
17+
<package id="openssl.v140.windesktop.msvcstl.dyn.rt-dyn.x86" version="1.0.2.1" />
18+
19+
<package id="zlib" version="1.2.8.8" />
20+
<package id="zlib.v120.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" />
21+
<package id="zlib.v140.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" />
22+
23+
</packages>

0 commit comments

Comments
 (0)