Skip to content

Commit 45a8ea8

Browse files
committed
Pass SourceBuild TargetRid and SourceBuildPortable args through the native script.
1 parent bd4bea6 commit 45a8ea8

File tree

6 files changed

+91
-59
lines changed

6 files changed

+91
-59
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
</PropertyGroup>
232232

233233
<PropertyGroup>
234-
<DotNetHostBinDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', '$(OutputRid).$(Configuration)', 'corehost'))</DotNetHostBinDir>
234+
<DotNetHostBinDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', '$(PackageRID).$(Configuration)', 'corehost'))</DotNetHostBinDir>
235235
</PropertyGroup>
236236

237237
<!--Feature switches -->

eng/SourceBuild.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
<InnerBuildArgs>$(InnerBuildArgs) --verbosity $(LogVerbosity)</InnerBuildArgs>
3333
<InnerBuildArgs>$(InnerBuildArgs) --nodereuse false</InnerBuildArgs>
3434
<InnerBuildArgs>$(InnerBuildArgs) --warnAsError false</InnerBuildArgs>
35-
<InnerBuildArgs>$(InnerBuildArgs) /p:PackageRid=$(TargetRid)</InnerBuildArgs>
35+
<InnerBuildArgs>$(InnerBuildArgs) --packagerid $(TargetRid)</InnerBuildArgs>
3636
<InnerBuildArgs>$(InnerBuildArgs) /p:NoPgoOptimize=true</InnerBuildArgs>
3737
<InnerBuildArgs>$(InnerBuildArgs) /p:KeepNativeSymbols=true</InnerBuildArgs>
3838
<InnerBuildArgs>$(InnerBuildArgs) /p:RuntimeOS=$(TargetRidWithoutPlatform)</InnerBuildArgs>
39-
<InnerBuildArgs>$(InnerBuildArgs) /p:PortableBuild=$(SourceBuildPortable)</InnerBuildArgs>
39+
<InnerBuildArgs>$(InnerBuildArgs) --portablebuild $(SourceBuildPortable)</InnerBuildArgs>
4040
<InnerBuildArgs>$(InnerBuildArgs) /p:BuildDebPackage=false</InnerBuildArgs>
4141
<InnerBuildArgs>$(InnerBuildArgs) /p:EnableNgenOptimization=false</InnerBuildArgs>
4242
</PropertyGroup>

eng/build.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ usage()
3131
echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS,"
3232
echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, NetBSD, illumos or Solaris."
3333
echo " [Default: Your machine's OS.]"
34+
echo " --packagerid <rid> Optional argument that overrides the target rid name."
3435
echo " --projects <value> Project or solution file(s) to build."
3536
echo " --runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked."
3637
echo " Checked is exclusive to the CLR runtime. It is the same as Debug, except code is"
@@ -134,12 +135,13 @@ initDistroRid()
134135
local buildArch="$2"
135136
local isCrossBuild="$3"
136137
local isPortableBuild="$4"
138+
local packageRid="$5"
137139

138140
# Only pass ROOTFS_DIR if __DoCrossArchBuild is specified and the current platform is not OSX that doesn't use rootfs
139141
if [[ $isCrossBuild == 1 && "$targetOs" != "OSX" ]]; then
140142
passedRootfsDir=${ROOTFS_DIR}
141143
fi
142-
initDistroRidGlobal ${targetOs} ${buildArch} ${isPortableBuild} ${passedRootfsDir}
144+
initDistroRidGlobal ${targetOs} ${buildArch} ${isPortableBuild} "${packageRid}" ${passedRootfsDir}
143145
}
144146

145147
showSubsetHelp()
@@ -152,6 +154,7 @@ cmakeargs=''
152154
extraargs=''
153155
crossBuild=0
154156
portableBuild=1
157+
packageRid=''
155158

156159
source $scriptroot/native/init-os-and-arch.sh
157160

@@ -402,6 +405,16 @@ while [[ $# > 0 ]]; do
402405
shift 1
403406
;;
404407

408+
-packagerid)
409+
if [ -z ${2+x} ]; then
410+
echo "No value for packagerid is supplied. See help (--help) for supported values." 1>&2
411+
exit 1
412+
fi
413+
packageRid="$(echo "$2" | tr "[:upper:]" "[:lower:]")"
414+
arguments="$arguments /p:PackageRid=$packageRid"
415+
shift 2
416+
;;
417+
405418
-portablebuild)
406419
if [ -z ${2+x} ]; then
407420
echo "No value for portablebuild is supplied. See help (--help) for supported values." 1>&2
@@ -468,7 +481,7 @@ if [[ "$os" == "Browser" && "$arch" != "wasm" ]]; then
468481
arch=wasm
469482
fi
470483

