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