forked from Azure/iot-edge-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cmd
155 lines (124 loc) · 5.22 KB
/
build.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
@REM Copyright (c) Microsoft. All rights reserved.
@REM Licensed under the MIT license. See LICENSE file in the project root for full license information.
@setlocal EnableExtensions EnableDelayedExpansion
@echo off
set current-path=%~dp0
rem // remove trailing slash
set current-path=%current-path:~0,-1%
set build-root=%current-path%\..
rem // resolve to fully qualified path
for %%i in ("%build-root%") do set build-root=%%~fi
rem ----------------------------------------------------------------------------
rem -- parse script arguments
rem ----------------------------------------------------------------------------
rem // default build options
set build-config=Debug
set build-platform=Win32
set CMAKE_run_e2e_tests=OFF
set CMAKE_enable_dotnet_binding=OFF
set enable-java-binding=OFF
set enable_nodejs_binding=OFF
set CMAKE_enable_ble_module=ON
set dependency_install_prefix=""
:args-loop
if "%1" equ "" goto args-done
if "%1" equ "--config" goto arg-build-config
if "%1" equ "--platform" goto arg-build-platform
if "%1" equ "--run-e2e-tests" goto arg-run-e2e-tests
if "%1" equ "--enable-dotnet-binding" goto arg-enable-dotnet-binding
if "%1" equ "--enable-java-binding" goto arg-enable-java-binding
if "%1" equ "--enable-nodejs-binding" goto arg-enable_nodejs_binding
if "%1" equ "--disable-ble-module" goto arg-disable_ble_module
if "%1" equ "--install-dependencies-in-tree" goto arg-install-dependencies-in-tree
call :usage && exit /b 1
:arg-build-config
shift
if "%1" equ "" call :usage && exit /b 1
set build-config=%1
goto args-continue
:arg-build-platform
shift
if "%1" equ "" call :usage && exit /b 1
set build-platform=%1
goto args-continue
:arg-run-e2e-tests
set CMAKE_run_e2e_tests=ON
goto args-continue
:arg-enable-dotnet-binding
set CMAKE_enable_dotnet_binding=ON
goto args-continue
:arg-enable-java-binding
set enable-java-binding=ON
call %current-path%\build_java.cmd
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
goto args-continue
:arg-disable_ble_module
set CMAKE_enable_ble_module=OFF
goto args-continue
:arg-enable_nodejs_binding
set enable_nodejs_binding=ON
goto args-continue
:arg-install-dependencies-in-tree
set dependency_install_prefix="-Ddependency_install_prefix=%build-root%\install-deps"
goto args-continue
:args-continue
shift
goto args-loop
:args-done
rem -----------------------------------------------------------------------------
rem -- build with CMAKE and run tests
rem -----------------------------------------------------------------------------
rem this is setting the cmake path in a quoted way
set cmake-root="%build-root%"\build
rem get the size of cmake path
set cmake-root-no-quotes=%build-root%\build
set size=0
:loop
if defined cmake-root-no-quotes (
rem chop down one character
set cmake-root-no-quotes=%cmake-root-no-quotes:~1%
rem add it to the size
set /A size += 1
rem go to begin
goto loop
)
rem echo %build-root%\build (%cmake-root%)is %size% characters long!
if %size% GTR 49 (
@echo build.cmd cannot continue because the path %build-root%\build is too long!
@echo try placing the repo in a shorter path. the path size can be at most 49 characters
exit /b 1
)
rmdir /s/q %cmake-root%
mkdir %cmake-root%
rem no error checking
pushd %cmake-root%
if %build-platform% == x64 (
echo ***Running CMAKE for Win64***
cmake %dependency_install_prefix% -Drun_e2e_tests:BOOL=%CMAKE_run_e2e_tests% -Denable_dotnet_binding:BOOL=%CMAKE_enable_dotnet_binding% -Denable_java_binding:BOOL=%enable-java-binding% -Denable_nodejs_binding:BOOL=%enable_nodejs_binding% -Denable_ble_module:BOOL=%CMAKE_enable_ble_module% "%build-root%" -G "Visual Studio 14 Win64"
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
) else (
echo ***Running CMAKE for Win32***
cmake %dependency_install_prefix% -Drun_e2e_tests:BOOL=%CMAKE_run_e2e_tests% -Denable_dotnet_binding:BOOL=%CMAKE_enable_dotnet_binding% -Denable_java_binding:BOOL=%enable-java-binding% -Denable_nodejs_binding:BOOL=%enable_nodejs_binding% -Denable_ble_module:BOOL=%CMAKE_enable_ble_module% "%build-root%"
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
)
msbuild /m /p:Configuration="%build-config%" /p:Platform="%build-platform%" azure_iot_gateway_sdk.sln
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
ctest -C "debug" -V
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
popd
goto :eof
rem -----------------------------------------------------------------------------
rem -- subroutines
rem -----------------------------------------------------------------------------
:usage
echo build.cmd [options]
echo options:
echo --config ^<value^> [Debug] build configuration (e.g. Debug, Release)
echo --platform ^<value^> [Win32] build platform (e.g. Win32, x64, ...)
echo --run-e2e-tests run end-to-end tests
echo --enable-dotnet-binding build dotnet binding binaries
echo --enable-java-binding enables building of Java binding; environment variable JAVA_HOME must be defined
echo --enable-nodejs-binding enables building of Node.js binding; environment variables NODE_INCLUDE and NODE_LIB must be defined
echo --disable-ble-module disable ble module from the build.
echo --install-dependencies-in-tree tells cmake to install all dependencies within the repo
goto :eof