2019-06-25 16:49:39 +02:00
|
|
|
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.
|
|
|
|
|
2020-09-02 22:18:20 +02:00
|
|
|
$ ./compat/vcbuild/vcpkg_copy_dlls.bat debug
|
|
|
|
$ ./compat/vcbuild/vcpkg_copy_dlls.bat release
|
2019-06-25 16:49:39 +02:00
|
|
|
|
|
|
|
3. Build git using MSVC from an SDK bash window using one of the
|
|
|
|
following commands:
|
|
|
|
|
|
|
|
$ make MSVC=1
|
|
|
|
$ make MSVC=1 DEBUG=1
|
|
|
|
|
|
|
|
================================================================
|
|
|
|
|
2019-07-29 22:08:12 +02:00
|
|
|
Alternatively, run `make 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.
|
|
|
|
|
|
|
|
Instead of generating the `git.sln` file yourself (which requires a full Git
|
|
|
|
for Windows SDK), you may want to consider fetching the `vs/master` branch of
|
|
|
|
https://github.com/git-for-windows/git instead (which is updated automatically
|
|
|
|
via CI running `make vcxproj`). The `vs/master` branch does not require a Git
|
|
|
|
for Windows to build, but you can run the test scripts in a regular Git Bash.
|
|
|
|
|
|
|
|
Note that `make vcxproj` will automatically add and commit the generated `.sln`
|
|
|
|
and `.vcxproj` files to the repo. This is necessary to allow building a
|
|
|
|
fully-testable Git in Visual Studio, where a regular Git Bash can be used to
|
|
|
|
run the test scripts (as opposed to a full Git for Windows SDK): a number of
|
|
|
|
build targets, such as Git commands implemented as Unix shell scripts (where
|
|
|
|
`@@SHELL_PATH@@` and other placeholders are interpolated) require a full-blown
|
|
|
|
Git for Windows SDK (which is about 10x the size of a regular Git for Windows
|
|
|
|
installation).
|
|
|
|
|
|
|
|
If your plan is to open a Pull Request with Git for Windows, it is a good idea
|
|
|
|
to drop this commit before submitting.
|
|
|
|
|
|
|
|
================================================================
|
2009-09-16 10:20:29 +02:00
|
|
|
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:
|
Makefile: stop hardcoding {command,config}-list.h
Change various places that hardcode the names of these two files to
refer to either $(GENERATED_H), or to a new generated-hdrs
target. That target is consistent with the *-objs targets I recently
added in 029bac01a8 (Makefile: add {program,xdiff,test,git,fuzz}-objs
& objects targets, 2021-02-23).
A subsequent commit will add a new generated hook-list.h. By doing
this refactoring we'll only need to add the new file to the
GENERATED_H variable, not EXCEPT_HDRS, the vcbuild/README etc.
Hardcoding command-list.h there seems to have been a case of
copy/paste programming in 976aaedca0 (msvc: add a Makefile target to
pre-generate the Visual Studio solution, 2019-07-29). The
config-list.h was added later in 709df95b78 (help: move
list_config_help to builtin/help, 2020-04-16).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-09-23 12:29:57 +02:00
|
|
|
make generated-hdrs
|
help: move list_config_help to builtin/help
Starting in 3ac68a93fd2, help.o began to depend on builtin/branch.o,
builtin/clean.o, and builtin/config.o. This meant that help.o was
unusable outside of the context of the main Git executable.
To make help.o usable by other commands again, move list_config_help()
into builtin/help.c (where it makes sense to assume other builtin libraries
are present).
When command-list.h is included but a member is not used, we start to
hear a compiler warning. Since the config list is generated in a fairly
different way than the command list, and since commands and config
options are semantically different, move the config list into its own
header and move the generator into its own script and build rule.
For reasons explained in 976aaedc (msvc: add a Makefile target to
pre-generate the Visual Studio solution, 2019-07-29), some build
artifacts we consider non-source files cannot be generated in the
Visual Studio environment, and we already have some Makefile tweaks
to help Visual Studio to use generated command-list.h header file.
Do the same to a new generated file, config-list.h, introduced by
this change.
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
2020-04-16 23:18:03 +02:00
|
|
|
to generate the header file needed to compile git.
|
2009-09-16 10:20:29 +02:00
|
|
|
|
2009-09-16 10:20:30 +02:00
|
|
|
4. Then either build Git with the GNU Make Makefile in the Git projects
|
|
|
|
root
|
2009-09-16 10:20:29 +02:00
|
|
|
make MSVC=1
|
2009-09-16 10:20:30 +02:00
|
|
|
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.
|
2009-09-16 10:20:29 +02:00
|
|
|
|
|
|
|
Done!
|