3 # Stop script if unbound variable found (use ${var:-} if intentional)
6 # Stop script if command returns non-zero exit code.
7 # Prevents hidden errors caused by missing error code propagation.
10 # Handle being in the "wrong" directory
11 cd "${BASH_SOURCE%/*}/"
13 # Include VSTS logging helpers
14 . ..
/eng
/common
/pipeline-logging-functions.sh
18 echo "Common settings:"
19 echo " --configuration <value> Build configuration: 'Debug' or 'Release' (short: -c)"
20 echo " --help Print help and exit (short: -h)"
24 echo " --pack Package build outputs into NuGet packages"
25 echo " --test Run all unit tests in the solution (short: -t)"
26 echo " --rebuild Run ../.autogen.sh"
27 echo " --llvm Enable LLVM support"
28 echo " --skipnative Do not build runtime"
29 echo " --skipmscorlib Do not build System.Private.CoreLib"
30 echo " --ci Enable Azure DevOps telemetry decoration"
33 echo "Command line arguments starting with '/p:' are passed through to MSBuild."
34 echo "Arguments can also be passed in with a single hyphen."
48 while [[ $# > 0 ]]; do
49 opt
="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
56 properties
="$properties $1 $2"
82 properties
="$properties $1"
85 properties
="$properties $1"
88 properties
="$properties $1"
91 properties
="$properties $1"
94 echo "Invalid argument: $1"
103 CPU_COUNT
=$
(getconf _NPROCESSORS_ONLN ||
echo 4)
105 if [[ "$configuration" == "Debug" ]]; then
106 EXTRA_CFLAGS
="-O0 -ggdb3 -fno-omit-frame-pointer"
107 EXTRA_CXXFLAGS
="-O0 -ggdb3 -fno-omit-frame-pointer"
108 elif [[ "$configuration" == "Release" ]]; then
109 EXTRA_CFLAGS
="-O2 -g"
110 EXTRA_CXXFLAGS
="-O2 -g"
113 if [ "$llvm" = "true" ]; then
114 git submodule update
--init -- ..
/external
/llvm-project ||
(Write-PipelineTelemetryError
-c "git" -e 1 "Error fetching LLVM submodule" && exit 1)
115 autogen_params
="$autogen_params --enable-llvm"
118 # run .././autogen.sh only once or if "--rebuild" argument is provided
119 if [[ "$force_rebuild" == "true" ||
! -f .configured
]]; then
120 (cd ..
&& .
/autogen.sh
--with-core=only
$autogen_params CFLAGS
="$EXTRA_CFLAGS" CXXFLAGS
="$EXTRA_CXXFLAGS") ||
(Write-PipelineTelemetryError
-c "configure" -e 1 "Error running autogen" && exit 1)
125 if [ "$skipnative" = "false" ]; then
126 make runtime
-j$CPU_COUNT ||
(Write-PipelineTelemetryError
-c "runtime" -e 1 "Error building unmanaged runtime" && exit 1)
129 # build System.Private.CoreLib (../mcs/class/System.Private.CoreLib)
130 if [ "$skipmscorlib" = "false" ]; then
131 make bcl CORLIB_BUILD_FLAGS
="$properties" ||
(Write-PipelineTelemetryError
-c "bcl" -e 1 "Error building System.Private.CoreLib" && exit 1)
134 # create a nupkg with runtime and System.Private.CoreLib
135 if [ "$pack" = "true" ]; then
136 if [ "$llvm" = "true" ]; then
137 make nupkg-llvm ||
(Write-PipelineTelemetryError
-c "nupkg" -e 1 "Error packing NuGet package" && exit 1)
139 make nupkg ||
(Write-PipelineTelemetryError
-c "nupkg" -e 1 "Error packing NuGet package" && exit 1)
143 # run all xunit tests
144 if [ "$test" = "true" ]; then
145 make update-tests-corefx ||
(Write-PipelineTelemetryError
-c "tests-download" -e 1 "Error downloading tests" && exit 1)
146 if [ "$ci" = "true" ]; then
147 make run-tests-corefx USE_TIMEOUT
=1 ||
(Write-PipelineTelemetryError
-c "tests" -e 1 "Error running tests" && exit 1)
149 make run-tests-corefx