This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
build_win.cmd
92 lines (67 loc) · 2.41 KB
/
build_win.cmd
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
SETLOCAL ENABLEEXTENSIONS
@echo on
SET SRC_ROOT=%cd%
SET CMAKE_ROOT=%cd%\cmake_build
IF ["%VSINSTALLDIR%"]==[""] goto :NO_VS_VARS
set CMAKE="%VSINSTALLDIR%\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"
set NINJA="%VSINSTALLDIR%\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\Ninja.exe"
set CMAKE_OPTIONS=-G "Ninja" -DUSE_INSTALLED_FRAMEWORK=ON -DCMAKE_MAKE_PROGRAM=%NINJA% -DCMAKE_INSTALL_PREFIX:PATH="%SRC_ROOT%\artifacts\install"
IF [%1]==[] set INVALID_ARG=1
IF [%2]==[] set INVALID_ARG=1
IF [%3]==[] set INVALID_ARG=1
if NOT INVALID_ARG == 1 goto :VALID_CMD_ARGS
echo "Invalid arguements!"
echo "build_win.cmd BUILD_TYPE ADAPTER_TYPE TARGET_NAME [BUILD_NUM]
echo "BUILD_TYPE: debug | release"
echo "ADAPTER_TYPE: real | simulator"
echo "TARGET_NAME: clean | build | rebuild"
echo "BUILD_NUM: (optional) XX.XX.XX.XXXX"
EXIT /B 1
:VALID_CMD_ARGS
:: the first parameter is an optional BUILD_TARGET
SET BUILD_TARGET=%3
IF [%3]==[] SET BUILD_TARGET=REBUILD
IF /I "%BUILD_TARGET%" == "clean" (
set BUILD_TARGET=clean
goto :VALID_BUILD_TARGET)
IF /I "%BUILD_TARGET%" == "build" (
set BUILD_TARGET=all
goto :VALID_BUILD_TARGET)
IF /I "%BUILD_TARGET%" == "rebuild" (
set BUILD_TARGET=rebuild
goto :VALID_BUILD_TARGET)
:: Invalid build type specified
echo "Must specify BUILD_TARGET: CLEAN, BUILD, REBUILD (default)."
EXIT /B 1
:VALID_BUILD_TARGET
echo "BUILD_TARGET=%BUILD_TARGET%"
set BUILD_TYPE=%1
set ADAPTER_TYPE=%2
IF NOT [%4]==[] set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DBUILDNUM=%4
if "%BUILD_TYPE%"=="release" (
set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DRELEASE=ON -DCMAKE_BUILD_TYPE="RelWithDebInfo"
) else ( set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DCMAKE_BUILD_TYPE="Debug" )
if "%ADAPTER_TYPE%"=="simulator" (
set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DBUILD_SIM=ON
)
echo "cmake %CMAKE_OPTIONS% %SRC_ROOT%"
if exist %CMAKE_ROOT% rmdir /s /q %CMAKE_ROOT%
mkdir %CMAKE_ROOT%
pushd %CMAKE_ROOT%
%CMAKE% %CMAKE_OPTIONS% %SRC_ROOT%
if %ERRORLEVEL% NEQ 0 echo "***BUILD FAILED *** " && popd && EXIT /B 1
if /I "%BUILD_TARGET%"=="rebuild" goto :NINJA_REBUILD
:NINJA_BUILD
%NINJA% -v %BUILD_TARGET%
if %ERRORLEVEL% NEQ 0 echo "***BUILD FAILED *** " && popd && EXIT /B 1
popd
echo "*** Windows built successfully! ***"
EXIT /B 0
:NINJA_REBUILD
%NINJA% clean
set BUILD_TARGET=all
goto :NINJA_BUILD
:NO_VS_VARS
echo "***BUILD FAILED *** "
echo "build_win.cmd must be run with environment set from Visual Studio. e.g. vcvars64.bat"
EXIT /B 1