[Tizen] Add CoreCLR tests build dependencies v3.1.3 for armel, arm64
[platform/upstream/coreclr.git] / build-packages.sh
1 #!/usr/bin/env bash
2
3 usage()
4 {
5     echo "Builds the NuGet packages from the binaries that were built in the Build product binaries step."
6     echo "Usage: build-packages -BuildArch -BuildType"
7     echo "BuildArch can be x64, x86, arm, arm64 (default is x64)"
8     echo "BuildType can be release, checked, debug (default is debug)"
9     echo
10     exit 1
11 }
12
13 initDistroRid()
14 {
15     source init-distro-rid.sh
16
17     local passedRootfsDir=""
18
19     # Only pass ROOTFS_DIR if __DoCrossArchBuild is specified.
20     if (( ${__CrossBuild} == 1 )); then
21         passedRootfsDir=${ROOTFS_DIR}
22     fi
23
24     initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__IsPortableBuild} ${passedRootfsDir}
25 }
26
27 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
28 __IsPortableBuild=1
29 __CrossBuild=0
30
31 # Use uname to determine what the OS is.
32 OSName=$(uname -s)
33 case $OSName in
34     Linux)
35         __BuildOS=Linux
36         __HostOS=Linux
37         ;;
38
39     Darwin)
40         __BuildOS=OSX
41         __HostOS=OSX
42         ;;
43
44     FreeBSD)
45         __BuildOS=FreeBSD
46         __HostOS=FreeBSD
47         ;;
48
49     OpenBSD)
50         __BuildOS=OpenBSD
51         __HostOS=OpenBSD
52         ;;
53
54     NetBSD)
55         __BuildOS=NetBSD
56         __HostOS=NetBSD
57         ;;
58
59     SunOS)
60         __BuildOS=SunOS
61         __HostOS=SunOS
62         ;;
63
64     *)
65         echo "Unsupported OS $OSName detected, configuring as if for Linux"
66         __BuildOS=Linux
67         __HostOS=Linux
68         ;;
69 esac
70
71 buildArgs=
72 unprocessedBuildArgs=
73
74 # TODO: get rid of argument processing entirely once we remove the
75 # uses of -Arg=Value style in buildpipeline.
76 while :; do
77     if [ $# -le 0 ]; then
78         break
79     fi
80
81     case "$1" in
82         -\?|-h|--help)
83             usage
84             exit 1
85             ;;
86         -BuildArch=*)
87             __BuildArch=$(echo $1| cut -d'=' -f 2)
88             buildArgs="$buildArgs /p:__BuildArch=$__BuildArch"
89             ;;
90         -BuildType=*)
91             __Type=$(echo $1| cut -d'=' -f 2)
92             buildArgs="$buildArgs /p:__BuildType=$__Type"
93             ;;
94         -OfficialBuildId=*|-officialbuildid=*)
95             __Id=$(echo $1| cut -d'=' -f 2)
96             buildArgs="$buildArgs /p:OfficialBuildId=$__Id"
97             ;;
98         -__DoCrossArchBuild=*)
99             __CrossBuild=$(echo $1| cut -d'=' -f 2)
100             buildArgs="$buildArgs /p:__DoCrossArchBuild=$__CrossBuild"
101             ;;
102         -portablebuild=false)
103             buildArgs="$buildArgs /p:PortableBuild=false"
104             __IsPortableBuild=0
105             ;;
106         --)
107             ;;
108         *)
109             unprocessedBuildArgs="$unprocessedBuildArgs $1"
110     esac
111     shift
112 done
113
114 initDistroRid
115
116 if [ "${__DistroRid}" = "linux-musl-arm64" ]; then
117     # ArchGroup is generally determined from parsing {}-{}; however, linux-musl-arm64
118     # will break this logic. To work around this, pass ArchGroup explicitely.
119
120     export ArchGroup=arm64
121
122     # Currently the decision tree in src/.nuget/dirs.props will incorrectly
123     # reparse the already calculated __DistroRid. For linux-musl-arm64 use
124     # the hack/hook to specifically bypass this logic.
125     export OutputRID=${__DistroRid}
126 fi
127
128 logFile=$__ProjectRoot/bin/Logs/build-packages.binlog
129 $__ProjectRoot/eng/common/build.sh -r -b -projects $__ProjectRoot/src/.nuget/packages.builds \
130                                    -verbosity minimal -bl:$logFile \
131                                    /p:__BuildOS=$__BuildOS /p:ArcadeBuild=true \
132                                    /p:PortableBuild=true /p:__DistroRid=$__DistroRid \
133                                    $buildArgs $unprocessedBuildArgs
134 if [ $? -ne 0 ]
135 then
136     echo "ERROR: An error occurred while building packages; See log for more details:"
137     echo "    $logFile"
138     exit 1
139 fi
140
141 echo "Done building packages."
142 exit 0