Skip to content

Commit

Permalink
Remove __DistroRid calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed Apr 3, 2024
1 parent e5cf690 commit 6d27384
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 95 deletions.
9 changes: 4 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,16 @@

<!-- OutputRID is used to name the target platform.
For portable builds, OutputRID matches _portableOS.
For non-portable builds, it uses __DistroRid (from the native build script), or falls back to RuntimeInformation.RuntimeIdentifier.
For non-portable builds, it expects caller to set OutputRID or falls back to RuntimeInformation.RuntimeIdentifier.
Source-build sets OutputRID directly. -->
<PropertyGroup Label="CalculateOutputRID">
<_hostRid Condition="'$(MSBuildRuntimeType)' == 'core'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</_hostRid>
<_hostRid Condition="'$(MSBuildRuntimeType)' != 'core'">win-$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant)</_hostRid>

<_parseDistroRid>$(__DistroRid)</_parseDistroRid>
<_parseDistroRid Condition="'$(_parseDistroRid)' == ''">$(_hostRid)</_parseDistroRid>
<_distroRidIndex>$(_parseDistroRid.LastIndexOf('-'))</_distroRidIndex>
<_parseDistroRid Condition="'$(PortableBuild)' == 'true'">$(_hostRid)</_parseDistroRid>
<_lastHyphenIndex Condition="'$(PortableBuild)' == 'true'">$(_parseDistroRid.LastIndexOf('-'))</_lastHyphenIndex>

<_outputOS>$(_parseDistroRid.SubString(0, $(_distroRidIndex)))</_outputOS>
<_outputOS Condition="'$(PortableBuild)' == 'true'">$(_parseDistroRid.SubString(0, $(_lastHyphenIndex)))</_outputOS>
<_outputOS Condition="'$(PortableBuild)' == 'true'">$(_portableOS)</_outputOS>

<OutputRID Condition="'$(OutputRID)' == ''">$(_outputOS)-$(TargetArchitecture)</OutputRID>
Expand Down
2 changes: 1 addition & 1 deletion eng/common/cross/build-android-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ done

cp -R "$__TmpDir/data/data/com.termux/files/usr/"* "$__ToolchainDir/sysroot/usr/"

# Generate platform file for build.sh script to assign to __DistroRid
# Generate platform file for build.sh script to assign to __OutputRid
echo "Generating platform file..."
echo "RID=android.${__ApiLevel}-${__BuildArch}" > $__ToolchainDir/sysroot/android_platform

Expand Down
78 changes: 1 addition & 77 deletions eng/common/native/init-distro-rid.sh
Original file line number Diff line number Diff line change
@@ -1,78 +1,5 @@
#!/bin/sh

# getNonPortableDistroRid
#
# Input:
# targetOs: (str)
# targetArch: (str)
# rootfsDir: (str)
#
# Return:
# non-portable rid
getNonPortableDistroRid()
{
targetOs="$1"
targetArch="$2"
rootfsDir="$3"
nonPortableRid=""

if [ "$targetOs" = "linux" ]; then
# shellcheck disable=SC1091
if [ -e "${rootfsDir}/etc/os-release" ]; then
. "${rootfsDir}/etc/os-release"
if [ "${ID}" = "rhel" ] || [ "${ID}" = "rocky" ] || [ "${ID}" = "alpine" ] || [ "${ID}" = "ol" ]; then
VERSION_ID="${VERSION_ID%.*}" # Remove the last version digit for these distros
fi

if echo "${VERSION_ID:-}" | grep -qE '^([[:digit:]]|\.)+$'; then
nonPortableRid="${ID}.${VERSION_ID}-${targetArch}"
else
# Rolling release distros either do not set VERSION_ID, set it as blank or
# set it to non-version looking string (such as TEMPLATE_VERSION_ID on ArchLinux);
# so omit it here to be consistent with everything else.
nonPortableRid="${ID}-${targetArch}"
fi
elif [ -e "${rootfsDir}/android_platform" ]; then
# shellcheck disable=SC1091
. "${rootfsDir}/android_platform"
nonPortableRid="$RID"
fi
fi

if [ "$targetOs" = "freebsd" ]; then
# $rootfsDir can be empty. freebsd-version is a shell script and should always work.
__freebsd_major_version=$("$rootfsDir"/bin/freebsd-version | cut -d'.' -f1)
nonPortableRid="freebsd.$__freebsd_major_version-${targetArch}"
elif command -v getprop >/dev/null && getprop ro.product.system.model | grep -qi android; then
__android_sdk_version=$(getprop ro.build.version.sdk)
nonPortableRid="android.$__android_sdk_version-${targetArch}"
elif [ "$targetOs" = "illumos" ]; then
__uname_version=$(uname -v)
case "$__uname_version" in
omnios-*)
__omnios_major_version=$(echo "$__uname_version" | cut -c9-10)
nonPortableRid="omnios.$__omnios_major_version-${targetArch}"
;;
joyent_*)
__smartos_major_version=$(echo "$__uname_version" | cut -c9-10)
nonPortableRid="smartos.$__smartos_major_version-${targetArch}"
;;
*)
nonPortableRid="illumos-${targetArch}"
;;
esac
elif [ "$targetOs" = "solaris" ]; then
__uname_version=$(uname -v)
__solaris_major_version=$(echo "$__uname_version" | cut -d'.' -f1)
nonPortableRid="solaris.$__solaris_major_version-${targetArch}"
elif [ "$targetOs" = "haiku" ]; then
__uname_release="$(uname -r)"
nonPortableRid=haiku.r"$__uname_release"-"$targetArch"
fi

echo "$nonPortableRid" | tr '[:upper:]' '[:lower:]'
}

