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 "%RELEASE%" == "" (
42 if "%WITH_TCP%" == "" (
46 if "%SECURED%" == "" (
50 if "%MULTIPLE_OWNER%" == "" (
54 if "%UWP_APP%" == "" (
55 REM Set it to build Win32 app by default
59 set THREAD_COUNT=%NUMBER_OF_PROCESSORS%
62 set WITH_UPSTREAM_LIBCOAP=1
64 set RD_MODE=CLIENT,SERVER
77 IF /I "%1"=="-threads" (
81 IF /I "%1"=="-noTest" (
84 IF /I "%1"=="-logging" (
87 IF /I "%1"=="-debugger" (
88 set DEBUG="%ProgramFiles(x86)%\Windows Kits\10\Debuggers\x64\cdb.exe" -2 -c "g"
90 IF /I "%1"=="-release" (
93 IF /I "%1"=="-noTCP" (
96 IF /I "%1"=="-noSecurity" (
99 IF /I "%1"=="-noMOT" (
102 IF /I "%1"=="-automaticUpdate" (
103 set AUTOMATIC_UPDATE=1
117 set BUILD_VARIANT=win32
118 if "%UWP_APP%" == "1" (
119 set BUILD_VARIANT=uwp
122 REM We need to append the "PATH" so the octbstack.dll can be found by executables
123 IF "%BUILD_MSYS%" == "" (
124 set BUILD_DIR=out\windows\%BUILD_VARIANT%\%TARGET_ARCH%\%BINDIR%
125 set PATH=!PATH!;!IOTIVITY_DIR!!BUILD_DIR!;
127 set BUILD_DIR=out\msys_nt\x86_64\%BINDIR%
128 set PATH=!PATH!;!BUILD_DIR!;C:\msys64\mingw64\bin
131 set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% UWP_APP=%UWP_APP% RELEASE=%RELEASE% WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=%WITH_TCP% BUILD_SAMPLE=ON LOGGING=%LOGGING% TEST=%TEST% RD_MODE=%RD_MODE% ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP% MULTIPLE_OWNER=%MULTIPLE_OWNER% -j %THREAD_COUNT% AUTOMATIC_UPDATE=%AUTOMATIC_UPDATE%
133 REM Use MSVC_VERSION=12.0 for VS2013, or MSVC_VERSION=14.0 for VS2015.
134 REM If MSVC_VERSION has not been defined here, SCons chooses automatically a VS version.
135 IF NOT "%MSVC_VERSION%" == "" (
136 set BUILD_OPTIONS=%BUILD_OPTIONS% MSVC_VERSION=%MSVC_VERSION%
139 REM *** BUILD OPTIONS ***
141 if "!RUN_ARG!"=="server" (
142 cd %BUILD_DIR%\resource\examples
143 %DEBUG% simpleserver.exe
144 ) else if "!RUN_ARG!"=="client" (
145 cd %BUILD_DIR%\resource\examples
146 %DEBUG% simpleclient.exe
147 ) else if "!RUN_ARG!"=="serverhq" (
148 cd %BUILD_DIR%\resource\examples
149 %DEBUG% simpleserverHQ.exe
150 ) else if "!RUN_ARG!"=="clienthq" (
151 cd %BUILD_DIR%\resource\examples
152 %DEBUG% simpleclientHQ.exe
153 ) else if "!RUN_ARG!"=="mediaclient" (
154 cd %BUILD_DIR%\resource\examples
155 %DEBUG% mediaclient.exe
156 ) else if "!RUN_ARG!"=="mediaserver" (
157 cd %BUILD_DIR%\resource\examples
158 %DEBUG% mediaserver.exe
159 ) else if "!RUN_ARG!"=="winuiclient" (
160 cd %BUILD_DIR%\resource\examples
161 %DEBUG% winuiclient.exe
162 ) else if "!RUN_ARG!"=="occlient" (
163 cd %BUILD_DIR%\resource\csdk\stack\samples\linux\SimpleClientServer
164 %DEBUG% occlientbasicops.exe -u 0 -t 3 -c 1
165 ) else if "!RUN_ARG!"=="ocserver" (
166 cd %BUILD_DIR%\resource\csdk\stack\samples\linux\SimpleClientServer
167 %DEBUG% ocserverbasicops.exe
168 ) else if "!RUN_ARG!"=="provclient" (
169 cd %BUILD_DIR%\resource\csdk\security\provisioning\sample
170 %DEBUG% provisioningclient.exe
171 ) else if "!RUN_ARG!"=="justworks" (
172 cd %BUILD_DIR%\resource\csdk\security\provisioning\sample
173 %DEBUG% sampleserver_justworks.exe
174 ) else if "!RUN_ARG!"=="test" (
175 %DEBUG% %BUILD_DIR%\resource\csdk\connectivity\test\catests.exe
176 %DEBUG% %BUILD_DIR%\resource\csdk\stack\test\stacktests.exe
177 %DEBUG% %BUILD_DIR%\resource\csdk\stack\test\cbortests.exe
178 %DEBUG% %BUILD_DIR%\resource\csdk\security\unittest\unittest.exe
179 %DEBUG% %BUILD_DIR%\resource\csdk\security\provisioning\unittest\unittest.exe
180 %DEBUG% %BUILD_DIR%\resource\c_common\ocrandom\test\randomtests.exe
181 %DEBUG% %BUILD_DIR%\resource\c_common\oic_malloc\test\malloctests.exe
182 %DEBUG% %BUILD_DIR%\resource\c_common\oic_string\test\stringtests.exe
183 %DEBUG% %BUILD_DIR%\resource\c_common\oic_time\test\timetests.exe
184 %DEBUG% %BUILD_DIR%\resource\unittests\unittests.exe
185 ) else if "!RUN_ARG!"=="build" (
186 echo Starting IoTivity build with these options:
187 echo TARGET_OS=%TARGET_OS%
188 echo TARGET_ARCH=%TARGET_ARCH%
189 echo UWP_APP=%UWP_APP%
190 echo BUILD_DIR=%BUILD_DIR%
191 echo SECURED=%SECURED%
192 echo RELEASE=%RELEASE%
194 echo LOGGING=%LOGGING%
195 echo ROUTING=%ROUTING%
196 echo WITH_TCP=%WITH_TCP%
197 echo WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP%
198 echo MULTIPLE_OWNER=%MULTIPLE_OWNER%
199 echo MSVC_VERSION=%MSVC_VERSION%
200 echo THREAD_COUNT=%THREAD_COUNT%
201 echo AUTOMATIC_UPDATE=%AUTOMATIC_UPDATE%
202 echo.scons VERBOSE=1 %BUILD_OPTIONS%
203 call scons.bat VERBOSE=1 %BUILD_OPTIONS%
205 echo SCons failed - exiting run.bat with code 3
208 ) else if "!RUN_ARG!"=="clean" (
209 echo Cleaning IoTivity build
211 call scons.bat VERBOSE=1 %BUILD_OPTIONS% -c
213 echo SCons failed - exiting run.bat with code 2
216 ) else if "!RUN_ARG!"=="cleangtest" (
217 rd /s /q extlibs\gtest\googletest-release-1.7.0
218 del extlibs\gtest\release-1.7.0.zip
220 echo.%0 - Script requires a valid argument!
221 echo Exiting run.bat with code 1
232 echo %0 - Helper to build/test iotivity. Requires an argument.
233 echo Installation: Drop this into your iotivity root directory to use it.
235 echo. Default build settings are: debug binaries run unittests and no logging
237 echo. Default build parameters can be overridden using the following arguments
239 REM At a quick look, the "Build either amd64 or x86 architecture binaries" message
240 REM below seems out of alignment with the other messages underneath it. But, "^|"
241 REM gets echoed as a single character, so the messages are actually aligned correctly
242 REM in the output of "run.bat".
243 echo -arch [x86 ^| amd64] - Build either amd64 or x86 architecture binaries
245 echo -noTest - Don't run the unittests after building the binaries
247 echo -logging - Enable logging while building the binaries
249 echo -debugger - Debug the requested application
251 echo -release - Build release binaries
253 echo -threads [NUMBER_OF_THREADS] - Build in parallel using [NUMBER_OF_THREADS] threads. Default: %NUMBER_OF_PROCESSORS%.
255 echo -noTCP - Build with the TCP adapter disabled
257 echo -noSecurity - Remove security support (results in code that cannot be certified by OCF)
259 echo -noMOT - Remove Multiple Ownership Transfer support.
261 echo -automaticUpdate - Automatically update libcoap to required version.
263 echo -uwp - Build for the Universal Windows Platform (UWP).
266 echo. Usage examples:
268 echo Launch SimpleClient with debugger:
269 echo %0 client -debugger
271 echo Launch SimpleServer:
274 echo Launch WinUIClient built in msys:
275 echo %0 msys winuiclient
277 echo Build amd64 debug binaries and run unit tests:
280 echo Build amd64 release binaries w/o running tests:
281 echo %0 build -arch amd64 -noTest -release
283 echo Build x86 debug binaries and run unit tests:
284 echo %0 build -arch x86
286 echo Build amd64 release binaries with logging enabled:
287 echo %0 build -arch amd64 -release -logging
289 echo Build using only one thread:
290 echo %0 build -threads 1
292 echo Build with TCP adapter disabled and run unit tests:
295 echo Build without security support and run unit tests:
296 echo %0 build -noSecurity
298 echo Build without Multiple Ownership Transfer support and run unit tests: