From 454cb638a42548fb9f17bae44fb69d8a5a755939 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 26 Oct 2022 15:32:14 -0400 Subject: [PATCH] Pass TargetRid and SourceBuildNonPortable to the native scripts (backport of #74504) --- eng/SourceBuild.props | 22 ++++++++++++++------- eng/build.sh | 10 ++++++++++ eng/common/templates/steps/source-build.yml | 6 ++++++ eng/native/build-commons.sh | 15 ++++++++++++++ eng/pipelines/common/global-build-job.yml | 2 ++ src/native/corehost/build.sh | 7 +++---- src/native/corehost/corehost.proj | 1 + 7 files changed, 52 insertions(+), 11 deletions(-) diff --git a/eng/SourceBuild.props b/eng/SourceBuild.props index bba40f534e5b6..fcbe9fa75e2a9 100644 --- a/eng/SourceBuild.props +++ b/eng/SourceBuild.props @@ -11,14 +11,20 @@ true false - + $([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier) $(__DistroRid) <_targetRidPlatformIndex>$(TargetRid.LastIndexOfAny("-")) - $(TargetRid.Substring(0, $(_targetRidPlatformIndex))) - $(TargetRid.Substring($(_targetRidPlatformIndex)).TrimStart('-')) + $(TargetRid.Substring($(_targetRidPlatformIndex)).TrimStart('-')) + + + $(TargetRid.Substring(0, $(_targetRidPlatformIndex))) + + + $(RuntimeOS) minimal @@ -34,19 +40,21 @@ - $(InnerBuildArgs) --arch $(TargetRidPlatform) + $(InnerBuildArgs) --arch $(TargetArch) $(InnerBuildArgs) --configuration $(Configuration) $(InnerBuildArgs) --allconfigurations $(InnerBuildArgs) --verbosity $(LogVerbosity) $(InnerBuildArgs) --nodereuse false $(InnerBuildArgs) --warnAsError false $(InnerBuildArgs) /p:MicrosoftNetFrameworkReferenceAssembliesVersion=1.0.2 - $(InnerBuildArgs) /p:PackageRid=$(TargetRid) + $(InnerBuildArgs) --outputrid $(TargetRid) + $(InnerBuildArgs) --portablebuild $(SourceBuildPortable) $(InnerBuildArgs) /p:NoPgoOptimize=true $(InnerBuildArgs) /p:KeepNativeSymbols=true - $(InnerBuildArgs) /p:RuntimeOS=$(TargetRidWithoutPlatform) - $(InnerBuildArgs) /p:PortableBuild=$(SourceBuildPortable) + $(InnerBuildArgs) /p:RuntimeOS=$(RuntimeOS) $(InnerBuildArgs) /p:BuildDebPackage=false + $(InnerBuildArgs) /p:RuntimeOS=$(RuntimeOS) + $(InnerBuildArgs) /p:AdditionalRuntimeIdentifierParent=$(BaseOS) diff --git a/eng/build.sh b/eng/build.sh index 8836bde10c492..ea6be90af6107 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -31,6 +31,7 @@ usage() echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS," echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, NetBSD, illumos or Solaris." echo " [Default: Your machine's OS.]" + echo " --outputrid Optional argument that overrides the target rid name." echo " --projects Project or solution file(s) to build." echo " --runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked." echo " Checked is exclusive to the CLR runtime. It is the same as Debug, except code is" @@ -400,6 +401,15 @@ while [[ $# > 0 ]]; do shift 1 ;; + -outputrid) + if [ -z ${2+x} ]; then + echo "No value for outputrid is supplied. See help (--help) for supported values." 1>&2 + exit 1 + fi + arguments="$arguments /p:OutputRid=$(echo "$2" | tr "[:upper:]" "[:lower:]")" + shift 2 + ;; + -portablebuild) if [ -z ${2+x} ]; then echo "No value for portablebuild is supplied. See help (--help) for supported values." 1>&2 diff --git a/eng/common/templates/steps/source-build.yml b/eng/common/templates/steps/source-build.yml index abb1b2bcda42b..b5b3e5aeb3b91 100644 --- a/eng/common/templates/steps/source-build.yml +++ b/eng/common/templates/steps/source-build.yml @@ -63,6 +63,11 @@ steps: targetRidArgs='/p:TargetRid=${{ parameters.platform.targetRID }}' fi + runtimeOsArgs= + if [ '${{ parameters.platform.runtimeOS }}' != '' ]; then + runtimeOsArgs='/p:RuntimeOS=${{ parameters.platform.runtimeOS }}' + fi + publishArgs= if [ '${{ parameters.platform.skipPublishValidation }}' != 'true' ]; then publishArgs='--publish' @@ -75,6 +80,7 @@ steps: $internalRuntimeDownloadArgs \ $internalRestoreArgs \ $targetRidArgs \ + $runtimeOsArgs \ /p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \ /p:ArcadeBuildFromSource=true displayName: Build diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 9600e346b3613..85a6f50ec6668 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -246,6 +246,7 @@ usage() echo "-msbuildonunsupportedplatform: build managed binaries even if distro is not officially supported." echo "-ninja: target ninja instead of GNU make" echo "-numproc: set the number of build processes." + echo "-outputrid: optional argument that overrides the target rid name." echo "-portablebuild: pass -portablebuild=false to force a non-portable build." echo "-skipconfigure: skip build configuration." echo "-skipgenerateversion: disable version generation even if MSBuild is supported." @@ -268,6 +269,7 @@ __HostArch=$arch __TargetOS=$os __HostOS=$os __BuildOS=$os +__OutputRid='' __msbuildonunsupportedplatform=0 @@ -443,6 +445,16 @@ while :; do __BuildArch=wasm ;; + outputrid|-outputrid) + if [[ -n "$2" ]]; then + __OutputRid="$2" + shift + else + echo "ERROR: 'outputrid' requires a non-empty option argument" + exit 1 + fi + ;; + os|-os) if [[ -n "$2" ]]; then __TargetOS="$2" @@ -508,5 +520,8 @@ fi # init the target distro name initTargetDistroRid +if [ -z "$__OutputRid" ]; then + __OutputRid="$(echo $__DistroRid | tr '[:upper:]' '[:lower:]')" +fi # Init if MSBuild for .NET Core is supported for this platform isMSBuildOnNETCoreSupported diff --git a/eng/pipelines/common/global-build-job.yml b/eng/pipelines/common/global-build-job.yml index c5d913a46eae1..1dcd4aa5a9252 100644 --- a/eng/pipelines/common/global-build-job.yml +++ b/eng/pipelines/common/global-build-job.yml @@ -129,6 +129,8 @@ jobs: platform: buildScript: $(_sclEnableCommand) $(Build.SourcesDirectory)$(dir)build$(scriptExt) nonPortable: true + targetRID: banana.24-x64 + runtimeOS: linux - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS', 'MacCatalyst') }}: - script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} ${{ parameters.archType }} azDO diff --git a/src/native/corehost/build.sh b/src/native/corehost/build.sh index 3aa6820e73a10..4d7828a008d5c 100755 --- a/src/native/corehost/build.sh +++ b/src/native/corehost/build.sh @@ -83,14 +83,13 @@ __LogsDir="$__RootBinDir/log" __MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs" # Set the remaining variables based upon the determined build configuration -__DistroRidLower="$(echo $__DistroRid | tr '[:upper:]' '[:lower:]')" -__BinDir="$__RootBinDir/bin/$__DistroRidLower.$__BuildType" -__IntermediatesDir="$__RootBinDir/obj/$__DistroRidLower.$__BuildType" +__BinDir="$__RootBinDir/bin/$__OutputRid.$__BuildType" +__IntermediatesDir="$__RootBinDir/obj/$__OutputRid.$__BuildType" export __BinDir __IntermediatesDir __CoreClrArtifacts __RuntimeFlavor __CMakeArgs="-DCLI_CMAKE_HOST_VER=\"$__host_ver\" -DCLI_CMAKE_COMMON_HOST_VER=\"$__apphost_ver\" -DCLI_CMAKE_HOST_FXR_VER=\"$__fxr_ver\" $__CMakeArgs" -__CMakeArgs="-DCLI_CMAKE_HOST_POLICY_VER=\"$__policy_ver\" -DCLI_CMAKE_PKG_RID=\"$__DistroRid\" -DCLI_CMAKE_COMMIT_HASH=\"$__commit_hash\" $__CMakeArgs" +__CMakeArgs="-DCLI_CMAKE_HOST_POLICY_VER=\"$__policy_ver\" -DCLI_CMAKE_PKG_RID=\"$__OutputRid\" -DCLI_CMAKE_COMMIT_HASH=\"$__commit_hash\" $__CMakeArgs" __CMakeArgs="-DRUNTIME_FLAVOR=\"$__RuntimeFlavor\" $__CMakeArgs" __CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs" diff --git a/src/native/corehost/corehost.proj b/src/native/corehost/corehost.proj index ba630e8d2f8e1..004358388b1e8 100644 --- a/src/native/corehost/corehost.proj +++ b/src/native/corehost/corehost.proj @@ -33,6 +33,7 @@ $(BuildArgs) -ninja $(BuildArgs) -runtimeflavor $(RuntimeFlavor) $(BuildArgs) /p:OfficialBuildId="$(OfficialBuildId)" + $(BuildArgs) -outputrid $(OutputRid)