# initDistroRidGlobal
#
# Input:
Expand All @@ -86,7 +13,6 @@ getNonPortableDistroRid()
# Notes:
# It is important to note that the function does not return anything, but it
# exports the following variables on success:
# __DistroRid : Non-portable rid of the target platform.
# __PortableTargetOS : OS-part of the portable rid that corresponds to the target platform.
initDistroRidGlobal()
{
Expand All @@ -105,8 +31,6 @@ initDistroRidGlobal()
fi
fi

__DistroRid=$(getNonPortableDistroRid "${targetOs}" "${targetArch}" "${rootfsDir}")

if [ -z "${__PortableTargetOS:-}" ]; then
__PortableTargetOS="$targetOs"

Expand All @@ -122,5 +46,5 @@ initDistroRidGlobal()
fi
fi

export __DistroRid __PortableTargetOS
export __PortableTargetOS
}
2 changes: 1 addition & 1 deletion eng/common/templates-official/job/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ parameters:
# The name of the job. This is included in the job ID.
# targetRID: ''
# The name of the target RID to use, instead of the one auto-detected by Arcade.
# nonPortable: false
# portableBuild: true
# Enables non-portable mode. This means a more specific RID (e.g. fedora.32-x64 rather than
# linux-x64), and compiling against distro-provided packages rather than portable ones.
# skipPublishValidation: false
Expand Down
2 changes: 1 addition & 1 deletion eng/common/templates-official/steps/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ steps:
$targetRidArgs \
$runtimeOsArgs \
$baseOsArgs \
/p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \
/p:PortableBuild=${{ parameters.platform.portableBuild }} \
/p:ArcadeBuildFromSource=true \
/p:DotNetBuildSourceOnly=true \
/p:DotNetBuildRepo=true \
Expand Down
2 changes: 1 addition & 1 deletion eng/common/templates/job/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ parameters:
# The name of the job. This is included in the job ID.
# targetRID: ''
# The name of the target RID to use, instead of the one auto-detected by Arcade.
# nonPortable: false
# portableBuild: true
# Enables non-portable mode. This means a more specific RID (e.g. fedora.32-x64 rather than
# linux-x64), and compiling against distro-provided packages rather than portable ones.
# skipPublishValidation: false
Expand Down
2 changes: 1 addition & 1 deletion eng/common/templates/steps/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ steps:
$targetRidArgs \
$runtimeOsArgs \
$baseOsArgs \
/p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \
/p:PortableBuild=${{ parameters.platform.portableBuild }} \
/p:ArcadeBuildFromSource=true \
/p:DotNetBuildSourceOnly=true \
/p:DotNetBuildRepo=true \
Expand Down
5 changes: 3 additions & 2 deletions eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,12 @@ if [[ "$__CrossBuild" == 1 ]]; then
fi
fi

# init the target distro name (__DistroRid) and target portable os (__PortableTargetOS).
# init the OutputRID and target portable os (__PortableTargetOS).
initTargetDistroRid
if [ -z "$__OutputRid" ]; then
if [[ "$__PortableBuild" == 0 ]]; then
__OutputRid="$__DistroRid"
echo "ERROR: --outputrid is required for non-portable builds"
exit 1
else
__OutputRid="$__PortableTargetOS-$__TargetArch"
fi
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/common/global-build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ parameters:
shouldContinueOnError: false
isOfficialBuild: false
isSourceBuild: false
isNonPortableSourceBuild: false
isPortableSourceBuild: true
runtimeFlavor: 'coreclr'
runtimeVariant: ''
helixQueues: ''
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
platform:
baseOS: ${{ parameters.baseOS }}
buildScript: $(Build.SourcesDirectory)$(dir)build$(scriptExt)
nonPortable: ${{ parameters.isNonPortableSourceBuild }}
portableBuild: ${{ parameters.isPortableSourceBuild }}
targetRID: ${{ parameters.targetRid }}
name: ${{ parameters.platform }}

Expand Down
6 changes: 3 additions & 3 deletions eng/pipelines/common/platform-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ jobs:
buildConfig: ${{ parameters.buildConfig }}
helixQueueGroup: ${{ parameters.helixQueueGroup }}
isSourceBuild: true
isNonPortableSourceBuild: true
isPortableSourceBuild: false
${{ insert }}: ${{ parameters.jobParameters }}

# Non-existent RID Source Build
Expand All @@ -336,7 +336,7 @@ jobs:
buildConfig: ${{ parameters.buildConfig }}
helixQueueGroup: ${{ parameters.helixQueueGroup }}
isSourceBuild: true
isNonPortableSourceBuild: true
isPortableSourceBuild: false
${{ insert }}: ${{ parameters.jobParameters }}

# Portable Linux x64 Source Build
Expand All @@ -358,7 +358,7 @@ jobs:
buildConfig: ${{ parameters.buildConfig }}
helixQueueGroup: ${{ parameters.helixQueueGroup }}
isSourceBuild: true
isNonPortableSourceBuild: false
isPortableSourceBuild: true
${{ insert }}: ${{ parameters.jobParameters }}

# GCC Linux x64 Build
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ extends:
jobParameters:
testScope: innerloop
nameSuffix: CoreCLR_NonPortable
buildArgs: -s clr.native+clr.tools+clr.corelib+clr.nativecorelib+clr.aot+clr.packages -c $(_BuildConfig) /p:PortableBuild=false
buildArgs: -s clr.native+clr.tools+clr.corelib+clr.nativecorelib+clr.aot+clr.packages --outputrid tizen.9.0.0-armel -c $(_BuildConfig) /p:PortableBuild=false
timeoutInMinutes: 120
condition: >-
or(
Expand Down

0 comments on commit 6d27384

Please sign in to comment.