-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·312 lines (271 loc) · 8.1 KB
/
build.sh
File metadata and controls
executable file
·312 lines (271 loc) · 8.1 KB
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
303
304
305
306
307
308
309
310
311
312
#!/usr/bin/env bash
usage()
{
echo "Usage: $0 [managed] [native] [BuildArch] [BuildType] [clean] [verbose] [clangx.y] [platform] [cross] [skiptests] [staticLibLink] [cmakeargs] [makeargs]"
echo "managed - optional argument to build the managed code"
echo "native - optional argument to build the native code"
echo "The following arguments affect native builds only:"
echo "BuildArch can be: x64, x86, arm, arm-softfp, arm64"
echo "BuildType can be: debug, release"
echo "clean - optional argument to force a clean build."
echo "verbose - optional argument to enable verbose build output."
echo "clangx.y - optional argument to build using clang version x.y."
echo "platform can be: FreeBSD, Linux, NetBSD, OSX, Windows"
echo "cross - optional argument to signify cross compilation,"
echo " - will use ROOTFS_DIR environment variable if set."
echo "skiptests - skip the tests in the './bin/*/*Tests/' subdirectory."
echo "staticLibLink - Optional argument to statically link any native library."
echo "generateversion - if building native only, pass this in to get a version on the build output."
echo "cmakeargs - user-settable additional arguments passed to CMake."
exit 1
}
setup_dirs()
{
echo Setting up directories for build
mkdir -p "$__BinDir"
mkdir -p "$__IntermediatesDir"
}
# Performs "clean build" type actions (deleting and remaking directories)
clean()
{
echo "Cleaning previous output for the selected configuration"
rm -rf "$__BinDir"
rm -rf "$__IntermediatesDir"
setup_dirs
}
# Prepare the system for building
prepare_managed_build()
{
# Run Init-Tools to restore BuildTools and ToolRuntime
$__scriptpath/init-tools.sh
}
build_managed()
{
__buildproj=$__scriptpath/build.proj
__buildlog=$__scriptpath/msbuild.log
$__scriptpath/Tools/dotnetcli/dotnet $__scriptpath/Tools/MSBuild.exe "$__buildproj" /m /nologo /verbosity:minimal "/flp:Verbosity=normal;LogFile=$__buildlog" "/flp2:warningsonly;logfile=$__scriptpath/msbuild.wrn" "/flp3:errorsonly;logfile=$__scriptpath/msbuild.err" /p:ConfigurationGroup=$__BuildType /p:TargetOS=$__BuildOS /p:OSGroup=$__BuildOS /p:SkipTests=$__SkipTests /p:COMPUTERNAME=$(hostname) /p:USERNAME=$(id -un) /p:TestNugetRuntimeId=$__TestNugetRuntimeId $__UnprocessedBuildArgs
BUILDERRORLEVEL=$?
echo
# Pull the build summary from the log file
tail -n 4 "$__buildlog"
echo Build Exit Code = $BUILDERRORLEVEL
}
__scriptpath=$(cd "$(dirname "$0")"; pwd -P)
__packageroot=$__scriptpath/packages
__sourceroot=$__scriptpath/src
__rootbinpath="$__scriptpath/bin"
__generateversionsource=false
__buildmanaged=false
__TestNugetRuntimeId=win7-x64
# Use uname to determine what the CPU is.
CPUName=$(uname -p)
# Some Linux platforms report unknown for platform, but the arch for machine.
if [ $CPUName == "unknown" ]; then
CPUName=$(uname -m)
fi
case $CPUName in
i686)
__BuildArch=x86
;;
x86_64)
__BuildArch=x64
;;
armv7l)
__BuildArch=arm
;;
aarch64)
__BuildArch=arm64
;;
*)
echo "Unknown CPU $CPUName detected, configuring as if for x64"
__BuildArch=x64
;;
esac
# Use uname to determine what the OS is.
OSName=$(uname -s)
case $OSName in
Darwin)
__HostOS=OSX
__TestNugetRuntimeId=osx.10.10-x64
;;
FreeBSD)
__HostOS=FreeBSD
# TODO: Add native version
__TestNugetRuntimeId=osx.10.10-x64
;;
Linux)
__HostOS=Linux
if [ ! -e /etc/os-release ]; then
echo "Cannot determine Linux distribution, assuming Ubuntu 14.04"
__TestNugetRuntimeId=ubuntu.14.04-x64
else
source /etc/os-release
__TestNugetRuntimeId=$ID.$VERSION_ID-$__BuildArch
fi
;;
NetBSD)
__HostOS=NetBSD
# TODO: Add native version
__TestNugetRuntimeId=osx.10.10-x64
;;
*)
echo "Unsupported OS '$OSName' detected. Configuring as if for Ubuntu."
__HostOS=Linux
__TestNugetRuntimeId=ubuntu.14.04-x64
;;
esac
__BuildOS=$__HostOS
__BuildType=Debug
__CMakeArgs=DEBUG
__CMakeExtraArgs=""
__MakeExtraArgs=""
BUILDERRORLEVEL=0
# Set the various build properties here so that CMake and MSBuild can pick them up
__UnprocessedBuildArgs=
__CleanBuild=false
__CrossBuild=0
__SkipTests=false
__ServerGC=0
__VerboseBuild=false
__ClangMajorVersion=3
__ClangMinorVersion=5
while :; do
if [ $# -le 0 ]; then
break
fi
lowerI="$(echo $1 | awk '{print tolower($0)}')"
case $lowerI in
-\?|-h|--help)
usage
exit 1
;;
managed)
__buildmanaged=true
;;
x86)
__BuildArch=x86
;;
x64)
__BuildArch=x64
;;
arm)
__BuildArch=arm
;;
arm-softfp)
__BuildArch=arm-softfp
;;
arm64)
__BuildArch=arm64
;;
debug)
__BuildType=Debug
;;
release)
__BuildType=Release
__CMakeArgs=RELEASE
;;
clean)
__CleanBuild=1
;;
verbose)
__VerboseBuild=1
;;
staticliblink)
__CMakeExtraArgs="$__CMakeExtraArgs -DCMAKE_STATIC_LIB_LINK=1"
;;
generateversion)
__generateversionsource=true
;;
clang3.5)
__ClangMajorVersion=3
__ClangMinorVersion=5
;;
clang3.6)
__ClangMajorVersion=3
__ClangMinorVersion=6
;;
clang3.7)
__ClangMajorVersion=3
__ClangMinorVersion=7
;;
clang3.8)
__ClangMajorVersion=3
__ClangMinorVersion=8
;;
freebsd)
__BuildOS=FreeBSD
__TestNugetRuntimeId=osx.10.10-x64
;;
linux)
__BuildOS=Linux
# If the Host OS is also Linux, then use the RID of the host.
# Otherwise, override it to Ubuntu by default.
if [ "$__HostOS" != "Linux" ]; then
__TestNugetRuntimeId=ubuntu.14.04-x64
fi
;;
netbsd)
__BuildOS=NetBSD
__TestNugetRuntimeId=osx.10.10-x64
;;
osx)
__BuildOS=OSX
__TestNugetRuntimeId=osx.10.10-x64
;;
windows)
__BuildOS=Windows_NT
__TestNugetRuntimeId=win7-x64
;;
cross)
__CrossBuild=1
;;
skiptests)
__SkipTests=true
;;
cmakeargs)
if [ -n "$2" ]; then
__CMakeExtraArgs="$__CMakeExtraArgs $2"
shift
else
echo "ERROR: 'cmakeargs' requires a non-empty option argument"
exit 1
fi
;;
makeargs)
if [ -n "$2" ]; then
__MakeExtraArgs="$__MakeExtraArgs $2"
shift
else
echo "ERROR: 'makeargs' requires a non-empty option argument"
exit 1
fi
;;
useservergc)
__ServerGC=1
;;
*)
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
esac
shift
done
if [ "$__buildmanaged" = false ]; then
__buildmanaged=true
fi
# Set the remaining variables based upon the determined build configuration
__IntermediatesDir="$__rootbinpath/obj/$__BuildOS.$__BuildArch.$__BuildType/Native"
__BinDir="$__rootbinpath/$__BuildOS.$__BuildArch.$__BuildType/Native"
# Make the directories necessary for build if they don't exist
setup_dirs
export CORECLR_SERVER_GC="$__ServerGC"
if $__buildmanaged; then
# Prepare the system
prepare_managed_build
# Build the corefx native components.
build_managed
# Build complete
fi
# If managed build failed, exit with the status code of the managed build
if [ $BUILDERRORLEVEL != 0 ]; then
exit $BUILDERRORLEVEL
fi
exit $BUILDERRORLEVEL