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