git/compat/vcbuild/README
Jeff Hostetler dce7d29551 msvc: support building Git using MS Visual C++
With this patch, Git can be built using the Microsoft toolchain, via:

	make MSVC=1 [DEBUG=1]

Third party libraries are built from source using the open source
"vcpkg" tool set. See https://github.com/Microsoft/vcpkg

On a first build, the vcpkg tools and the third party libraries are
automatically downloaded and built. DLLs for the third party libraries
are copied to the top-level (and t/helper) directory to facilitate
debugging. See compat/vcbuild/README.

A series of .bat files are invoked by the Makefile to find the location
of the installed version of Visual Studio and the associated compiler
tools (essentially replicating the environment setup performed by a
"Developer Command Prompt"). This should find the most recent VS2015 or
VS2017 installation. Output from these scripts are used by the Makefile
to define compiler and linker pathnames and -I and -L arguments.

The build produces .pdb files for both debug and release builds.

Note: This commit was squashed from an organic series of commits
developed between 2016 and 2018 in Git for Windows' `master` branch.
This combined commit eliminates the obsolete commits related to fetching
NuGet packages for third party libraries. It is difficult to use NuGet
packages for C/C++ sources because they may be built by earlier versions
of the MSVC compiler and have CRT version and linking issues.

Additionally, the C/C++ NuGet packages that we were using tended to not
be updated concurrently with the sources.  And in the case of cURL and
OpenSSL, this could expose us to security issues.

Helped-by: Yue Lin Ho <b8732003@student.nsysu.edu.tw>
Helped-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-06-25 10:46:57 -07:00

90 lines
3.2 KiB
Plaintext

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 libraries. 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
================================================================
The Steps of Build Git with VS2008
1. You need the build environment, which contains the Git dependencies
to be able to compile, link and run Git with MSVC.
You can either use the binary repository:
WWW: http://repo.or.cz/w/msvcgit.git
Git: git clone git://repo.or.cz/msvcgit.git
Zip: http://repo.or.cz/w/msvcgit.git?a=snapshot;h=master;sf=zip
and call the setup_32bit_env.cmd batch script before compiling Git,
(see repo/package README for details), or the source repository:
WWW: http://repo.or.cz/w/gitbuild.git
Git: git clone git://repo.or.cz/gitbuild.git
Zip: (None, as it's a project with submodules)
and build the support libs as instructed in that repo/package.
2. Ensure you have the msysgit environment in your path, so you have
GNU Make, bash and perl available.
WWW: http://repo.or.cz/w/msysgit.git
Git: git clone git://repo.or.cz/msysgit.git
Zip: http://repo.or.cz/w/msysgit.git?a=snapshot;h=master;sf=zip
This environment is also needed when you use the resulting
executables, since Git might need to run scripts which are part of
the git operations.
3. Inside Git's directory run the command:
make command-list.h
to generate the command-list.h file needed to compile git.
4. Then either build Git with the GNU Make Makefile in the Git projects
root
make MSVC=1
or generate Visual Studio solution/projects (.sln/.vcproj) with the
command
perl contrib/buildsystems/generate -g Vcproj
and open and build the solution with the IDE
devenv git.sln /useenv
or build with the IDE build engine directly from the command line
devenv git.sln /useenv /build "Release|Win32"
The /useenv option is required, so Visual Studio picks up the
environment variables for the support libraries required to build
Git, which you set up in step 1.
Done!