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