2 REM Helper script to build and run IoTivity on Windows
3 SETLOCAL ENABLEDELAYEDEXPANSION
10 IF /I "%1" == "msys" (
17 REM *** Default BUILD OPTIONS ***
20 if "%JENKINS_HOME%" == "" (
21 set AUTOMATIC_UPDATE=0
23 set AUTOMATIC_UPDATE=1
26 if "%TARGET_ARCH%" == "" (
34 if "%LOGGING%" == "" (
38 if "%LOG_LEVEL%" == "" (
42 if "%RELEASE%" == "" (
46 if "%WITH_TCP%" == "" (
50 if "%SECURED%" == "" (
54 if "%MULTIPLE_OWNER%" == "" (
58 if "%MSVC_UWP_APP%" == "" (
59 REM Set it to build Win32 app by default
63 if "%BUILD_JAVA%" == "" (
64 REM Do not build Java by default
68 set THREAD_COUNT=%NUMBER_OF_PROCESSORS%
71 set WITH_UPSTREAM_LIBCOAP=1
73 set RD_MODE=CLIENT,SERVER
86 IF /I "%1"=="-threads" (
90 IF /I "%1"=="-noTest" (
93 IF /I "%1"=="-logging" (
96 IF /I "%1"=="-logLevel" (
100 IF /I "%1"=="-debugger" (
101 set DEBUG="%ProgramFiles(x86)%\Windows Kits\10\Debuggers\x64\cdb.exe" -2 -c "g"
103 IF /I "%1"=="-release" (
106 IF /I "%1"=="-noTCP" (
109 IF /I "%1"=="-noSecurity" (
112 IF /I "%1"=="-noMOT" (
115 IF /I "%1"=="-automaticUpdate" (
116 set AUTOMATIC_UPDATE=1
121 IF /I "%1"=="-java" (
133 set BUILD_VARIANT=win32
134 if "%MSVC_UWP_APP%" == "1" (
135 set BUILD_VARIANT=uwp
138 REM We need to append the "PATH" so the octbstack.dll can be found by executables
139 IF "%BUILD_MSYS%" == "" (
140 set BUILD_DIR=out\windows\%BUILD_VARIANT%\%TARGET_ARCH%\%BINDIR%
141 set PATH=!PATH!;!IOTIVITY_DIR!!BUILD_DIR!;
143 set BUILD_DIR=out\msys_nt\x86_64\%BINDIR%
144 set PATH=!PATH!;!BUILD_DIR!;C:\msys64\mingw64\bin
147 set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% MSVC_UWP_APP=%MSVC_UWP_APP% RELEASE=%RELEASE% WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=%WITH_TCP% BUILD_SAMPLE=ON LOGGING=%LOGGING% LOG_LEVEL=%LOG_LEVEL% RD_MODE=%RD_MODE% ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP% MULTIPLE_OWNER=%MULTIPLE_OWNER% AUTOMATIC_UPDATE=%AUTOMATIC_UPDATE% BUILD_JAVA=%BUILD_JAVA%
149 REM Use MSVC_VERSION=12.0 for VS2013, or MSVC_VERSION=14.0 for VS2015.
150 REM If MSVC_VERSION has not been defined here, SCons chooses automatically a VS version.
151 IF NOT "%MSVC_VERSION%" == "" (
152 set BUILD_OPTIONS=%BUILD_OPTIONS% MSVC_VERSION=%MSVC_VERSION%
155 REM *** BUILD OPTIONS ***
157 if "!RUN_ARG!"=="server" (
158 cd %BUILD_DIR%\resource\examples
159 %DEBUG% simpleserver.exe
160 ) else if "!RUN_ARG!"=="client" (
161 cd %BUILD_DIR%\resource\examples
162 %DEBUG% simpleclient.exe
163 ) else if "!RUN_ARG!"=="serverhq" (
164 cd %BUILD_DIR%\resource\examples
165 %DEBUG% simpleserverHQ.exe
166 ) else if "!RUN_ARG!"=="clienthq" (
167 cd %BUILD_DIR%\resource\examples
168 %DEBUG% simpleclientHQ.exe
169 ) else if "!RUN_ARG!"=="mediaclient" (
170 cd %BUILD_DIR%\resource\examples
171 %DEBUG% mediaclient.exe
172 ) else if "!RUN_ARG!"=="mediaserver" (
173 cd %BUILD_DIR%\resource\examples
174 %DEBUG% mediaserver.exe
175 ) else if "!RUN_ARG!"=="winuiclient" (
176 cd %BUILD_DIR%\resource\examples
177 %DEBUG% winuiclient.exe
178 ) else if "!RUN_ARG!"=="occlient" (
179 cd %BUILD_DIR%\resource\csdk\stack\samples\linux\SimpleClientServer
180 %DEBUG% occlientbasicops.exe -u 0 -t 3 -c 1
181 ) else if "!RUN_ARG!"=="ocserver" (
182 cd %BUILD_DIR%\resource\csdk\stack\samples\linux\SimpleClientServer
183 %DEBUG% ocserverbasicops.exe
184 ) else if "!RUN_ARG!"=="provclient" (
185 cd %BUILD_DIR%\resource\csdk\security\provisioning\sample
186 %DEBUG% provisioningclient.exe
187 ) else if "!RUN_ARG!"=="justworks" (
188 cd %BUILD_DIR%\resource\csdk\security\provisioning\sample
189 %DEBUG% sampleserver_justworks.exe
190 ) else if "!RUN_ARG!"=="test" (
191 %DEBUG% %BUILD_DIR%\resource\csdk\connectivity\test\catests.exe
192 %DEBUG% %BUILD_DIR%\resource\csdk\stack\test\stacktests.exe
193 %DEBUG% %BUILD_DIR%\resource\csdk\stack\test\cbortests.exe
194 %DEBUG% %BUILD_DIR%\resource\csdk\security\unittest\unittest.exe
195 %DEBUG% %BUILD_DIR%\resource\csdk\security\provisioning\unittest\unittest.exe
196 %DEBUG% %BUILD_DIR%\resource\c_common\ocrandom\test\randomtests.exe
197 %DEBUG% %BUILD_DIR%\resource\c_common\oic_malloc\test\malloctests.exe
198 %DEBUG% %BUILD_DIR%\resource\c_common\oic_string\test\stringtests.exe
199 %DEBUG% %BUILD_DIR%\resource\c_common\oic_time\test\timetests.exe
200 %DEBUG% %BUILD_DIR%\resource\unittests\unittests.exe
201 ) else if "!RUN_ARG!"=="build" (
202 echo Starting IoTivity build with these options:
203 echo TARGET_OS=%TARGET_OS%
204 echo TARGET_ARCH=%TARGET_ARCH%
205 echo MSVC_UWP_APP=%MSVC_UWP_APP%
206 echo BUILD_DIR=%BUILD_DIR%
207 echo SECURED=%SECURED%
208 echo RELEASE=%RELEASE%
210 echo LOGGING=%LOGGING%
211 echo LOG_LEVEL=%LOG_LEVEL%
212 echo ROUTING=%ROUTING%
213 echo WITH_TCP=%WITH_TCP%
214 echo WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP%
215 echo MULTIPLE_OWNER=%MULTIPLE_OWNER%
216 echo MSVC_VERSION=%MSVC_VERSION%
217 echo THREAD_COUNT=%THREAD_COUNT%
218 echo AUTOMATIC_UPDATE=%AUTOMATIC_UPDATE%
219 echo BUILD_JAVA=%BUILD_JAVA%
222 REM - Generate coap.h, to avoid race conditions during second step below (see IOT-2376).
223 REM - Other SCons Config headers get generated during this step too, as a side effect.
224 echo.==============================================================
225 echo.run.bat : Generating Config header files...
226 echo.scons.bat -j 1 VERBOSE=1 TEST=0 %BUILD_OPTIONS% extlibs\libcoap\libcoap\include\coap\coap.h
227 call scons.bat -j 1 VERBOSE=1 TEST=0 %BUILD_OPTIONS% extlibs\libcoap\libcoap\include\coap\coap.h
229 echo SCons failed - exiting run.bat with code 5
234 REM - Compile everything, but don't run tests yet.
235 echo.==============================================================
236 echo.run.bat : Compiling...
237 echo.scons.bat -j %THREAD_COUNT% VERBOSE=1 TEST=0 %BUILD_OPTIONS%
238 call scons.bat -j %THREAD_COUNT% VERBOSE=1 TEST=0 %BUILD_OPTIONS%
240 echo SCons failed - exiting run.bat with code 3
245 REM - Run tests if needed, using a single SCons thread.
247 echo.==============================================================
248 echo.run.bat : Running tests...
249 echo.scons.bat -j 1 VERBOSE=1 TEST=1 %BUILD_OPTIONS%
250 call scons.bat -j 1 VERBOSE=1 TEST=1 %BUILD_OPTIONS%
252 echo SCons failed - exiting run.bat with code 4
256 ) else if "!RUN_ARG!"=="clean" (
257 echo Cleaning IoTivity build
259 echo.scons.bat -j 1 VERBOSE=1 TEST=%TEST% %BUILD_OPTIONS% -c
260 call scons.bat -j 1 VERBOSE=1 TEST=%TEST% %BUILD_OPTIONS% -c
262 echo SCons failed - exiting run.bat with code 2
265 ) else if "!RUN_ARG!"=="cleangtest" (
266 rd /s /q extlibs\gtest\googletest-release-1.7.0
267 del extlibs\gtest\release-1.7.0.zip
269 echo.%0 - Script requires a valid argument!
270 echo Exiting run.bat with code 1
281 echo %0 - Helper to build/test iotivity. Requires an argument.
282 echo Installation: Drop this into your iotivity root directory to use it.
284 echo. Default build settings are: debug binaries run unittests and no logging
286 echo. Default build parameters can be overridden using the following arguments
288 REM At a quick look, the "Build either amd64 or x86 architecture binaries" message
289 REM below seems out of alignment with the other messages underneath it. But, "^|"
290 REM gets echoed as a single character, so the messages are actually aligned correctly
291 REM in the output of "run.bat".
292 echo -arch [x86 ^| amd64] - Build either amd64 or x86 architecture binaries
294 echo -noTest - Don't run the unittests after building the binaries
296 echo -logging - Enable logging while building the binaries
298 echo -logLevel LEVEL - Enable logging while building the binaries, and ignore log entries less severe than LEVEL.
299 echo Valid levels are: DEBUG, INFO, WARNING, ERROR, and FATAL. Default level is DEBUG.
301 echo -debugger - Debug the requested application
303 echo -release - Build release binaries
305 echo -threads [NUMBER_OF_THREADS] - Build in parallel using [NUMBER_OF_THREADS] threads. Default: %NUMBER_OF_PROCESSORS%.
307 echo -noTCP - Build with the TCP adapter disabled
309 echo -noSecurity - Remove security support (results in code that cannot be certified by OCF)
311 echo -noMOT - Remove Multiple Ownership Transfer support.
313 echo -automaticUpdate - Automatically update libcoap to required version.
315 echo -uwp - Build for the Universal Windows Platform (UWP).
317 echo -java - Build Java. The JDK path must be set in the JAVA_HOME environment variable.
320 echo. Usage examples:
322 echo Launch SimpleClient with debugger:
323 echo %0 client -debugger
325 echo Launch SimpleServer:
328 echo Launch WinUIClient built in msys:
329 echo %0 msys winuiclient
331 echo Build amd64 debug binaries and run unit tests:
334 echo Build amd64 release binaries w/o running tests:
335 echo %0 build -arch amd64 -noTest -release
337 echo Build x86 debug binaries and run unit tests:
338 echo %0 build -arch x86
340 echo Build amd64 release binaries with logging enabled:
341 echo %0 build -arch amd64 -release -logging
343 echo Build debug binaries with logging enabled, and ignore log entries less severe than WARNING:
344 echo %0 build -logging -logLevel WARNING
346 echo Build using only one thread:
347 echo %0 build -threads 1
349 echo Build with TCP adapter disabled and run unit tests:
352 echo Build without security support and run unit tests:
353 echo %0 build -noSecurity
355 echo Build without Multiple Ownership Transfer support and run unit tests: