[Tizen] Add crossgen and coreconsole to coreclr package
[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 initHostDistroRid()
14 {
15     __HostDistroRid=""
16     if [ "$__HostOS" == "Linux" ]; then
17         if [ -e /etc/os-release ]; then
18             source /etc/os-release
19             if [[ $ID == "rhel" ]]; then
20                 # remove the last version digit
21                 VERSION_ID=${VERSION_ID%.*}
22             fi
23             __HostDistroRid="$ID.$VERSION_ID-$__Arch"
24             if [[ $ID == "alpine" ]]; then
25                 __HostDistroRid="linux-musl-$__Arch"
26             fi
27         elif [ -e /etc/redhat-release ]; then
28             local redhatRelease=$(</etc/redhat-release)
29             if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
30                __HostDistroRid="rhel.6-$__Arch"
31             fi
32         fi
33     fi
34     if [ "$__HostOS" == "FreeBSD" ]; then
35         __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
36         __HostDistroRid="freebsd.$__freebsd_version-$__Arch"
37     fi
38
39     if [ "$__HostDistroRid" == "" ]; then
40         echo "WARNING: Cannot determine runtime id for current distro."
41     fi
42 }
43
44 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
45 __IsPortableBuild=1
46
47 # Use uname to determine what the OS is.
48 OSName=$(uname -s)
49 case $OSName in
50     Linux)
51         __BuildOS=Linux
52         __HostOS=Linux
53         ;;
54
55     Darwin)
56         __BuildOS=OSX
57         __HostOS=OSX
58         ;;
59
60     FreeBSD)
61         __BuildOS=FreeBSD
62         __HostOS=FreeBSD
63         ;;
64
65     OpenBSD)
66         __BuildOS=OpenBSD
67         __HostOS=OpenBSD
68         ;;
69
70     NetBSD)
71         __BuildOS=NetBSD
72         __HostOS=NetBSD
73         ;;
74
75     SunOS)
76         __BuildOS=SunOS
77         __HostOS=SunOS
78         ;;
79
80     *)
81         echo "Unsupported OS $OSName detected, configuring as if for Linux"
82         __BuildOS=Linux
83         __HostOS=Linux
84         ;;
85 esac
86
87 unprocessedBuildArgs=
88
89 while :; do
90     if [ $# -le 0 ]; then
91         break
92     fi
93
94     case "$1" in
95         -\?|-h|--help)
96         usage
97         exit 1
98         ;;
99         -BuildArch=*)
100         unprocessedBuildArgs="$unprocessedBuildArgs $1"
101         __Arch=$(echo $1| cut -d'=' -f 2)
102         ;;
103
104         -portablebuild=false)
105             unprocessedBuildArgs="$unprocessedBuildArgs $1"
106             __IsPortableBuild=0
107             ;;
108         *)
109         unprocessedBuildArgs="$unprocessedBuildArgs $1"
110     esac
111     shift
112 done
113
114 # Portable builds target the base RID
115 if [ $__IsPortableBuild == 1 ]; then
116     if [ "$__BuildOS" == "Linux" ]; then
117         export __DistroRid="linux-$__Arch"
118     elif [ "$__BuildOS" == "OSX" ]; then
119         export __DistroRid="osx-$__Arch"
120     fi
121 else
122     # init the host distro name
123     initHostDistroRid
124     export __DistroRid="$__HostDistroRid"
125 fi
126
127 $__ProjectRoot/run.sh build-packages -Project=$__ProjectRoot/src/.nuget/packages.builds -DistroRid=$__DistroRid -UseSharedCompilation=false -BuildNugetPackage=false -MsBuildEventLogging="/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log" $unprocessedBuildArgs
128 if [ $? -ne 0 ]
129 then
130     echo "ERROR: An error occurred while building packages; See build-packages.log for more details."
131     exit 1
132 fi
133
134 echo "Done building packages."
135 exit 0