forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vcpkg: get MSVC dependencies with vcpkg rather than nuget
Dependencies such as cURL and OpenSSL are necessary to build and run Git. Previously, we obtained those dependencies by fetching NuGet packages. However, it is notoriously hard to keep NuGet packages of C/C++ libraries up-to-date, as the toolsets for different Visual Studio versions are different, and the NuGet packages would have to ship them all. That is the reason why the NuGet packages we use are quite old, and even insecure in the case of cURL and OpenSSL (the versions contain known security flaws that have been addressed by later versions for which no NuGet packages are available). The better way to handle this situation is to use the vcpkg system: https://github.com/Microsoft/vcpkg The idea is that a single Git repository contains enough supporting files to build up-to-date versions of a large number of Open Source libraries on demand, including cURL and OpenSSL. We integrate this system via four new .bat files to 1) initialize the vcpkg system, 2) build the packages, 4) set up Git's Makefile system to find the build artifacts, and 3) copy the artifacts into the top-level directory We now also completely convert the pathname exported in the %msvc_bin_dir_msys% variable to MSYS format with forward slashes rather than a mixture of forward and back slashes. This solves an obscure problem observed by some developers: [...] http-push.c CC remote-curl.o remote-curl.c * new script parameters GEN git-instaweb sed: -e expression #7, char 155: invalid reference \2 on `s' command's RHS make: *** [Makefile:2023: git-instaweb] Error 1 Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
- Loading branch information
1 parent
85fda73
commit 4ee8d34
Showing
10 changed files
with
215 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
/GIT-BUILD-OPTIONS | ||
/GIT-CFLAGS | ||
/GIT-LDFLAGS | ||
/GIT-MSVC-GEN | ||
/GIT-PREFIX | ||
/GIT-PERL-DEFINES | ||
/GIT-PERL-HEADER | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
GEN.* | ||
/vcpkg/ | ||
/MSVC-DEFS-GEN | ||
/VCPKG-DEFS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters