forked from microsoft/Mobius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.cmd
265 lines (206 loc) · 7.6 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
@setlocal
@echo OFF
rem
rem Copyright (c) Microsoft. All rights reserved.
rem Licensed under the MIT license. See LICENSE file in the project root for full license information.
rem
if "%1" == "csharp" set buildCSharp=true
SET CMDHOME=%~dp0
@REM Remove trailing backslash \
set CMDHOME=%CMDHOME:~0,-1%
@rem check prerequisites
call "%CMDHOME%\localmode\precheck.cmd"
if %precheck% == "bad" (goto :eof)
@rem Windows 7/8/10 may not allow powershell scripts by default
powershell -Command Set-ExecutionPolicy -Scope CurrentUser Unrestricted
@rem download build tools
pushd "%CMDHOME%"
powershell -f localmode\downloadtools.ps1 build
call tools\updatebuildtoolenv.cmd
popd
set SPARKCLR_HOME=%CMDHOME%\runtime
@echo SPARKCLR_HOME=%SPARKCLR_HOME%
if defined buildCSharp goto :buildCSharp
if EXIST "%SPARKCLR_HOME%" (
@echo Delete existing %SPARKCLR_HOME% ...
rd /s /q "%SPARKCLR_HOME%"
)
if NOT EXIST "%SPARKCLR_HOME%" mkdir "%SPARKCLR_HOME%"
if NOT EXIST "%SPARKCLR_HOME%\bin" mkdir "%SPARKCLR_HOME%\bin"
if NOT EXIST "%SPARKCLR_HOME%\data" mkdir "%SPARKCLR_HOME%\data"
if NOT EXIST "%SPARKCLR_HOME%\lib" mkdir "%SPARKCLR_HOME%\lib"
if NOT EXIST "%SPARKCLR_HOME%\samples" mkdir "%SPARKCLR_HOME%\samples"
if NOT EXIST "%SPARKCLR_HOME%\repl" mkdir "%SPARKCLR_HOME%\repl"
@echo Assemble Mobius Scala components
pushd "%CMDHOME%\..\scala"
@rem clean the target directory first
call mvn.cmd %MVN_QUIET% clean
@rem
@rem Note: Shade-plugin helps creates an uber-package to simplify running samples during CI;
@rem however, it breaks debug mode in IntellJ. So enable shade-plugin
@rem only in build.cmd to create the uber-package.
@rem
copy /y pom.xml %temp%\pom.xml.original
powershell -f ..\build\localmode\patchpom.ps1 pom.xml
copy /y pom.xml %temp%\pom.xml.patched
IF "%APPVEYOR_REPO_TAG%" == "true" (goto :sign)
@rem build the package
call mvn.cmd %MVN_QUIET% package -Puber-jar
goto :mvndone
:sign
@rem
@rem prepare signing only when APPVEYOR_REPO_TAG is available
@rem
gpg2 --batch --yes --import ..\build\data\private_token.asc
gpg2 --batch --yes --import ..\build\data\public_token.asc
pushd %APPDATA%\gnupg
del /q trustdb.gpg
popd
gpg2 --batch --yes --import-ownertrust < ..\build\data\ownertrustblob.txt
gpg2 --list-key
@rem build the package, sign, deploy to maven central
call mvn %MVN_QUIET% clean deploy -Puber-jar -DdoSign=true -DdoRelease=true
:mvndone
set MVN_ERRORLEVEL=%ERRORLEVEL%
@rem
@rem After uber package is created, restore Pom.xml
@rem
copy /y %temp%\pom.xml.original pom.xml
if %MVN_ERRORLEVEL% NEQ 0 (
@echo Build Mobius Scala components failed, stop building.
popd
goto :eof
)
@echo Mobius Scala binaries
@rem copy non-uber jar to runtime\lib folder
powershell -f ..\build\copyjar.ps1
popd
@REM Any .jar files under the lib directory will be copied to the staged runtime lib tree.
if EXIST "%CMDHOME%\lib" (
@echo Copy extra jar library binaries
FOR /F "tokens=*" %%G IN ('DIR /B /A-D /S %CMDHOME%\lib\*.jar') DO (
@echo %%G
copy /y "%%G" "%SPARKCLR_HOME%\lib\"
)
)
:buildCpp
Set CppSkipped=0
@echo Assemble Mobius C++ components (RIOSOCK)
pushd %CMDHOME%\..\cpp
call Clean.cmd
call Build.cmd
if %ERRORLEVEL% EQU 2 (
set CppSkipped=1
popd
goto :buildCSharp
)
if %ERRORLEVEL% NEQ 0 (
@echo Build Mobius C++ RIOSOCK failed, stop building.
popd
goto :eof
)
@echo Mobius C++ RIOSOCK binaries
copy /y x64\Release\*.dll "%SPARKCLR_HOME%\bin\"
copy /y x64\Release\*.pdb "%SPARKCLR_HOME%\bin\"
popd
:buildCSharp
@echo Assemble Mobius C# components
pushd "%CMDHOME%\..\csharp"
@rem clean any possible previous build first
call Clean.cmd
call Build.cmd
if %ERRORLEVEL% NEQ 0 (
@echo Build Mobius C# components failed, stop building.
popd
goto :eof
)
@echo Mobius C# binaries
copy /y Worker\Microsoft.Spark.CSharp\bin\Release\* "%SPARKCLR_HOME%\bin\"
@echo Mobius C# Samples binaries
@rem need to include CSharpWorker.exe.config in samples folder
copy /y Worker\Microsoft.Spark.CSharp\bin\Release\* "%SPARKCLR_HOME%\samples\"
copy /y Samples\Microsoft.Spark.CSharp\bin\Release\* "%SPARKCLR_HOME%\samples\"
@echo Mobius Samples data
copy /y Samples\Microsoft.Spark.CSharp\data\* "%SPARKCLR_HOME%\data\"
@echo SparkCLR REPL
copy /y Worker\Microsoft.Spark.CSharp\bin\Release\* "%SPARKCLR_HOME%\repl\"
copy /y Repl\bin\Release\* "%SPARKCLR_HOME%\repl\"
popd
@echo Download external dependencies
pushd "%CMDHOME%"
set DEPENDENCIES_DIR=dependencies
if NOT EXIST "%DEPENDENCIES_DIR%" mkdir %DEPENDENCIES_DIR%
set DEPENDENCIES_HOME=%CMDHOME%\%DEPENDENCIES_DIR%
powershell -f localmode\downloadtools.ps1 dependencies
@echo Assemble dependencies
xcopy /e /y "%DEPENDENCIES_HOME%" "%SPARKCLR_HOME%\dependencies\"
@echo Assemble Mobius examples
pushd "%CMDHOME%\..\examples"
call Clean.cmd
call Build.cmd
if %ERRORLEVEL% NEQ 0 (
@echo Build Mobius .NET examples failed, stop building.
popd
goto :eof
)
set EXAMPLES_HOME=%CMDHOME%\examples
@echo set EXAMPLES_HOME=%EXAMPLES_HOME%
if EXIST "%EXAMPLES_HOME%" (
@echo Delete existing %EXAMPLES_HOME% ...
rd /s /q "%EXAMPLES_HOME%"
)
if NOT EXIST "%EXAMPLES_HOME%" mkdir "%EXAMPLES_HOME%"
set CURRDIR=%cd%
for /f "delims=" %%D in ('dir /b /s bin') do call :copyexamples %%D
goto :copyscripts
:copyexamples
set EXAMPLES_SRC=%1
set EXAMPLES_TARGET=%1
call set EXAMPLES_TARGET=%%EXAMPLES_TARGET:%CURRDIR%=%EXAMPLES_HOME%%%
set EXAMPLES_TARGET=%EXAMPLES_TARGET:~0,-4%
@echo mkdir %EXAMPLES_TARGET%
if NOT EXIST "%EXAMPLES_TARGET%" mkdir "%EXAMPLES_TARGET%"
REM 1. Copy dependencies from %SPARKCLR_HOME%\bin to use latest Mobius binaries
xcopy /y "%SPARKCLR_HOME%\bin\*" "%EXAMPLES_TARGET%"
REM 2. copy Examples APPs
xcopy /d /y "%EXAMPLES_SRC%\Release" "%EXAMPLES_TARGET%"
goto :eof
:copyscripts
popd
@echo Assemble Mobius script components
xcopy /e /y "%CMDHOME%\..\scripts" "%SPARKCLR_HOME%\scripts\"
@echo Make distribution
pushd "%CMDHOME%"
if not exist ".\target" (mkdir .\target)
if not defined ProjectVersion (
powershell -f .\localmode\zipdir.ps1 -dir "%SPARKCLR_HOME%" -target ".\target\runtime.zip"
goto :distdone
)
set SPARKCLR_NAME=spark-clr_2.11-%ProjectVersion%
@echo "%SPARKCLR_HOME%
@rem copy samples to top-level folder before zipping
@echo move /Y "%SPARKCLR_HOME%\samples "%CMDHOME%"
move /Y %SPARKCLR_HOME%\samples %CMDHOME%
@echo move /Y "%SPARKCLR_HOME%\data" "%CMDHOME%\samples"
move /Y %SPARKCLR_HOME%\data %CMDHOME%\samples
@rem copy release info
@echo copy /Y "%CMDHOME%\..\notes\mobius-release-info.md"
copy /Y "%CMDHOME%\..\notes\mobius-release-info.md"
@rem Create the zip file
@echo 7z a .\target\%SPARKCLR_NAME%.zip runtime examples samples mobius-release-info.md
7z a .\target\%SPARKCLR_NAME%.zip runtime examples samples mobius-release-info.md
:distdone
popd
if %CppSkipped% EQU 1 (
@echo.
@echo ===============================================================================================================
@echo. !!! Note !!!
@echo Skipped building Mobius C++ component ^(RIOSock.dll^) due to missing VC++ Build Toolset.
@echo Mobius uses this component to leverage socket optimization available in Windows
@echo This is an optional component and Mobius will be fully functional even without this component
@echo If you want to build this component, enable VC++ project in Visual Studio
@echo or download "Visual C++ Build Tools" from "http://landinghub.visualstudio.com/visual-cpp-build-tools"
@echo.
@echo ===============================================================================================================
@echo.
)