471-
initDistroRid $os $arch $crossBuild $portableBuild
484+
initDistroRid $os $arch $crossBuild $portableBuild "$packageRid"
472485

473486
# Disable targeting pack caching as we reference a partially constructed targeting pack and update it later.
474487
# The later changes are ignored when using the cache.

eng/native/build-commons.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ initTargetDistroRid()
1111
passedRootfsDir="$ROOTFS_DIR"
1212
fi
1313

14-
initDistroRidGlobal "$__TargetOS" "$__TargetArch" "$__PortableBuild" "$passedRootfsDir"
14+
initDistroRidGlobal "$__TargetOS" "$__TargetArch" "$__PortableBuild" "$packageRid" "$passedRootfsDir"
1515
}
1616

1717
setup_dirs()
@@ -212,6 +212,7 @@ usage()
212212
echo "-gccx.y: optional argument to build using gcc version x.y."
213213
echo "-ninja: target ninja instead of GNU make"
214214
echo "-numproc: set the number of build processes."
215+
echo "-packagerid: optional argument that overrides the target rid name."
215216
echo "-portablebuild: pass -portablebuild=false to force a non-portable build."
216217
echo "-skipconfigure: skip build configuration."
217218
echo "-keepnativesymbols: keep native/unmanaged debug symbols."
@@ -253,6 +254,8 @@ else
253254
fi
254255
fi
255256

257+
packageRid=''
258+
256259
while :; do
257260
if [[ "$#" -le 0 ]]; then
258261
break
@@ -396,6 +399,16 @@ while :; do
396399
__TargetArch=wasm
397400
;;
398401

402+
packagerid|-packagerid)
403+
if [[ -n "$2" ]]; then
404+
packageRid="$2"
405+
shift
406+
else
407+
echo "ERROR: 'packageRid' requires a non-empty option argument"
408+
exit 1
409+
fi
410+
;;
411+
399412
ppc64le|-ppc64le)
400413
__TargetArch=ppc64le
401414
;;

eng/native/init-distro-rid.sh

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -132,71 +132,76 @@ initDistroRidGlobal()
132132
local targetOs="$1"
133133
local buildArch="$2"
134134
local isPortable="$3"
135+
local packageRid="$4"
135136
local rootfsDir=""
136-
if [ "$#" -ge 4 ]; then
137-
rootfsDir="$4"
137+
if [ "$#" -ge 5 ]; then
138+
rootfsDir="$5"
138139
fi
139140

140-
if [ -n "${rootfsDir}" ]; then
141-
# We may have a cross build. Check for the existence of the rootfsDir
142-
if [ ! -e "${rootfsDir}" ]; then
143-
echo "Error rootfsDir has been passed, but the location is not valid."
144-
exit 1
141+
if [ -n "$packageRid" ]; then
142+
export __DistroRid=$packageRid
143+
else
144+
if [ -n "${rootfsDir}" ]; then
145+
# We may have a cross build. Check for the existence of the rootfsDir
146+
if [ ! -e "${rootfsDir}" ]; then
147+
echo "Error rootfsDir has been passed, but the location is not valid."
148+
exit 1
149+
fi
145150
fi
146-
fi
147151

148-
initNonPortableDistroRid "${targetOs}" "${buildArch}" "${isPortable}" "${rootfsDir}"
152+
initNonPortableDistroRid "${targetOs}" "${buildArch}" "${isPortable}" "${rootfsDir}"
149153

150-
if [ "$buildArch" = "wasm" ]; then
151-
__DistroRid=browser-wasm
152-
export __DistroRid
153-
fi
154+
if [ "$buildArch" = "wasm" ]; then
155+
__DistroRid=browser-wasm
156+
export __DistroRid
157+
fi
154158

155-
if [ -z "${__DistroRid}" ]; then
156-
# The non-portable build rid was not set. Set the portable rid.
159+
if [ -z "${__DistroRid}" ]; then
160+
# The non-portable build rid was not set. Set the portable rid.
157161

158-
__PortableBuild=1
159-
export __PortableBuild
160-
local distroRid=""
162+
__PortableBuild=1
163+
export __PortableBuild
164+
local distroRid=""
161165

