Pass the --clr-memory-model flag on the command line instead of MONO_DEBUG so its...
[mono-project.git] / netcore / build.sh
blobb93074794857bed0ed057c75adcbd611a19993ce
1 #!/usr/bin/env bash
3 # Stop script if unbound variable found (use ${var:-} if intentional)
4 set -u
6 # Stop script if command returns non-zero exit code.
7 # Prevents hidden errors caused by missing error code propagation.
8 set -e
10 usage()
12 echo "Common settings:"
13 echo " --configuration <value> Build configuration: 'Debug' or 'Release' (short: -c)"
14 echo " --help Print help and exit (short: -h)"
15 echo ""
17 echo "Actions:"
18 echo " --pack Package build outputs into NuGet packages"
19 echo " --test Run all unit tests in the solution (short: -t)"
20 echo " --rebuild Run ../.autogen.sh"
21 echo " --skipnative Do not build runtime"
22 echo " --skipmscorlib Do not build System.Private.CoreLib"
23 echo ""
25 echo "Command line arguments starting with '/p:' are passed through to MSBuild."
26 echo "Arguments can also be passed in with a single hyphen."
29 pack=false
30 configuration='Debug'
31 properties=''
32 force_rebuild=false
33 test=false
34 skipmscorlib=false
35 skipnative=false
37 while [[ $# > 0 ]]; do
38 opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
39 case "$opt" in
40 -help|-h)
41 usage
42 exit 0
44 -configuration|-c)
45 properties="$properties $1 $2"
46 configuration=$2
47 shift
49 -pack)
50 pack=true
52 -test|-t)
53 test=true
55 -rebuild)
56 force_rebuild=true
58 -skipmscorlib)
59 skipmscorlib=true
61 -skipnative)
62 skipnative=true
64 -p:*|/p:*)
65 properties="$properties $1"
67 -m:*|/m:*)
68 properties="$properties $1"
70 -bl:*|/bl:*)
71 properties="$properties $1"
73 -dl:*|/dl:*)
74 properties="$properties $1"
77 echo "Invalid argument: $1"
78 usage
79 exit 1
81 esac
83 shift
84 done
86 CPU_COUNT=$(getconf _NPROCESSORS_ONLN || echo 4)
88 # run .././autogen.sh only once or if "--rebuild" argument is provided
89 if [[ "$force_rebuild" == "true" || ! -f .configured ]]; then
90 (cd .. && ./autogen.sh --with-core=only)
91 touch .configured
94 # build mono runtime
95 if [ "$skipnative" = "false" ]; then
96 make runtime -j$CPU_COUNT
99 # build System.Private.CoreLib (../mcs/class/System.Private.CoreLib)
100 if [ "$skipmscorlib" = "false" ]; then
101 make bcl CORLIB_BUILD_FLAGS="$properties"
104 # create a nupkg with runtime and System.Private.CoreLib
105 if [ "$pack" = "true" ]; then
106 make nupkg
109 # run all xunit tests
110 if [ "$test" = "true" ]; then
111 for testdir in corefx/tests/extracted/*; do
112 ../scripts/ci/./run-step.sh --label=$(basename $testdir) --timeout=15m make run-tests-corefx-$(basename $testdir)
113 done