Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass TargetRid and SourceBuildNonPortable to the native scripts #74504

Merged
merged 22 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/SourceBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
<InnerBuildArgs>$(InnerBuildArgs) --verbosity $(LogVerbosity)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --nodereuse false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --warnAsError false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:PackageRid=$(TargetRid)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --distrorid $(TargetRid)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:NoPgoOptimize=true</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:KeepNativeSymbols=true</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:RuntimeOS=$(TargetRidWithoutPlatform)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:PortableBuild=$(SourceBuildPortable)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --portablebuild $(SourceBuildPortable)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:BuildDebPackage=false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:EnableNgenOptimization=false</InnerBuildArgs>
</PropertyGroup>
Expand Down
11 changes: 11 additions & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 " --distrorid <rid> Optional argument that overrides the target rid name."
echo " --projects <value> 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"
Expand Down Expand Up @@ -402,6 +403,16 @@ while [[ $# > 0 ]]; do
shift 1
;;

-distrorid)
if [ -z ${2+x} ]; then
echo "No value for distrorid is supplied. See help (--help) for supported values." 1>&2
exit 1
fi
__DistroRid="$(echo "$2" | tr "[:upper:]" "[:lower:]")"
arguments="$arguments /p:PackageRid=$__DistroRid"
tmds marked this conversation as resolved.
Show resolved Hide resolved
shift 2
;;

-portablebuild)
if [ -z ${2+x} ]; then
echo "No value for portablebuild is supplied. See help (--help) for supported values." 1>&2
Expand Down
11 changes: 11 additions & 0 deletions eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ usage()
echo "-gccx.y: optional argument to build using gcc version x.y."
echo "-ninja: target ninja instead of GNU make"
echo "-numproc: set the number of build processes."
echo "-distrorid: 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 "-keepnativesymbols: keep native/unmanaged debug symbols."
Expand Down Expand Up @@ -396,6 +397,16 @@ while :; do
__TargetArch=wasm
;;

distrorid|-distrorid)
if [[ -n "$2" ]]; then
__DistroRid="$2"
shift
else
echo "ERROR: 'distrorid' requires a non-empty option argument"
exit 1
fi
;;

ppc64le|-ppc64le)
__TargetArch=ppc64le
;;
Expand Down
112 changes: 57 additions & 55 deletions eng/native/init-distro-rid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,72 +137,74 @@ initDistroRidGlobal()
rootfsDir="$4"
fi

if [ -n "${rootfsDir}" ]; then
# We may have a cross build. Check for the existence of the rootfsDir
if [ ! -e "${rootfsDir}" ]; then
echo "Error rootfsDir has been passed, but the location is not valid."
exit 1
if [ -z "${__DistroRid:-}" ]; then
if [ -n "${rootfsDir}" ]; then
# We may have a cross build. Check for the existence of the rootfsDir
if [ ! -e "${rootfsDir}" ]; then
echo "Error rootfsDir has been passed, but the location is not valid."
exit 1
fi
fi
fi

initNonPortableDistroRid "${targetOs}" "${buildArch}" "${isPortable}" "${rootfsDir}"
initNonPortableDistroRid "${targetOs}" "${buildArch}" "${isPortable}" "${rootfsDir}"

if [ "$buildArch" = "wasm" ]; then
__DistroRid=browser-wasm
export __DistroRid
fi
if [ "$buildArch" = "wasm" ]; then
__DistroRid=browser-wasm
export __DistroRid
fi

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

__PortableBuild=1
export __PortableBuild
local distroRid=""
__PortableBuild=1
export __PortableBuild
local distroRid=""

# Check for musl-based distros (e.g Alpine Linux, Void Linux).
if "${rootfsDir}/usr/bin/ldd" --version 2>&1 | grep -q musl ||
strings "${rootfsDir}/usr/bin/ldd" 2>&1 | grep -q musl; then
distroRid="linux-musl-${buildArch}"
fi
# Check for musl-based distros (e.g Alpine Linux, Void Linux).
if "${rootfsDir}/usr/bin/ldd" --version 2>&1 | grep -q musl ||
strings "${rootfsDir}/usr/bin/ldd" 2>&1 | grep -q musl; then
distroRid="linux-musl-${buildArch}"
fi