162-
# Check for musl-based distros (e.g Alpine Linux, Void Linux).
163-
if "${rootfsDir}/usr/bin/ldd" --version 2>&1 | grep -q musl ||
164-
strings "${rootfsDir}/usr/bin/ldd" 2>&1 | grep -q musl; then
165-
distroRid="linux-musl-${buildArch}"
166-
fi
166+
# Check for musl-based distros (e.g Alpine Linux, Void Linux).
167+
if "${rootfsDir}/usr/bin/ldd" --version 2>&1 | grep -q musl ||
168+
strings "${rootfsDir}/usr/bin/ldd" 2>&1 | grep -q musl; then
169+
distroRid="linux-musl-${buildArch}"
170+
fi
167171

168-
if [ -z "${distroRid}" ]; then
169-
if [ "$targetOs" = "Linux" ]; then
170-
distroRid="linux-$buildArch"
171-
elif [ "$targetOs" = "linux-bionic" ]; then
172-
distroRid="linux-bionic-$buildArch"
173-
elif [ "$targetOs" = "OSX" ]; then
174-
distroRid="osx-$buildArch"
175-
elif [ "$targetOs" = "MacCatalyst" ]; then
176-
distroRid="maccatalyst-$buildArch"
177-
elif [ "$targetOs" = "tvOS" ]; then
178-
distroRid="tvos-$buildArch"
179-
elif [ "$targetOs" = "tvOSSimulator" ]; then
180-
distroRid="tvossimulator-$buildArch"
181-
elif [ "$targetOs" = "iOS" ]; then
182-
distroRid="ios-$buildArch"
183-
elif [ "$targetOs" = "iOSSimulator" ]; then
184-
distroRid="iossimulator-$buildArch"
185-
elif [ "$targetOs" = "Android" ]; then
186-
distroRid="android-$buildArch"
187-
elif [ "$targetOs" = "Browser" ]; then
188-
distroRid="browser-$buildArch"
189-
elif [ "$targetOs" = "FreeBSD" ]; then
190-
distroRid="freebsd-$buildArch"
191-
elif [ "$targetOs" = "illumos" ]; then
192-
distroRid="illumos-$buildArch"
193-
elif [ "$targetOs" = "Solaris" ]; then
194-
distroRid="solaris-$buildArch"
172+
if [ -z "${distroRid}" ]; then
173+
if [ "$targetOs" = "Linux" ]; then
174+
distroRid="linux-$buildArch"
175+
elif [ "$targetOs" = "linux-bionic" ]; then
176+
distroRid="linux-bionic-$buildArch"
177+
elif [ "$targetOs" = "OSX" ]; then
178+
distroRid="osx-$buildArch"
179+
elif [ "$targetOs" = "MacCatalyst" ]; then
180+
distroRid="maccatalyst-$buildArch"
181+
elif [ "$targetOs" = "tvOS" ]; then
182+
distroRid="tvos-$buildArch"
183+
elif [ "$targetOs" = "tvOSSimulator" ]; then
184+
distroRid="tvossimulator-$buildArch"
185+
elif [ "$targetOs" = "iOS" ]; then
186+
distroRid="ios-$buildArch"
187+
elif [ "$targetOs" = "iOSSimulator" ]; then
188+
distroRid="iossimulator-$buildArch"
189+
elif [ "$targetOs" = "Android" ]; then
190+
distroRid="android-$buildArch"
191+
elif [ "$targetOs" = "Browser" ]; then
192+
distroRid="browser-$buildArch"
193+
elif [ "$targetOs" = "FreeBSD" ]; then
194+
distroRid="freebsd-$buildArch"
195+
elif [ "$targetOs" = "illumos" ]; then
196+
distroRid="illumos-$buildArch"
197+
elif [ "$targetOs" = "Solaris" ]; then
198+
distroRid="solaris-$buildArch"
199+
fi
195200
fi
196-
fi
197201

198-
__DistroRid="${distroRid}"
199-
export __DistroRid
202+
__DistroRid="${distroRid}"
203+
export __DistroRid
204+
fi
200205
fi
201206

202207
if [ -z "$__DistroRid" ]; then

src/native/corehost/corehost.proj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<BuildArgs Condition="'$(Ninja)' == 'true'">$(BuildArgs) -ninja</BuildArgs>
8282
<BuildArgs>$(BuildArgs) -runtimeflavor $(RuntimeFlavor)</BuildArgs>
8383
<BuildArgs Condition="'$(OfficialBuildId)' != ''">$(BuildArgs) /p:OfficialBuildId="$(OfficialBuildId)"</BuildArgs>
84+
<BuildArgs Condition="'$(PackageRid)' != ''">$(BuildArgs) -packagerid $(PackageRid)</BuildArgs>
8485
</PropertyGroup>
8586

8687
<!--

0 commit comments

Comments
 (0)