forked from dotnet/roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cibuild.sh
executable file
·205 lines (181 loc) · 5.01 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
#!/bin/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)"
echo " --minimal Run a minimal set of suites (used when upgrading mono)"
}
XUNIT_VERSION=2.0.0-alpha-build2576
FULL_RUN=true
OS_NAME=$(uname -s)
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
;;
--minimal)
FULL_RUN=false
shift 1
;;
*)
usage
exit 1
;;
esac
done
run_xbuild()
{
xbuild /v:m /p:SignAssembly=false /p:DebugSymbols=false "$@"
if [ $? -ne 0 ]; then
echo Compilation 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()
{
i=5
while [ $i -gt 0 ]; do
mono src/.nuget/NuGet.exe "$@"
if [ $? -eq 0 ]; then
i=0
fi
done
if [ $? -ne 0 ]; then
echo NuGet Failed
exit 1
fi
}
# Run the compilation. Can pass additional build arguments as parameters
compile_toolset()
{
echo Compiling the toolset compilers
echo -e "\tCompiling the C# compiler"
run_xbuild src/Compilers/CSharp/csc/csc.csproj
if [ "$FULL_RUN" = "true" ]; then
echo -e "\tCompiling VB compiler"
run_xbuild src/Compilers/VisualBasic/vbc/vbc.csproj
fi
}
# Save the toolset binaries from Binaries/Debug to Binaries/Bootstrap
save_toolset()
{
local compiler_binaries=(
csc.exe
Microsoft.CodeAnalysis.dll
Microsoft.CodeAnalysis.Desktop.dll
Microsoft.CodeAnalysis.CSharp.dll
Microsoft.CodeAnalysis.CSharp.Desktop.dll
System.Collections.Immutable.dll
System.Reflection.Metadata.dll)
if [ "$FULL_RUN" = "true" ]; then
compiler_binaries=(
${compiler_binaries[@]}
vbc.exe
Microsoft.CodeAnalysis.VisualBasic.dll
Microsoft.CodeAnalysis.VisualBasic.Desktop.dll)
fi
mkdir Binaries/Bootstrap
for i in ${compiler_binaries[@]}; do
cp Binaries/Debug/${i} Binaries/Bootstrap/${i}
if [ $? -ne 0 ]; then
echo Saving bootstrap binaries failed
exit 1
fi
done
}
# Clean out all existing binaries. This ensures the bootstrap phase forces
# a rebuild instead of picking up older binaries.
clean_roslyn()
{
echo Cleaning the enlistment
xbuild /v:m /t:Clean src/Toolset.sln
rm -rf Binaries/Debug
}
build_roslyn()
{
BOOTSTRAP_ARG=/p:BootstrapBuildPath=$(pwd)/Binaries/Bootstrap
echo Running the bootstrap build
if [ "$FULL_RUN" = "true" ]; then
echo -e "\tCompiling CrossPlatform.sln"
run_xbuild $BOOTSTRAP_ARG src/CrossPlatform.sln
else
echo -e "\tCompiling the C# compiler"
run_xbuild $BOOTSTRAP_ARG src/Compilers/CSharp/csc/csc.csproj
fi
}
test_roslyn()
{
if [ "$FULL_RUN" != "true" ]; then
return
fi
local xunit_runner=packages/xunit.runners.$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
for i in "${test_binaries[@]}"
do
mono $xunit_runner Binaries/Debug/$i.dll -xml Binaries/Debug/$i.TestResults.xml -noshadow
if [ $? -ne 0 ]; then
any_failed=true
fi
done
if [ "$any_failed" = "true" ]; then
echo Unit test failed
exit 1
fi
}
# As a bootstrap mechanism in Jenkins we assume that Linux is a
# minimal run. It is not yet updated to the latest mono build
# nor is the --minimal switch present for us to take advantage
# of. This block will be deleted once everything gets pushed
# through.
if [ "$OS_NAME" = "Linux" ]; then
FULL_RUN=false
fi
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
else
echo Changing mono snapshot
. mono-snapshot mono/20150316155603
if [ $? -ne 0 ]; then
echo Could not set mono snapshot
exit 1
fi
fi
# NuGet on mono crashes about every 5th time we run it. This is causing
# Linux runs to fail frequently enough that we need to employ a
# temporary work around.
echo Restoring NuGet packages
run_nuget restore src/Roslyn.sln
run_nuget install xunit.runners -PreRelease -Version $XUNIT_VERSION -OutputDirectory packages
compile_toolset
save_toolset
clean_roslyn
build_roslyn
test_roslyn