diff options
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 89 |
1 files changed, 16 insertions, 73 deletions
@@ -60,78 +60,25 @@ usage() echo "-bindir - output directory (defaults to $__ProjectRoot/bin)" echo "-msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported." echo "-numproc - set the number of build processes." + echo "-portablebuild - pass -portablebuild=false to force a non-portable build." exit 1 } -initHostDistroRid() -{ - __HostDistroRid="" - if [ "$__HostOS" == "Linux" ]; then - if [ -e /etc/os-release ]; then - source /etc/os-release - if [[ $ID == "rhel" ]]; then - # remove the last version digit - VERSION_ID=${VERSION_ID%.*} - fi - __HostDistroRid="$ID.$VERSION_ID-$__HostArch" - if [[ $ID == "alpine" ]]; then - __HostDistroRid="linux-musl-$__HostArch" - fi - elif [ -e /etc/redhat-release ]; then - local redhatRelease=$(</etc/redhat-release) - if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then - __HostDistroRid="rhel.6-$__HostArch" - fi - if [[ $redhatRelease == "CentOS Linux release 7."* ]]; then - __HostDistroRid="rhel.7-$__Arch" - fi - fi - fi - if [ "$__HostOS" == "FreeBSD" ]; then - __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'` - __HostDistroRid="freebsd.$__freebsd_version-$__HostArch" - fi - - if [ "$__HostDistroRid" == "" ]; then - echo "WARNING: Can not determine runtime id for current distro." - fi -} - initTargetDistroRid() { - if [ $__CrossBuild == 1 ]; then - if [ "$__BuildOS" == "Linux" ]; then - if [ ! -e $ROOTFS_DIR/etc/os-release ]; then - if [ -e $ROOTFS_DIR/android_platform ]; then - source $ROOTFS_DIR/android_platform - export __DistroRid="$RID" - else - echo "WARNING: Can not determine runtime id for current distro." - export __DistroRid="" - fi - else - source $ROOTFS_DIR/etc/os-release - export __DistroRid="$ID.$VERSION_ID-$__BuildArch" - fi - fi - else - export __DistroRid="$__HostDistroRid" - fi + source init-distro-rid.sh - if [ "$__BuildOS" == "OSX" ]; then - __PortableBuild=1 - fi + local passedRootfsDir="" - # Portable builds target the base RID - if [ $__PortableBuild == 1 ]; then - if [ "$__BuildOS" == "Linux" ]; then - export __DistroRid="linux-$__BuildArch" - elif [ "$__BuildOS" == "OSX" ]; then - export __DistroRid="osx-$__BuildArch" - elif [ "$__BuildOS" == "FreeBSD" ]; then - export __DistroRid="freebsd-$__BuildArch" - fi + # Only pass ROOTFS_DIR if cross is specified. + if (( ${__CrossBuild} == 1 )); then + passedRootfsDir=${ROOTFS_DIR} + elif [ "${__BuildArch}" != "${__HostArch}" ]; then + echo "Error, you are building a cross scenario without passing -cross." + exit 1 fi + + initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__PortableBuild} ${passedRootfsDir} } setup_dirs() @@ -410,10 +357,10 @@ isMSBuildOnNETCoreSupported() if [ "$__HostOS" == "Linux" ]; then __isMSBuildOnNETCoreSupported=1 # note: the RIDs below can use globbing patterns - UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64") + UNSUPPORTED_RIDS=("ubuntu.17.04-x64") for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}" do - if [[ $__HostDistroRid == $UNSUPPORTED_RID ]]; then + if [[ ${__DistroRid} == $UNSUPPORTED_RID ]]; then __isMSBuildOnNETCoreSupported=0 break fi @@ -691,7 +638,6 @@ __GccBuild=0 __GccMajorVersion=0 __GccMinorVersion=0 __NuGetPath="$__PackagesDir/NuGet.exe" -__HostDistroRid="" __DistroRid="" __cmakeargs="" __SkipGenerateVersion=0 @@ -1035,9 +981,6 @@ fi __LogsDir="$__RootBinDir/Logs" __MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs" -# init the host distro name -initHostDistroRid - # Set the remaining variables based upon the determined build configuration __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType" __PackagesBinDir="$__BinDir/.nuget" @@ -1054,6 +997,9 @@ if [ $__CrossBuild == 1 ]; then fi __CrossGenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$__BuildArch.$__BuildType.log" +# init the target distro name +initTargetDistroRid + # Init if MSBuild for .NET Core is supported for this platform isMSBuildOnNETCoreSupported @@ -1079,9 +1025,6 @@ if [ $__CrossBuild == 1 ]; then fi fi -# init the target distro name -initTargetDistroRid - # Make the directories necessary for build if they don't exist setup_dirs |