|
| 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 | + SET p="packages\%%i_%arch%" |
| 57 | + IF NOT EXIST "%p%" CALL :sub__install_one %%i |
| 58 | + IF ERRORLEVEL 1 ( EXIT /B 1 ) |
| 59 | + ) |
| 60 | + |
| 61 | +:install_defines |
| 62 | + cd %cwd% |
| 63 | + SET inst=%cwd%vcpkg\installed\%arch% |
| 64 | + |
| 65 | + echo vcpkg_inc=-I"%inst%\include">VCPKG-DEFS |
| 66 | + echo vcpkg_rel_lib=-L"%inst%\lib">>VCPKG-DEFS |
| 67 | + echo vcpkg_rel_bin="%inst%\bin">>VCPKG-DEFS |
| 68 | + echo vcpkg_dbg_lib=-L"%inst%\debug\lib">>VCPKG-DEFS |
| 69 | + echo vcpkg_dbg_bin="%inst%\debug\bin">>VCPKG-DEFS |
| 70 | + |
| 71 | + EXIT /B 0 |
| 72 | + |
| 73 | + |
| 74 | +:sub__install_one |
| 75 | + echo Installing package %1... |
| 76 | + |
| 77 | + .\vcpkg.exe install %1:%arch% |
| 78 | + IF ERRORLEVEL 1 ( EXIT /B 1 ) |
| 79 | + |
| 80 | + echo Finished %1 |
| 81 | + goto :EOF |
0 commit comments