-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.bat
200 lines (155 loc) · 5.38 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
@echo off
REM
REM OpcUaStack build and install script
REM
set CMAKE=cmake.exe
REM ---------------------------------------------------------------------------
REM
REM main
REM
REM ---------------------------------------------------------------------------
set ARG_COUNT=0
for %%x in (%*) do set /A ARG_COUNT+=1
if %ARG_COUNT% LSS 2 goto :usage
set INSTALL_PREFIX=C:\ASNeG
set COMMAND="local"
set STACK_PREFIX=C:\ASNeG
set VS_GENERATOR=""
set BUILD_TYPE="Debug"
set JOBS=1
set STANDALONE=OFF
:parse
if "%~1"=="" goto :execute
if "%~1"=="/t" set COMMAND=%2
if "%~1"=="-t" set COMMAND=%2
if "%~1"=="--target" set COMMAND=%2
if "%~1"=="/i" set INSTALL_PREFIX=%~2
if "%~1"=="-i" set INSTALL_PREFIX=%~2
if "%~1"=="--install-prefix" set INSTALL_PREFIX=%~2
if "%~1"=="/s" set STACK_PREFIX="%~2"
if "%~1"=="-s" set STACK_PREFIX="%~2"
if "%~1"=="--stack-prefix" set STACK_PREFIX="%~2"
if "%~1"=="/vs" set VS_GENERATOR="-G%~2"
if "%~1"=="-vs" set VS_GENERATOR="-G%~2"
if "%~1"=="--vs-generator" set VS_GENERATOR="-G%~2"
if "%~1"=="/B" set BUILD_TYPE=%~2
if "%~1"=="-B" set BUILD_TYPE=%~2
if "%~1"=="--build-type" set BUILD_TYPE=%~2
if "%~1"=="/j" set JOBS=%~2
if "%~1"=="-j" set JOBS=%~2
if "%~1"=="--jobs" set JOBS=%~2
shift
REM flags
if "%~2"=="/S" set STANDALONE=ON
if "%~2"=="-S" set STANDALONE=ON
if "%~2"=="--standalone" set STANDALONE=ON
shift
goto :parse
:execute
set ARCH="x86"
if %VS_GENERATOR%=="" goto :set_build_suffix
if /i "%VS_GENERATOR:~-6,-1%"=="Win64" set ARCH="x64"
if /i "%VS_GENERATOR:~-4,-1%%"=="ARM" set ARCH="arm"
:set_build_suffix
set BUILD_DIR_SUFFIX=%ARCH%_vs%VisualStudioVersion%_%BUILD_TYPE%
if "%COMMAND%" == "" (
call:build_local
goto:error_handle
)
if "%COMMAND%" == "local" (
call:build_local
goto:error_handle
)
if "%COMMAND%" == "msi" (
call:build_msi
goto:error_handle
)
if "%COMMAND%" == "tst" (
call:build_tst
goto:error_handle
)
call:usage
goto:error_handle
REM ---------------------------------------------------------------------------
REM
REM build local function
REM
REM ---------------------------------------------------------------------------
:build_local
echo build and install local
REM
REM build OpcUaStack
REM
%CMAKE% %VS_GENERATOR% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_CXX_FLAGS=/MP%JOBS% -DOPCUASTACK_INSTALL_PREFIX=%STACK_PREFIX% -H./src/ -B./build_local_%BUILD_DIR_SUFFIX%
REM
REM install OpcUaStack
REM
set DESTDIR=%INSTALL_PREFIX%
%CMAKE% --build build_local_%BUILD_DIR_SUFFIX% --target install --config %BUILD_TYPE%
goto:error_handle
REM ---------------------------------------------------------------------------
REM
REM build MSI function
REM
REM ---------------------------------------------------------------------------
:build_msi
echo build MSI package
REM
REM build OpcUaStack
REM
%CMAKE% %VS_GENERATOR% -DCPACK_BINARY_MSI=ON -DSTANDALONE=%STANDALONE% -DCMAKE_CXX_FLAGS=/MP%JOBS% -DOPCUASTACK_INSTALL_PREFIX=%STACK_PREFIX% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -H./src/ -B./build_msi_%BUILD_DIR_SUFFIX%
REM
REM package OpcUaStack to MSI
REM
%CMAKE% --build build_msi_%BUILD_DIR_SUFFIX% --target package --config %BUILD_TYPE%
goto:error_handle
REM ---------------------------------------------------------------------------
REM
REM build tst function
REM
REM ---------------------------------------------------------------------------
:build_tst
echo build unittest
REM
REM build unittest
REM
%CMAKE% %VS_GENERATOR% -DOPCUASTACK_INSTALL_PREFIX="%STACK_PREFIX%" -DCMAKE_CXX_FLAGS=/MP%JOBS% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -H./tst/ -B./build_tst_%BUILD_DIR_SUFFIX%
REM
REM install OpcUaStack
REM
%CMAKE% --build build_tst_%BUILD_DIR_SUFFIX% --config %BUILD_TYPE%
goto:error_handle
REM ---------------------------------------------------------------------------
REM
REM usage function
REM
REM ---------------------------------------------------------------------------
:usage
echo "build.bat --target (local | tst | msi)"
echo.
echo --target, -t, /t: sets one of the folowing target:
echo local - create local build and install in folder C:/install
echo tst - build unit application
echo msi - build msi package
echo.
echo --stack-prefix, -s, /s STACK_PREFIX: set the path to directory
echo \twhere the OpcUaStack is installed (default: C:\ASNeG)
echo.
echo --install-prefix, -i, /i INSTALL_PREFIX: is the path to directory
echo \twhere the application should be installed (default: C:\ASNeG)
echo.
echo --vs-generator, -vs, /vs VS_GENERATOR: is the name of cmake generator
echo \t witch cmake uses during the building of the project. By default, cmake tries to figure out the generator from the environment.
echo.
echo --build-type, -B, /B BUILD_TYPE: set the build types Debug or Release. By default, it is Debug type.
echo.
echo --standalone, -S, /S: includes OpcUaStack and its dependencies in MSI package of the application
echo.
echo "--jobs, -j, /j JOB_COUNT: sets the number of the jobs of make"
echo.
goto:error_handle
:error_handle
if errorlevel 1 (
echo finished with errocode %errorlevel%
exit /b %errorlevel%
)