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 "%TARGET_ARCH%" == "" (
28 if "%LOGGING%" == "" (
32 if "%RELEASE%" == "" (
36 if "%WITH_TCP%" == "" (
40 if "%SECURED%" == "" (
44 set THREAD_COUNT=%NUMBER_OF_PROCESSORS%
46 set WITH_UPSTREAM_LIBCOAP=1
61 IF /I "%1"=="-threads" (
65 IF /I "%1"=="-noTest" (
68 IF /I "%1"=="-logging" (
71 IF /I "%1"=="-debugger" (
72 set DEBUG="%ProgramFiles(x86)%\Windows Kits\10\Debuggers\x64\cdb.exe" -2 -c "g"
74 IF /I "%1"=="-release" (
77 IF /I "%1"=="-noTCP" (
80 IF /I "%1"=="-noSecurity" (
92 REM We need to append the "PATH" so the octbstack.dll can be found by executables
93 IF "%BUILD_MSYS%" == "" (
94 set BUILD_DIR=out\windows\%TARGET_ARCH%\%BINDIR%
95 set PATH=!PATH!;!IOTIVITY_DIR!!BUILD_DIR!;
97 set BUILD_DIR=out\msys_nt\x86_64\%BINDIR%
98 set PATH=!PATH!;!BUILD_DIR!;C:\msys64\mingw64\bin
101 set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% RELEASE=%RELEASE% WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=%WITH_TCP% BUILD_SAMPLE=ON LOGGING=%LOGGING% TEST=%TEST% RD_MODE=CLIENT ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP% MULTIPLE_OWNER=%MULTIPLE_OWNER% -j %THREAD_COUNT%
103 REM Use MSVC_VERSION=12.0 for VS2013, or MSVC_VERSION=14.0 for VS2015.
104 REM If MSVC_VERSION has not been defined here, SCons chooses automatically a VS version.
105 IF NOT "%MSVC_VERSION%" == "" (
106 set BUILD_OPTIONS=%BUILD_OPTIONS% MSVC_VERSION=%MSVC_VERSION%
109 REM *** BUILD OPTIONS ***
111 if "!RUN_ARG!"=="server" (
112 cd %BUILD_DIR%\resource\examples
113 %DEBUG% simpleserver.exe
114 ) else if "!RUN_ARG!"=="client" (
115 cd %BUILD_DIR%\resource\examples
116 %DEBUG% simpleclient.exe
117 ) else if "!RUN_ARG!"=="serverhq" (
118 cd %BUILD_DIR%\resource\examples
119 %DEBUG% simpleserverHQ.exe
120 ) else if "!RUN_ARG!"=="clienthq" (
121 cd %BUILD_DIR%\resource\examples
122 %DEBUG% simpleclientHQ.exe
123 ) else if "!RUN_ARG!"=="mediaclient" (
124 cd %BUILD_DIR%\resource\examples
125 %DEBUG% mediaclient.exe
126 ) else if "!RUN_ARG!"=="mediaserver" (
127 cd %BUILD_DIR%\resource\examples
128 %DEBUG% mediaserver.exe
129 ) else if "!RUN_ARG!"=="winuiclient" (
130 cd %BUILD_DIR%\resource\examples
131 %DEBUG% winuiclient.exe
132 ) else if "!RUN_ARG!"=="occlient" (
133 cd %BUILD_DIR%\resource\csdk\stack\samples\linux\SimpleClientServer
134 %DEBUG% occlientbasicops.exe -u 0 -t 3 -c 1
135 ) else if "!RUN_ARG!"=="ocserver" (
136 cd %BUILD_DIR%\resource\csdk\stack\samples\linux\SimpleClientServer
137 %DEBUG% ocserverbasicops.exe
138 ) else if "!RUN_ARG!"=="provclient" (
139 cd %BUILD_DIR%\resource\csdk\security\provisioning\sample
140 %DEBUG% provisioningclient.exe
141 ) else if "!RUN_ARG!"=="justworks" (
142 cd %BUILD_DIR%\resource\csdk\security\provisioning\sample
143 %DEBUG% sampleserver_justworks.exe
144 ) else if "!RUN_ARG!"=="test" (
145 %DEBUG% %BUILD_DIR%\resource\csdk\connectivity\test\catests.exe
146 %DEBUG% %BUILD_DIR%\resource\csdk\stack\test\stacktests.exe
147 %DEBUG% %BUILD_DIR%\resource\csdk\stack\test\cbortests.exe
148 %DEBUG% %BUILD_DIR%\resource\csdk\security\unittest\unittest.exe
149 %DEBUG% %BUILD_DIR%\resource\csdk\security\provisioning\unittest\unittest.exe
150 %DEBUG% %BUILD_DIR%\resource\c_common\ocrandom\test\randomtests.exe
151 %DEBUG% %BUILD_DIR%\resource\c_common\oic_malloc\test\malloctests.exe
152 %DEBUG% %BUILD_DIR%\resource\c_common\oic_string\test\stringtests.exe
153 %DEBUG% %BUILD_DIR%\resource\c_common\oic_time\test\timetests.exe
154 %DEBUG% %BUILD_DIR%\resource\unittests\unittests.exe
155 ) else if "!RUN_ARG!"=="build" (
156 echo Starting IoTivity build with these options:
157 echo TARGET_OS=%TARGET_OS%
158 echo TARGET_ARCH=%TARGET_ARCH%
159 echo SECURED=%SECURED%
160 echo RELEASE=%RELEASE%
162 echo LOGGING=%LOGGING%
163 echo ROUTING=%ROUTING%
164 echo WITH_TCP=%WITH_TCP%
165 echo WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP%
166 echo MULTIPLE_OWNER=%MULTIPLE_OWNER%
167 echo MSVC_VERSION=%MSVC_VERSION%
168 echo THREAD_COUNT=%THREAD_COUNT%
169 echo.scons VERBOSE=1 %BUILD_OPTIONS%
170 scons VERBOSE=1 %BUILD_OPTIONS%
171 ) else if "!RUN_ARG!"=="clean" (
172 scons VERBOSE=1 %BUILD_OPTIONS% -c clean
175 del extlibs\gtest\googletest*.lib
176 del extlibs\gtest\googletest-release-1.7.0\src\gtest*.obj
178 erase resource\c_common\iotivity_config.h
179 erase extlibs\libcoap\coap.lib
180 erase extlibs\libcoap\libcoap\include\coap\coap_config.h
181 erase extlibs\mbedtls\mbed*.lib
182 ) else if "!RUN_ARG!"=="cleangtest" (
183 rd /s /q extlibs\gtest\googletest-release-1.7.0
184 del extlibs\gtest\release-1.7.0.zip
186 echo.%0 - Script requires a valid argument!
197 echo %0 - Helper to build/test iotivity. Requires an argument.
198 echo Installation: Drop this into your iotivity root directory to use it.
200 echo. Default build settings are: debug binaries run unittests and no logging
202 echo. Default build parameters can be overridden using the following arguments
204 REM At a quick look, the "Build either amd64 or x86 architecture binaries" message
205 REM below seems out of alignment with the other messages underneath it. But, "^|"
206 REM gets echoed as a single character, so the messages are actually aligned correctly
207 REM in the output of "run.bat".
208 echo -arch [x86 ^| amd64] - Build either amd64 or x86 architecture binaries
210 echo -noTest - Don't run the unittests after building the binaries
212 echo -logging - Enable logging while building the binaries
214 echo -debugger - Debug the requested application
216 echo -release - Build release binaries
218 echo -threads [NUMBER_OF_THREADS] - Build in parallel using [NUMBER_OF_THREADS] threads. Default: %NUMBER_OF_PROCESSORS%.
220 echo -noTCP - Build with the TCP adapter disabled
222 echo -noSecurity - Remove security support (results in code that cannot be certified by OCF)
224 echo. Usage examples:
226 echo Launch SimpleClient with debugger:
227 echo %0 client -debugger
229 echo Launch SimpleServer:
232 echo Launch WinUIClient built in msys:
233 echo %0 msys winuiclient
235 echo Build amd64 debug binaries and run unit tests:
238 echo Build amd64 release binaries w/o running tests:
239 echo %0 build -arch amd64 -noTest -release
241 echo Build x86 debug binaries and run unit tests:
242 echo %0 build -arch x86
244 echo Build amd64 release binaries with logging enabled:
245 echo %0 build -arch amd64 -release -logging
247 echo Build using only one thread:
248 echo %0 build -threads 1
250 echo Build with TCP adapter disabled and run unit tests:
253 echo Build without security support and run unit tests:
254 echo %0 build -noSecurity