compat / vcbuild / vcpkg_install.baton commit Merge branch 'nd/tree-walk-with-repo' (1eb0a12)
   1@ECHO OFF
   2REM ================================================================
   3REM This script installs the "vcpkg" source package manager and uses
   4REM it to build the third-party libraries that git requires when it
   5REM is built using MSVC.
   6REM
   7REM [1] Install VCPKG.
   8REM     [a] Create <root>/compat/vcbuild/vcpkg/
   9REM     [b] Download "vcpkg".
  10REM     [c] Compile using the currently installed version of VS.
  11REM     [d] Create <root>/compat/vcbuild/vcpkg/vcpkg.exe
  12REM
  13REM [2] Install third-party libraries.
  14REM     [a] Download each (which may also install CMAKE).
  15REM     [b] Compile in RELEASE mode and install in:
  16REM         vcpkg/installed/<arch>/{bin,lib}
  17REM     [c] Compile in DEBUG mode and install in:
  18REM         vcpkg/installed/<arch>/debug/{bin,lib}
  19REM     [d] Install headers in:
  20REM         vcpkg/installed/<arch>/include
  21REM
  22REM [3] Create a set of MAKE definitions for the top-level
  23REM     Makefile to allow "make MSVC=1" to find the above
  24REM     third-party libraries.
  25REM     [a] Write vcpkg/VCPGK-DEFS
  26REM
  27REM https://blogs.msdn.microsoft.com/vcblog/2016/09/19/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows/
  28REM https://github.com/Microsoft/vcpkg
  29REM https://vcpkg.readthedocs.io/en/latest/
  30REM ================================================================
  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