Improved support for Visual Studio
[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 set CURRENT_ARG=%1
18 set SECOND_ARG=%2
19 set DEBUG=
20
21 if "!SECOND_ARG!"=="debug" (
22   set DEBUG="%ProgramFiles(x86)%\Windows Kits\10\Debuggers\x64\cdb.exe" -2 -c "g" 
23 )
24
25 REM We need to append the "PATH" so the octbstack.dll can be found by executables
26 IF "%BUILD_MSYS%" == "" (
27   set BUILD_DIR=out\windows\amd64\debug
28   set PATH=!PATH!;!IOTIVITY_DIR!!BUILD_DIR!;
29 ) ELSE (
30   set BUILD_DIR=out\msys_nt\x86_64\debug
31   set PATH=!PATH!;!BUILD_DIR!;C:\msys64\mingw64\bin
32 )
33
34 REM *** BUILD OPTIONS ***
35 set TARGET_OS=windows
36 set TARGET_ARCH=amd64
37 set SECURED=1
38 set TEST=1
39 set LOGGING=OFF
40 set WITH_RD=1
41 set ROUTING=EP
42
43 set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% RELEASE=0 WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=0 BUILD_SAMPLE=ON LOGGING=%LOGGING% TEST=%TEST% WITH_RD=%WITH_RD% ROUTING=%ROUTING%
44
45 REM Use MSVC_VERSION=12.0 for VS2013, or MSVC_VERSION=14.0 for VS2015.
46 REM If MSVC_VERSION has not been defined here, SCons chooses automatically a VS version.
47 IF NOT "%MSVC_VERSION%" == "" (
48   set BUILD_OPTIONS=%BUILD_OPTIONS% MSVC_VERSION=%MSVC_VERSION%
49 )
50
51 REM *** BUILD OPTIONS ***
52
53 if "!CURRENT_ARG!"=="server" (
54   cd %BUILD_DIR%\resource\examples
55   %DEBUG% simpleserver.exe
56 ) else if "!CURRENT_ARG!"=="client" (
57   cd %BUILD_DIR%\resource\examples
58   %DEBUG% simpleclient.exe
59 ) else if "!CURRENT_ARG!"=="serverhq" (
60   cd %BUILD_DIR%\resource\examples
61   %DEBUG% simpleserverHQ.exe
62 ) else if "!CURRENT_ARG!"=="clienthq" (
63   cd %BUILD_DIR%\resource\examples
64   %DEBUG% simpleclientHQ.exe
65 )else if "!CURRENT_ARG!"=="mediaclient" (
66   cd %BUILD_DIR%\resource\examples
67   %DEBUG% mediaclient.exe
68 ) else if "!CURRENT_ARG!"=="mediaserver" (
69   cd %BUILD_DIR%\resource\examples
70   %DEBUG% mediaserver.exe
71 ) else if "!CURRENT_ARG!"=="winuiclient" (
72   cd %BUILD_DIR%\resource\examples
73   %DEBUG% winuiclient.exe
74 ) else if "!CURRENT_ARG!"=="occlient" (
75   cd %BUILD_DIR%\resource\csdk\stack\samples\linux\SimpleClientServer
76   %DEBUG% occlientbasicops.exe -u 0 -t 3 -c 1
77 ) else if "!CURRENT_ARG!"=="ocserver" (
78   cd %BUILD_DIR%\resource\csdk\stack\samples\linux\SimpleClientServer
79   %DEBUG% ocserverbasicops.exe
80 ) else if "!CURRENT_ARG!"=="provclient" (
81   cd %BUILD_DIR%\resource\csdk\security\provisioning\sample
82   %DEBUG% provisioningclient.exe
83 ) else if "!CURRENT_ARG!"=="justworks" (
84   cd %BUILD_DIR%\resource\csdk\security\provisioning\sample
85   %DEBUG% sampleserver_justworks.exe
86 ) else if "!CURRENT_ARG!"=="test" (
87   %DEBUG% %BUILD_DIR%\resource\csdk\connectivity\test\catests.exe
88   %DEBUG% %BUILD_DIR%\resource\csdk\stack\test\stacktests.exe
89   %DEBUG% %BUILD_DIR%\resource\csdk\stack\test\cbortests.exe
90   %DEBUG% %BUILD_DIR%\resource\csdk\security\unittest\unittest.exe
91   %DEBUG% %BUILD_DIR%\resource\csdk\security\provisioning\unittest\unittest.exe
92 ) else if "!CURRENT_ARG!"=="build" (
93   echo Starting IoTivity build with these options:
94   echo   TARGET_OS=%TARGET_OS%
95   echo   TARGET_ARCH=%TARGET_ARCH%
96   echo   SECURED=%SECURED%
97   echo   LOGGING=%LOGGING%
98   echo   WITH_RD=%WITH_RD%
99   echo   ROUTING=%ROUTING%
100   echo.scons VERBOSE=1 %BUILD_OPTIONS%
101   scons VERBOSE=1 %BUILD_OPTIONS%
102 ) else if "!CURRENT_ARG!"=="clean" (
103   scons VERBOSE=1 %BUILD_OPTIONS% -c clean
104   rd /s /q out
105   del .sconsign.dblite
106   del extlibs\gtest\gtest*.lib
107   del extlibs\gtest\gtest-1.7.0\src\gtest*.obj
108 ) else if "!CURRENT_ARG!"=="cleangtest" (
109   rd /s /q extlibs\gtest\gtest-1.7.0
110   del extlibs\gtest\gtest-1.7.0.zip
111 ) else (
112     echo %0 - Script requires a valid argument!
113     goto :EOF
114 )
115
116 cd %IOTIVITY_DIR%
117
118 echo Done!
119
120 goto EOF
121
122 :USAGE
123 echo %0 - Helper to build/test iotivity.  Requires an argument.
124 echo Installation: Drop this into your iotivity root directory to use it.
125 echo.
126 echo. Usage examples:
127 echo   Launch SimpleClient with debugger:
128 echo      %0 client debug
129 echo.
130 echo   Launch SimpleServer:
131 echo      %0 server
132 echo.
133 echo   Launch WinUIClient built in msys:
134 echo      %0 msys winuiclient
135 echo.
136 echo   Build:
137 echo      %0 build
138 echo.
139 echo   Run all tests:
140 echo      %0 test
141 echo.
142 echo   Clean:
143 echo      %0 clean
144
145 :EOF