]> git.ipfire.org Git - thirdparty/git.git/blob - compat/vcbuild/vcpkg_install.bat
Merge branch 'jk/escaped-wildcard-dwim'
[thirdparty/git.git] / compat / vcbuild / vcpkg_install.bat
1 @ECHO OFF
2 REM ================================================================
3 REM This script installs the "vcpkg" source package manager and uses
4 REM it to build the third-party libraries that git requires when it
5 REM is built using MSVC.
6 REM
7 REM [1] Install VCPKG.
8 REM [a] Create <root>/compat/vcbuild/vcpkg/
9 REM [b] Download "vcpkg".
10 REM [c] Compile using the currently installed version of VS.
11 REM [d] Create <root>/compat/vcbuild/vcpkg/vcpkg.exe
12 REM
13 REM [2] Install third-party libraries.
14 REM [a] Download each (which may also install CMAKE).
15 REM [b] Compile in RELEASE mode and install in:
16 REM vcpkg/installed/<arch>/{bin,lib}
17 REM [c] Compile in DEBUG mode and install in:
18 REM vcpkg/installed/<arch>/debug/{bin,lib}
19 REM [d] Install headers in:
20 REM vcpkg/installed/<arch>/include
21 REM
22 REM [3] Create a set of MAKE definitions for the top-level
23 REM Makefile to allow "make MSVC=1" to find the above
24 REM third-party libraries.
25 REM [a] Write vcpkg/VCPGK-DEFS
26 REM
27 REM https://blogs.msdn.microsoft.com/vcblog/2016/09/19/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows/
28 REM https://github.com/Microsoft/vcpkg
29 REM https://vcpkg.readthedocs.io/en/latest/
30 REM ================================================================
31
32 SETLOCAL EnableDelayedExpansion
33
34 @FOR /F "delims=" %%D IN ("%~dp0") DO @SET cwd=%%~fD
35 cd %cwd%
36
37 dir vcpkg\vcpkg.exe >nul 2>nul && GOTO :install_libraries
38
39 echo Fetching vcpkg in %cwd%vcpkg
40 git.exe clone https://github.com/Microsoft/vcpkg vcpkg
41 IF ERRORLEVEL 1 ( EXIT /B 1 )
42
43 cd vcpkg
44 echo Building vcpkg
45 powershell -exec bypass scripts\bootstrap.ps1
46 IF ERRORLEVEL 1 ( EXIT /B 1 )
47
48 echo Successfully installed %cwd%vcpkg\vcpkg.exe
49
50 :install_libraries
51 SET arch=x64-windows
52
53 echo Installing third-party libraries...
54 FOR %%i IN (zlib expat libiconv openssl libssh2 curl) DO (
55 cd %cwd%vcpkg
56 IF NOT EXIST "packages\%%i_%arch%" CALL :sub__install_one %%i
57 IF ERRORLEVEL 1 ( EXIT /B 1 )
58 )
59
60 :install_defines
61 cd %cwd%
62 SET inst=%cwd%vcpkg\installed\%arch%
63
64 echo vcpkg_inc=-I"%inst%\include">VCPKG-DEFS
65 echo vcpkg_rel_lib=-L"%inst%\lib">>VCPKG-DEFS
66 echo vcpkg_rel_bin="%inst%\bin">>VCPKG-DEFS
67 echo vcpkg_dbg_lib=-L"%inst%\debug\lib">>VCPKG-DEFS
68 echo vcpkg_dbg_bin="%inst%\debug\bin">>VCPKG-DEFS
69
70 EXIT /B 0
71
72
73 :sub__install_one
74 echo Installing package %1...
75
76 .\vcpkg.exe install %1:%arch%
77 IF ERRORLEVEL 1 ( EXIT /B 1 )
78
79 echo Finished %1
80 goto :EOF