NSConsumerTest2.cpp string typo
[platform/upstream/iotivity.git] / run.bat
1 @echo off
2 REM Helper script to build and run IoTivity on Windows
3 SETLOCAL ENABLEDELAYEDEXPANSION
4
5 if [%1]==[] goto USAGE
6
7 set IOTIVITY_DIR=%~dp0
8 set HOME=%USERPROFILE%
9
10 IF /I "%1" == "msys" (
11   set BUILD_MSYS="YES"
12   SHIFT
13 ) ELSE (
14   set BUILD_MSYS=
15 )
16
17 REM *** Default BUILD OPTIONS ***
18 set TARGET_OS=windows
19
20 if "%JENKINS_HOME%" == "" (
21   set AUTOMATIC_UPDATE=0
22 ) else (
23   set AUTOMATIC_UPDATE=1
24 )
25
26 if "%TARGET_ARCH%" == "" (
27   set TARGET_ARCH=amd64
28 )
29
30 if "%TEST%" == "" (
31   set TEST=1
32 )
33
34 if "%LOGGING%" == "" (
35   set LOGGING=0
36 )
37
38 if "%RELEASE%" == "" (
39   set RELEASE=0
40 )
41
42 if "%WITH_TCP%" == "" (
43   set WITH_TCP=1
44 )
45
46 if "%SECURED%" == "" (
47   set SECURED=1
48 )
49
50 if "%MULTIPLE_OWNER%" == "" (
51   set MULTIPLE_OWNER=1
52 )
53
54 set THREAD_COUNT=%NUMBER_OF_PROCESSORS%
55
56 set ROUTING=EP
57 set WITH_UPSTREAM_LIBCOAP=1
58 set BINDIR=debug
59 set RD_MODE=CLIENT,SERVER
60
61 set RUN_ARG=%1
62 SHIFT
63
64 set DEBUG=
65
66 :processArgs
67 IF NOT "%1"=="" (
68   IF /I "%1"=="-arch" (
69     SET TARGET_ARCH=%2
70     SHIFT
71   )
72   IF /I "%1"=="-threads" (
73     SET THREAD_COUNT=%2
74     SHIFT
75   )
76   IF /I "%1"=="-noTest" (
77     SET TEST=0
78   )
79   IF /I "%1"=="-logging" (
80     SET LOGGING=1
81   )
82   IF /I "%1"=="-debugger" (
83     set DEBUG="%ProgramFiles(x86)%\Windows Kits\10\Debuggers\x64\cdb.exe" -2 -c "g"
84   )
85   IF /I "%1"=="-release" (
86     SET RELEASE=1
87   )
88   IF /I "%1"=="-noTCP" (
89     SET WITH_TCP=0
90   )
91   IF /I "%1"=="-noSecurity" (
92     set SECURED=0
93   )
94   IF /I "%1"=="-noMOT" (
95     set MULTIPLE_OWNER=0
96   )
97   IF /I "%1"=="-automaticUpdate" (
98     set AUTOMATIC_UPDATE=1
99   )
100
101   SHIFT
102   GOTO :processArgs
103 )
104
105 IF %RELEASE% == 1 (
106   set BINDIR=release
107 )
108
109 REM We need to append the "PATH" so the octbstack.dll can be found by executables
110 IF "%BUILD_MSYS%" == "" (
111   set BUILD_DIR=out\windows\%TARGET_ARCH%\%BINDIR%
112   set PATH=!PATH!;!IOTIVITY_DIR!!BUILD_DIR!;
113 ) ELSE (
114   set BUILD_DIR=out\msys_nt\x86_64\%BINDIR%
115   set PATH=!PATH!;!BUILD_DIR!;C:\msys64\mingw64\bin
116 )
117
118 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=%RD_MODE% ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP% MULTIPLE_OWNER=%MULTIPLE_OWNER% -j %THREAD_COUNT% AUTOMATIC_UPDATE=%AUTOMATIC_UPDATE%
119
120 REM Use MSVC_VERSION=12.0 for VS2013, or MSVC_VERSION=14.0 for VS2015.
121 REM If MSVC_VERSION has not been defined here, SCons chooses automatically a VS version.
122 IF NOT "%MSVC_VERSION%" == "" (
123   set BUILD_OPTIONS=%BUILD_OPTIONS% MSVC_VERSION=%MSVC_VERSION%
124 )
125
126 REM *** BUILD OPTIONS ***
127
128 if "!RUN_ARG!"=="server" (
129   cd %BUILD_DIR%\resource\examples
130   %DEBUG% simpleserver.exe
131 ) else if "!RUN_ARG!"=="client" (
132   cd %BUILD_DIR%\resource\examples
133   %DEBUG% simpleclient.exe
134 ) else if "!RUN_ARG!"=="serverhq" (
135   cd %BUILD_DIR%\resource\examples
136   %DEBUG% simpleserverHQ.exe
137 ) else if "!RUN_ARG!"=="clienthq" (
138   cd %BUILD_DIR%\resource\examples
139   %DEBUG% simpleclientHQ.exe
140 ) else if "!RUN_ARG!"=="mediaclient" (
141   cd %BUILD_DIR%\resource\examples
142   %DEBUG% mediaclient.exe
143 ) else if "!RUN_ARG!"=="mediaserver" (
144   cd %BUILD_DIR%\resource\examples
145   %DEBUG% mediaserver.exe
146 ) else if "!RUN_ARG!"=="winuiclient" (
147   cd %BUILD_DIR%\resource\examples
148   %DEBUG% winuiclient.exe
149 ) else if "!RUN_ARG!"=="occlient" (
150   cd %BUILD_DIR%\resource\csdk\stack\samples\linux\SimpleClientServer
151   %DEBUG% occlientbasicops.exe -u 0 -t 3 -c 1
152 ) else if "!RUN_ARG!"=="ocserver" (
153   cd %BUILD_DIR%\resource\csdk\stack\samples\linux\SimpleClientServer
154   %DEBUG% ocserverbasicops.exe
155 ) else if "!RUN_ARG!"=="provclient" (
156   cd %BUILD_DIR%\resource\csdk\security\provisioning\sample
157   %DEBUG% provisioningclient.exe
158 ) else if "!RUN_ARG!"=="justworks" (
159   cd %BUILD_DIR%\resource\csdk\security\provisioning\sample
160   %DEBUG% sampleserver_justworks.exe
161 ) else if "!RUN_ARG!"=="test" (
162   %DEBUG% %BUILD_DIR%\resource\csdk\connectivity\test\catests.exe
163   %DEBUG% %BUILD_DIR%\resource\csdk\stack\test\stacktests.exe
164   %DEBUG% %BUILD_DIR%\resource\csdk\stack\test\cbortests.exe
165   %DEBUG% %BUILD_DIR%\resource\csdk\security\unittest\unittest.exe
166   %DEBUG% %BUILD_DIR%\resource\csdk\security\provisioning\unittest\unittest.exe
167   %DEBUG% %BUILD_DIR%\resource\c_common\ocrandom\test\randomtests.exe
168   %DEBUG% %BUILD_DIR%\resource\c_common\oic_malloc\test\malloctests.exe
169   %DEBUG% %BUILD_DIR%\resource\c_common\oic_string\test\stringtests.exe
170   %DEBUG% %BUILD_DIR%\resource\c_common\oic_time\test\timetests.exe
171   %DEBUG% %BUILD_DIR%\resource\unittests\unittests.exe
172 ) else if "!RUN_ARG!"=="build" (
173   echo Starting IoTivity build with these options:
174   echo   TARGET_OS=%TARGET_OS%
175   echo   TARGET_ARCH=%TARGET_ARCH%
176   echo   SECURED=%SECURED%
177   echo   RELEASE=%RELEASE%
178   echo   TEST=%TEST%
179   echo   LOGGING=%LOGGING%
180   echo   ROUTING=%ROUTING%
181   echo   WITH_TCP=%WITH_TCP%
182   echo   WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP%
183   echo   MULTIPLE_OWNER=%MULTIPLE_OWNER%
184   echo   MSVC_VERSION=%MSVC_VERSION%
185   echo   THREAD_COUNT=%THREAD_COUNT%
186   echo   AUTOMATIC_UPDATE=%AUTOMATIC_UPDATE%
187   echo.scons VERBOSE=1 %BUILD_OPTIONS%
188   call scons.bat VERBOSE=1 %BUILD_OPTIONS%
189   if ERRORLEVEL 1 (
190     echo SCons failed - exiting run.bat with code 3
191     exit /B 3
192     )
193 ) else if "!RUN_ARG!"=="clean" (
194   del /S *.ilk
195   call scons.bat VERBOSE=1 %BUILD_OPTIONS% -c
196   if ERRORLEVEL 1 (
197     echo SCons failed - exiting run.bat with code 2
198     exit /B 2
199     )
200 ) else if "!RUN_ARG!"=="cleangtest" (
201   rd /s /q extlibs\gtest\googletest-release-1.7.0
202   del extlibs\gtest\release-1.7.0.zip
203 ) else (
204     echo.%0 - Script requires a valid argument!
205     echo Exiting run.bat with code 1
206     exit /B 1
207 )
208
209 cd %IOTIVITY_DIR%
210
211 echo Done!
212
213 goto EOF
214
215 :USAGE
216 echo %0 - Helper to build/test iotivity.  Requires an argument.
217 echo Installation: Drop this into your iotivity root directory to use it.
218 echo.
219 echo. Default build settings are: debug binaries run unittests and no logging
220 echo.
221 echo. Default build parameters can be overridden using the following arguments
222 echo.
223 REM At a quick look, the "Build either amd64 or x86 architecture binaries" message
224 REM below seems out of alignment with the other messages underneath it. But, "^|"
225 REM gets echoed as a single character, so the messages are actually aligned correctly
226 REM in the output of "run.bat".
227 echo   -arch [x86 ^| amd64]          - Build either amd64 or x86 architecture binaries
228 echo.
229 echo   -noTest                      - Don't run the unittests after building the binaries
230 echo.
231 echo   -logging                     - Enable logging while building the binaries
232 echo.
233 echo   -debugger                    - Debug the requested application
234 echo.
235 echo   -release                     - Build release binaries
236 echo.
237 echo   -threads [NUMBER_OF_THREADS] - Build in parallel using [NUMBER_OF_THREADS] threads. Default: %NUMBER_OF_PROCESSORS%.
238 echo.
239 echo   -noTCP                       - Build with the TCP adapter disabled
240 echo.
241 echo   -noSecurity                  - Remove security support (results in code that cannot be certified by OCF)
242 echo.
243 echo   -noMOT                       - Remove Multiple Ownership Transfer support.
244 echo.
245 echo   -automaticUpdate             - Automatically update libcoap to required version.
246 echo.
247 echo.
248 echo. Usage examples:
249 echo.
250 echo   Launch SimpleClient with debugger:
251 echo      %0 client -debugger
252 echo.
253 echo   Launch SimpleServer:
254 echo      %0 server
255 echo.
256 echo   Launch WinUIClient built in msys:
257 echo      %0 msys winuiclient
258 echo.
259 echo   Build amd64 debug binaries and run unit tests:
260 echo      %0 build
261 echo.
262 echo   Build amd64 release binaries w/o running tests:
263 echo      %0 build -arch amd64 -noTest -release
264 echo.
265 echo   Build x86 debug binaries and run unit tests:
266 echo      %0 build -arch x86
267 echo.
268 echo   Build amd64 release binaries with logging enabled:
269 echo      %0 build -arch amd64 -release -logging
270 echo.
271 echo   Build using only one thread:
272 echo      %0 build -threads 1
273 echo.
274 echo   Build with TCP adapter disabled and run unit tests:
275 echo      %0 build -noTCP
276 echo.
277 echo   Build without security support and run unit tests:
278 echo      %0 build -noSecurity
279 echo.
280 echo   Build without Multiple Ownership Transfer support and run unit tests:
281 echo      %0 build -noMOT
282 echo.
283 echo   Run all tests:
284 echo      %0 test
285 echo.
286 echo   Clean:
287 echo      %0 clean
288
289 :EOF