-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.bat
151 lines (134 loc) · 3.79 KB
/
build.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
REM
REM Copyright (C) 2022-2024 Intel Corporation
REM
REM SPDX-License-Identifier: MIT
REM
@echo off
setlocal enabledelayedexpansion
:: Defaults
set USE_NINJA=0
set BUILD_TYPE=Debug
set BITS=64
set VS=2022
set DO_BUILD=0
set ALL_PLATFORMS_SUPPORT=-DAUBSTREAM_ALLOW_LEGACY_PLATFORMS_SUPPORT=1
:: Parse arguments
goto :arg_parse
:arg_loop
shift
:arg_parse
if "%~1" == "" goto :configure
if "%~1" == "-ninja" (
set USE_NINJA=1
goto :arg_loop
)
if "%~1" == "-build" (
set BUILD_TYPE=%~2
shift
goto :arg_loop
)
if "%~1" == "-bits" (
set BITS=%~2
shift
goto :arg_loop
)
if "%~1" == "-vs" (
set VS=%~2
shift
goto :arg_loop
)
if "%~1" == "-do-build" (
set DO_BUILD=1
goto :arg_loop
)
if "%~1" == "-h" (
goto :Usage
)
if "%~1" == "-help" (
goto :Usage
)
echo Ignoring unknown argument: %1
goto :arg_loop
:configure
set PLATFORM=Windows%BITS%
if "%USE_NINJA%" == "1" (
set COMPILER=Ninja
set PLATFORM_FLAGS=-DCMAKE_BUILD_TYPE=%BUILD_TYPE%
set PLATFORM=%PLATFORM%\%BUILD_TYPE%
goto :configure_2
)
if "%VS%" == "2019" (
set COMPILER=Visual Studio 16 2019
set PLATFORM_FLAGS=-Thost=x64
if "%BITS%" == "64" (
set PLATFORM_FLAGS=!PLATFORM_FLAGS! -Ax64
) else (
set PLATFORM_FLAGS=!PLATFORM_FLAGS! -Awin32
)
) else if "%VS%" == "2022" (
set COMPILER=Visual Studio 17 2022
set PLATFORM_FLAGS=-Thost=x64
if "%BITS%" == "64" (
set PLATFORM_FLAGS=!PLATFORM_FLAGS! -Ax64
) else (
set PLATFORM_FLAGS=!PLATFORM_FLAGS! -Awin32
)
) else (
set COMPILER=Visual Studio 15 2017
set PLATFORM_FLAGS=-Thost=x64
if "%BITS%" == "64" (
set COMPILER=!COMPILER! Win64
)
)
:configure_2
set PROJECT_DIRECTORY=%~dp0
if "%BRANCH%" == "" (
set BUILD_DIRECTORY=%PROJECT_DIRECTORY%build_master\%PLATFORM%
set BRANCH_FLAGS=
) else (
set BUILD_DIRECTORY=%PROJECT_DIRECTORY%build\%PLATFORM%
set BRANCH_FLAGS=-DBRANCH_TYPE=%BRANCH%
)
set CMAKE_EXE="cmake.exe"
echo -- Looking for cmake.exe
WHERE cmake.exe
IF %ERRORLEVEL% NEQ 0 set SUCCESS=1 & echo ERROR: Unable to find cmake at %CMAKE_EXE% & goto :FAIL
echo -- Looking for cmake.exe -- found
if not exist %BUILD_DIRECTORY% mkdir %BUILD_DIRECTORY%
pushd .
cd %BUILD_DIRECTORY%
:: echo %CMAKE_EXE% -Wno-dev -G "%COMPILER%" %PLATFORM_FLAGS% %BRANCH_FLAGS% -DBUILD_BITS=%BITS% %PROJECT_DIRECTORY% -Daubstream_build_tests=1 %ALL_PLATFORMS_SUPPORT%
%CMAKE_EXE% -G "%COMPILER%" %PLATFORM_FLAGS% %BRANCH_FLAGS% -DBUILD_BITS=%BITS% %PROJECT_DIRECTORY% -Daubstream_build_tests=1 %ALL_PLATFORMS_SUPPORT%
if !ERRORLEVEL! NEQ 0 set SUCCESS=!ERRORLEVEL! & popd & echo ERROR: cmake failed with !ERRORLEVEL!. Exiting... & goto :FAIL
popd
:: Perform Build
set BUILD_FLAGS=
if "%USE_NINJA%" == "1" (
set BUILD_FLAGS=-- all aub_stream aub_stream_all_hw
) else (
set BUILD_FLAGS=--config %BUILD_TYPE%
)
if "%DO_BUILD%" == "1" (
%CMAKE_EXE% --build "%BUILD_DIRECTORY%" %BUILD_FLAGS%
)
:EXIT
EXIT /B %ERRORLEVEL%
:FAIL
echo.
echo Error
EXIT /B 1
:Usage
set script=build.bat
echo Usage: %script% ^[OPTIONS^]
echo Valid Options:
echo -vs ^<2017^|2019^> Select Visual Studio 2017 or Visual Studio 2019
echo ^(ignored when using -ninja^) ^[default: 2019^]
echo -ninja Use ninja as the build tool. Must be run from developer command prompt.
echo ^[default: off^]
echo -bits ^<32^|64^> Select 32-bit or 64-bit build. ^[default: 64^]
echo ^(ignored when using -ninja^)
echo -build ^<Debug^|Release^|ReleaseInternal^>
echo Select build type. ^[default: Debug^]
echo -do-build Perform build after cmake configuration. ^[default: off^]
echo -h, -help Display this help message and exit
exit /B 0