-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare.bat
76 lines (59 loc) · 1.9 KB
/
prepare.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@echo off
:: Maybe I should have used powershell but anyway this looks familiar for now
call :SANITY_CHECKS || (
>&2 echo ERROR: Sanity checks are failed
exit /B 1
)
vcpkg install libxml2 gtest --triplet x64-windows || (
>&2 echo ERROR: Cannot install dependencies
exit /B 1
)
if not exist "%~dp0build" mkdir "%~dp0build"
pushd %~dp0build
cmake .. -DCMAKE_GENERATOR_PLATFORM=x64 "-DCMAKE_TOOLCHAIN_FILE=%~dp0third-party\vcpkg\scripts\buildsystems\vcpkg.cmake"
popd
if %ERRORLEVEL% neq 0 (
>&2 echo ERROR: CMake failed with exit code %ERRORLEVEL%
exit /B %ERRORLEVEL%
)
echo INFO: Build finished
exit /B 0
:SANITY_CHECKS
:: Sanity checks are here
where git >nul 2>nul
if %ERRORLEVEL% neq 0 (
>&2 echo ERROR: Git command line client not found, please install it and add it into the path
exit /B 1
)
where cmake >nul 2>nul
if %ERRORLEVEL% neq 0 (
>&2 echo ERROR: CMake not found, please install it and add it into the path
exit /B 1
)
where vcpkg >nul 2>nul || call :GET_VCPKG || (
>&2 echo ERROR: VCPkg needed for this build script. If you use MSys2 then you already know what to do
exit /B 1
)
exit /B 0
:GET_VCPKG
:: Get vcpkg working
call :CLONE_REPOSITORY vcpkg https://github.com/Microsoft/vcpkg.git || exit /B 1
pushd %~dp0third-party\vcpkg
if not exist "%CD%\vcpkg.exe" cmd /C call bootstrap-vcpkg.bat
popd
if %ERRORLEVEL% neq 0 (
>&2 echo ERROR: Bootstrap vcpkg failed with %ERRORLEVEL%
exit /B 1
)
set PATH=%PATH%;%~dp0third-party\vcpkg
exit /B 0
:CLONE_REPOSITORY
:: Clone repositories into third-party folder
if not exist "%~dp0third-party\%1" git clone "%2" --recursive "%~dp0third-party\%1" || (
rd /S /Q "%~dp0third-party\%1"
exit /B 1
) else if not exist "%~dp0third-party\%1\.git" (
>&2 echo ERROR: Git folder does not exist for %1 but its folder exist "%~dp0third-party\%1"
exit /B 1
)
exit /B 0