forked from dotnet/roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cibuild.sh
executable file
·303 lines (258 loc) · 7.79 KB
/
cibuild.sh
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#!/usr/bin/env bash
usage()
{
echo "Runs our integration suite on Linux"
echo "usage: cibuild.sh [options]"
echo ""
echo "Options"
echo " --mono-path <path> Path to the mono installation to use for the run"
echo " --os <os> OS to run (Linux / Darwin)"
}
XUNIT_VERSION=2.1.0
BUILD_CONFIGURATION=Debug
OS_NAME=$(uname -s)
USE_CACHE=true
MONO_ARGS='--debug=mdb-optimizations --attach=disable'
MSBUILD_ADDITIONALARGS='/v:m /consoleloggerparameters:Verbosity=minimal /filelogger /fileloggerparameters:Verbosity=normal'
export MONO_THREADS_PER_CPU=50
# There are some stability issues that are causing Jenkins builds to fail at an
# unacceptable rate. To temporarily work around that we are going to retry the
# unstable tasks a number of times.
RETRY_COUNT=5
while [[ $# > 0 ]]
do
opt="$1"
case $opt in
-h|--help)
usage
exit 1
;;
--mono-path)
CUSTOM_MONO_PATH=$2
shift 2
;;
--os)
OS_NAME=$2
shift 2
;;
--debug)
BUILD_CONFIGURATION=Debug
shift 1
;;
--release)
BUILD_CONFIGURATION=Release
shift 1
;;
--nocache)
USE_CACHE=false
shift 1
;;
*)
usage
exit 1
;;
esac
done
set_build_info()
{
if [ "$OS_NAME" == "Linux" ]; then
MSBUILD_ADDITIONALARGS="$MSBUILD_ADDITIONALARGS /p:BaseNuGetRuntimeIdentifier=ubuntu.14.04"
MONO_TOOLSET_NAME=mono.linux.4
ROSLYN_TOOLSET_NAME=roslyn.linux.1
elif [ "$OS_NAME" == "Darwin" ]; then
MSBUILD_ADDITIONALARGS="$MSBUILD_ADDITIONALARGS /p:BaseNuGetRuntimeIdentifier=osx.10.10"
MONO_TOOLSET_NAME=mono.mac.5
ROSLYN_TOOLSET_NAME=roslyn.mac.1
else
echo Unrecognized OS $OS_NAME
exit 1
fi
}
restore_nuget()
{
local package_name="nuget.35.zip"
local target="/tmp/$package_name"
echo "Installing NuGet Packages $target"
if [ -f $target ]; then
if [ "$USE_CACHE" = "true" ]; then
echo "Nuget already installed"
return
fi
fi
pushd /tmp/
rm $package_name 2>/dev/null
curl -O https://dotnetci.blob.core.windows.net/roslyn/$package_name
unzip -uoq $package_name -d ~/
if [ $? -ne 0 ]; then
echo "Unable to download NuGet packages"
exit 1
fi
popd
}
run_msbuild()
{
local is_good=false
for i in `seq 1 $RETRY_COUNT`
do
mono $MONO_ARGS ~/.nuget/packages/Microsoft.Build.Mono.Debug/14.1.0-prerelease/lib/MSBuild.exe $MSBUILD_ADDITIONALARGS /p:SignAssembly=false /p:DebugSymbols=false /p:Configuration=$BUILD_CONFIGURATION "$@"
if [ $? -eq 0 ]; then
is_good=true
break
fi
echo Build retry $i
done
if [ "$is_good" != "true" ]; then
echo Build failed
exit 1
fi
}
# NuGet crashes on occasion during restore. This isn't a fatal action so
# we re-run it a number of times.
run_nuget()
{
local is_good=false
for i in `seq 1 $RETRY_COUNT`
do
mono $MONO_ARGS .nuget/NuGet.exe "$@"
if [ $? -eq 0 ]; then
is_good=true
break
fi
done
if [ "$is_good" != "true" ]; then
echo NuGet failed
exit 1
fi
}
# Install the Roslyn toolset which is used to build the bootstrap compilers
install_roslyn_toolset()
{
local package_name=$ROSLYN_TOOLSET_NAME
local package_path="/tmp/$ROSLYN_TOOLSET_NAME.tar.bz2"
local download_package=false
if [ ! -f $package_path ]; then
download_package=true
fi
if [ "$USE_CACHE" = "true" ]; then
download_package=true
fi
if [ "$download_package" = "true" ]; then
rm $package_path 2>/dev/null
pushd /tmp
curl -O https://dotnetci.blob.core.windows.net/roslyn/$package_name.tar.bz2
popd
fi
mkdir -p "Binaries"
pushd Binaries > /dev/null
tar -jxf $package_path
popd > /dev/null
}
build_bootstrap()
{
install_roslyn_toolset
local bootstrap_arg="/p:CscToolPath=$(pwd)/Binaries/$ROSLYN_TOOLSET_NAME /p:CscToolExe=csc \
/p:VbcToolPath=$(pwd)/Binaries/$ROSLYN_TOOLSET_NAME /p:VbcToolExe=vbc"
# Build the bootstrap compilers
echo Compiling the toolset compilers
echo -e " Compiling the C# compiler"
run_msbuild /nologo $bootstrap_arg src/Compilers/CSharp/CscCore/CscCore.csproj /fileloggerparameters:LogFile=Binaries/Bootstrap_CscCore.log
echo -e " Compiling the VB compiler"
run_msbuild /nologo $bootstrap_arg src/Compilers/VisualBasic/VbcCore/VbcCore.csproj /fileloggerparameters:LogFile=Binaries/Bootstrap_VbcCore.log
# Save the compilers into the bootstrap directory
local bootstrap_path="Binaries/Bootstrap"
mkdir -p $bootstrap_path
cp Binaries/$BUILD_CONFIGURATION/csccore/* $bootstrap_path
cp Binaries/$BUILD_CONFIGURATION/vbccore/* $bootstrap_path
# Clean out the built files so they will be re-built using the
# bootstrap compiler
echo Cleaning the enlistment
rm -rf Binaries/$BUILD_CONFIGURATION
rm -rf Binaries/Obj
}
build_roslyn()
{
local bootstrap_arg="/p:CscToolPath=$(pwd)/Binaries/Bootstrap /p:CscToolExe=csc \
/p:VbcToolPath=$(pwd)/Binaries/Bootstrap /p:VbcToolExe=vbc"
echo Building CrossPlatform.sln
run_msbuild /nologo $bootstrap_arg CrossPlatform.sln /fileloggerparameters:LogFile=Binaries/Build.log
}
# Install the specified Mono toolset from our Azure blob storage.
install_mono_toolset()
{
local target=/tmp/$1
echo "Installing Mono toolset $1"
if [ -d $target ]; then
if [ "$USE_CACHE" = "true" ]; then
echo "Mono already installed"
return
fi
fi
pushd /tmp
rm -r $target 2>/dev/null
rm $1.tar.bz2 2>/dev/null
curl -O https://dotnetci.blob.core.windows.net/roslyn/$1.tar.bz2
tar -jxf $1.tar.bz2
if [ $? -ne 0 ]; then
echo "Unable to download toolset"
exit 1
fi
popd
}
# This function will update the PATH variable to put the desired
# version of Mono ahead of the system one.
set_mono_path()
{
if [ "$CUSTOM_MONO_PATH" != "" ]; then
if [ ! -d "$CUSTOM_MONO_PATH" ]; then
echo "Not a valid directory $CUSTOM_MONO_PATH"
exit 1
fi
echo "Using mono path $CUSTOM_MONO_PATH"
PATH=$CUSTOM_MONO_PATH:$PATH
return
fi
install_mono_toolset $MONO_TOOLSET_NAME
PATH=/tmp/$MONO_TOOLSET_NAME/bin:$PATH
}
check_mono()
{
local mono_path=$(which mono)
echo "Mono path $mono_path"
}
test_roslyn()
{
local xunit_runner=~/.nuget/packages/xunit.runner.console/$XUNIT_VERSION/tools/xunit.console.x86.exe
local test_binaries=(
Roslyn.Compilers.CSharp.CommandLine.UnitTests
Roslyn.Compilers.CSharp.Syntax.UnitTests
Roslyn.Compilers.CSharp.Semantic.UnitTests
Roslyn.Compilers.CSharp.Symbol.UnitTests
Roslyn.Compilers.VisualBasic.Syntax.UnitTests)
local any_failed=false
# Need to copy over the execution dependencies. This isn't being done correctly
# by msbuild at the moment.
cp ~/.nuget/packages/xunit.extensibility.execution/$XUNIT_VERSION/lib/net45/xunit.execution.desktop.* Binaries/$BUILD_CONFIGURATION
for i in "${test_binaries[@]}"
do
mkdir -p Binaries/$BUILD_CONFIGURATION/xUnitResults/
mono $MONO_ARGS $xunit_runner Binaries/$BUILD_CONFIGURATION/$i.dll -xml Binaries/$BUILD_CONFIGURATION/xUnitResults/$i.dll.xml -noshadow
if [ $? -ne 0 ]; then
any_failed=true
fi
done
if [ "$any_failed" = "true" ]; then
echo Unit test failed
exit 1
fi
}
if [ "$CLEAN_RUN" == "true" ]; then
echo Clean out the enlistment
git clean -dxf .
fi
set_build_info
restore_nuget
set_mono_path
check_mono
build_bootstrap
build_roslyn
test_roslyn