if [ -z "${distroRid}" ]; then
if [ "$targetOs" = "Linux" ]; then
distroRid="linux-$buildArch"
elif [ "$targetOs" = "linux-bionic" ]; then
distroRid="linux-bionic-$buildArch"
elif [ "$targetOs" = "OSX" ]; then
distroRid="osx-$buildArch"
elif [ "$targetOs" = "MacCatalyst" ]; then
distroRid="maccatalyst-$buildArch"
elif [ "$targetOs" = "tvOS" ]; then
distroRid="tvos-$buildArch"
elif [ "$targetOs" = "tvOSSimulator" ]; then
distroRid="tvossimulator-$buildArch"
elif [ "$targetOs" = "iOS" ]; then
distroRid="ios-$buildArch"
elif [ "$targetOs" = "iOSSimulator" ]; then
distroRid="iossimulator-$buildArch"
elif [ "$targetOs" = "Android" ]; then
distroRid="android-$buildArch"
elif [ "$targetOs" = "Browser" ]; then
distroRid="browser-$buildArch"
elif [ "$targetOs" = "FreeBSD" ]; then
distroRid="freebsd-$buildArch"
elif [ "$targetOs" = "illumos" ]; then
distroRid="illumos-$buildArch"
elif [ "$targetOs" = "Solaris" ]; then
distroRid="solaris-$buildArch"
if [ -z "${distroRid}" ]; then
if [ "$targetOs" = "Linux" ]; then
distroRid="linux-$buildArch"
elif [ "$targetOs" = "linux-bionic" ]; then
distroRid="linux-bionic-$buildArch"
elif [ "$targetOs" = "OSX" ]; then
distroRid="osx-$buildArch"
elif [ "$targetOs" = "MacCatalyst" ]; then
distroRid="maccatalyst-$buildArch"
elif [ "$targetOs" = "tvOS" ]; then
distroRid="tvos-$buildArch"
elif [ "$targetOs" = "tvOSSimulator" ]; then
distroRid="tvossimulator-$buildArch"
elif [ "$targetOs" = "iOS" ]; then
distroRid="ios-$buildArch"
elif [ "$targetOs" = "iOSSimulator" ]; then
distroRid="iossimulator-$buildArch"
elif [ "$targetOs" = "Android" ]; then
distroRid="android-$buildArch"
elif [ "$targetOs" = "Browser" ]; then
distroRid="browser-$buildArch"
elif [ "$targetOs" = "FreeBSD" ]; then
distroRid="freebsd-$buildArch"
elif [ "$targetOs" = "illumos" ]; then
distroRid="illumos-$buildArch"
elif [ "$targetOs" = "Solaris" ]; then
distroRid="solaris-$buildArch"
fi
fi
fi

__DistroRid="${distroRid}"
export __DistroRid
fi
__DistroRid="${distroRid}"
fi

if [ -z "$__DistroRid" ]; then
echo "DistroRid is not set. This is almost certainly an error"
exit 1
if [ -z "$__DistroRid" ]; then
echo "DistroRid is not set. This is almost certainly an error"
exit 1
fi
fi

export __DistroRid
echo "__DistroRid: ${__DistroRid}"
}
1 change: 1 addition & 0 deletions src/native/corehost/corehost.proj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<BuildArgs Condition="'$(Ninja)' == 'true'">$(BuildArgs) -ninja</BuildArgs>
<BuildArgs>$(BuildArgs) -runtimeflavor $(RuntimeFlavor)</BuildArgs>
<BuildArgs Condition="'$(OfficialBuildId)' != ''">$(BuildArgs) /p:OfficialBuildId="$(OfficialBuildId)"</BuildArgs>
<BuildArgs Condition="'$(OutputRid)' != ''">$(BuildArgs) -distrorid $(OutputRid)</BuildArgs>
tmds marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<!--
Expand Down