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