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

Consolidate RID and native file naming in MSBuild scripts #43804

Merged
3 commits merged into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<WasmAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmAppBuilder', 'Debug', '$(NetCoreAppCurrent)', 'publish'))</WasmAppBuilderDir>
<WasmBuildTasksDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmBuildTasks', 'Debug', '$(NetCoreAppCurrent)', 'publish'))</WasmBuildTasksDir>
<MonoAOTCompilerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'MonoAOTCompiler', 'Debug', '$(NetCoreAppCurrent)'))</MonoAOTCompilerDir>

<AppleAppBuilderTasksAssemblyPath>$([MSBuild]::NormalizePath('$(AppleAppBuilderDir)', 'AppleAppBuilder.dll'))</AppleAppBuilderTasksAssemblyPath>
<AndroidAppBuilderTasksAssemblyPath>$([MSBuild]::NormalizePath('$(AndroidAppBuilderDir)', 'AndroidAppBuilder.dll'))</AndroidAppBuilderTasksAssemblyPath>
<WasmAppBuilderTasksAssemblyPath>$([MSBuild]::NormalizePath('$(WasmAppBuilderDir)', 'WasmAppBuilder.dll'))</WasmAppBuilderTasksAssemblyPath>
Expand Down Expand Up @@ -105,8 +105,6 @@
</PropertyGroup>

<PropertyGroup>
<!-- Default to portable build if not explicitly set -->
<PortableBuild Condition="'$(PortableBuild)' == ''">true</PortableBuild>
<!-- Default to discarding symbols if not explicitly set -->
<KeepNativeSymbols Condition="'$(KeepNativeSymbols)' == ''">false</KeepNativeSymbols>
<!-- Used for launchSettings.json and runtime config files. -->
Expand Down
112 changes: 109 additions & 3 deletions eng/Configurations.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
steps and in the repository.
-->

<PropertyGroup>
<!-- Default to portable build if not explicitly set -->
<PortableBuild Condition="'$(PortableBuild)' == ''">true</PortableBuild>
</PropertyGroup>

<PropertyGroup>
<LibrariesProjectRoot>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'libraries'))</LibrariesProjectRoot>
<CoreClrProjectRoot>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'coreclr'))</CoreClrProjectRoot>
Expand Down Expand Up @@ -49,9 +54,6 @@
</PropertyGroup>

<PropertyGroup>
<HostRuntimeIdentifier Condition="'$(HostRuntimeIdentifier)' == '' and '$(MSBuildRuntimeType)' == 'core'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</HostRuntimeIdentifier>
<HostRuntimeIdentifier Condition="'$(HostRuntimeIdentifier)' == '' and '$(MSBuildRuntimeType)' != 'core'">win-$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant)</HostRuntimeIdentifier>

<TargetOS Condition="'$(TargetOS)' == '' and $([MSBuild]::IsOSPlatform('OSX'))">OSX</TargetOS>
<TargetOS Condition="'$(TargetOS)' == '' and $([MSBuild]::IsOSPlatform('FREEBSD'))">FreeBSD</TargetOS>
<TargetOS Condition="'$(TargetOS)' == '' and $([MSBuild]::IsOSPlatform('NETBSD'))">NetBSD</TargetOS>
Expand All @@ -68,6 +70,108 @@
<TargetsMobile Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'Android' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'Browser'">true</TargetsMobile>
</PropertyGroup>

<PropertyGroup Label="CalculateOS">
<_runtimeOS>$(RuntimeOS)</_runtimeOS>

<_parseDistroRid>$(__DistroRid)</_parseDistroRid>
<_parseDistroRid Condition="'$(_parseDistroRid)' == ''">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</_parseDistroRid>
<_distroRidIndex>$(_parseDistroRid.LastIndexOfAny("-"))</_distroRidIndex>

<_runtimeOS Condition="'$(_runtimeOS)' == ''">$(_parseDistroRid.SubString(0, $(_distroRidIndex)))</_runtimeOS>

<!-- _runtimeOS is calculated based on the build system OS, however if building for Browser/iOS/Android we need to let
the build system to use browser/ios/android as the _runtimeOS for produced package RIDs. -->
<_runtimeOS Condition="'$(TargetsMobile)' == 'true'">$(TargetOS.ToLowerInvariant())</_runtimeOS>

<_runtimeOSVersionIndex>$(_runtimeOS.IndexOfAny(".-0123456789"))</_runtimeOSVersionIndex>
<_runtimeOSFamily Condition="'$(_runtimeOSVersionIndex)' != '-1'">$(_runtimeOS.SubString(0, $(_runtimeOSVersionIndex)))</_runtimeOSFamily>

<_buildingInOSX>$([MSBuild]::IsOSPlatform('OSX'))</_buildingInOSX>
<_portableOS>linux</_portableOS>
<_portableOS Condition="'$(_runtimeOS)' == 'linux-musl'">linux-musl</_portableOS>
<_portableOS Condition="$(_buildingInOSX)">osx</_portableOS>
<_portableOS Condition="'$(_runtimeOSFamily)' == 'win' or '$(TargetOS)' == 'windows'">win</_portableOS>
<_portableOS Condition="'$(_runtimeOSFamily)' == 'FreeBSD'">freebsd</_portableOS>
<_portableOS Condition="'$(_runtimeOSFamily)' == 'illumos'">illumos</_portableOS>
<_portableOS Condition="'$(_runtimeOSFamily)' == 'Solaris'">solaris</_portableOS>
<_portableOS Condition="'$(_runtimeOS)' == 'Browser'">browser</_portableOS>
<_portableOS Condition="'$(_runtimeOS)' == 'ios'">ios</_portableOS>
<_portableOS Condition="'$(_runtimeOS)' == 'tvos'">tvos</_portableOS>
<_portableOS Condition="'$(_runtimeOS)' == 'android'">android</_portableOS>

<_runtimeOS Condition="$(_runtimeOS.StartsWith('tizen'))">linux</_runtimeOS>
<_runtimeOS Condition="'$(PortableBuild)' == 'true'">$(_portableOS)</_runtimeOS>

<!-- support cross-targeting by choosing a RID to restore when running on a different machine that what we're build for -->
<_portableOS Condition="'$(TargetOS)' == 'Unix' and '$(_runtimeOSFamily)' != 'osx' and '$(_runtimeOSFamily)' != 'FreeBSD' and '$(_runtimeOS)' != 'linux-musl' and '$(_runtimeOSFamily)' != 'illumos' and '$(_runtimeOSFamily)' != 'Solaris'">linux</_portableOS>
</PropertyGroup>

<PropertyGroup Label="CalculateArch">
<_hostArch>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant)</_hostArch>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'arm'">arm</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'arm64'">arm64</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(TargetOS)' == 'Browser'">wasm</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(TargetsMobile)' == 'true'">x64</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
</PropertyGroup>

<PropertyGroup Label="CalculateRID">
<_toolRuntimeRID Condition="'$(BuildingInsideVisualStudio)' == 'true'">$(_runtimeOS)-x64</_toolRuntimeRID>
<_toolRuntimeRID Condition="'$(_toolRuntimeRID)' == ''">$(_runtimeOS)-$(_hostArch)</_toolRuntimeRID>
<!-- We build linux-musl-arm on a ubuntu container, so we can't use the toolset build for alpine runtime. We need to use portable linux RID for our toolset in order to be able to use it. -->
<_toolRuntimeRID Condition="'$(_runtimeOS)' == 'linux-musl' and $(TargetArchitecture.StartsWith('arm')) and !$(_hostArch.StartsWith('arm'))">linux-x64</_toolRuntimeRID>

<!-- There are no WebAssembly tools, so use the default ones -->
<_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and '$(TargetOS)' == 'windows'">win-x64</_toolRuntimeRID>
<_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and '$(TargetOS)' != 'windows' and $(_buildingInOSX)">osx-x64</_toolRuntimeRID>
<_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and '$(TargetOS)' != 'windows' and !$(_buildingInOSX)">linux-x64</_toolRuntimeRID>

<!-- There are no Android tools, so use the default ones -->
<_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and '$(TargetOS)' == 'windows'">win-x64</_toolRuntimeRID>
<_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and '$(TargetOS)' != 'windows' and $(_buildingInOSX)">osx-x64</_toolRuntimeRID>
<_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and '$(TargetOS)' != 'windows' and !$(_buildingInOSX)">linux-x64</_toolRuntimeRID>

<!-- There are no iOS or tvOS tools and it can be built on OSX only, so use that -->
<_toolRuntimeRID Condition="'$(_runtimeOS)' == 'ios' or '$(_runtimeOS)' == 'tvos'">osx-x64</_toolRuntimeRID>
<MicrosoftNetCoreIlasmPackageRuntimeId>$(_toolRuntimeRID)</MicrosoftNetCoreIlasmPackageRuntimeId>

<_packageRID Condition="'$(PortableBuild)' == 'true'">$(_portableOS)-$(TargetArchitecture)</_packageRID>
<PackageRID Condition="'$(PackageRID)' == ''">$(_packageRID)</PackageRID>
<PackageRID Condition="'$(PackageRID)' == ''">$(_runtimeOS)-$(TargetArchitecture)</PackageRID>

<_outputRID Condition="'$(TargetOS)' == 'windows'">win-$(TargetArchitecture)</_outputRID>
<_outputRID Condition="'$(TargetOS)' == 'OSX'">osx-$(TargetArchitecture)</_outputRID>
<_outputRID Condition="'$(TargetOS)' == 'Linux'">linux-$(TargetArchitecture)</_outputRID>
<_outputRID Condition="'$(TargetOS)' == 'FreeBSD'">freebsd-$(TargetArchitecture)</_outputRID>
<_outputRID Condition="'$(TargetOS)' == 'NetBSD'">netbsd-$(TargetArchitecture)</_outputRID>
<_outputRID Condition="'$(TargetOS)' == 'illumos'">illumos-$(TargetArchitecture)</_outputRID>
<_outputRID Condition="'$(TargetOS)' == 'Solaris'">solaris-$(TargetArchitecture)</_outputRID>
<_outputRID Condition="'$(TargetOS)' == 'iOS'">ios-$(TargetArchitecture)</_outputRID>
<_outputRID Condition="'$(TargetOS)' == 'tvOS'">tvos-$(TargetArchitecture)</_outputRID>
<_outputRID Condition="'$(TargetOS)' == 'Android'">android-$(TargetArchitecture)</_outputRID>
<_outputRID Condition="'$(TargetOS)' == 'Browser'">browser-$(TargetArchitecture)</_outputRID>

<OutputRid Condition="'$(OutputRid)' == ''">$(PackageRID)</OutputRid>
<OutputRid Condition="'$(PortableBuild)' == 'true'">$(_outputRID)</OutputRid>
</PropertyGroup>

<PropertyGroup Label="CalculateTargetOSName" Condition="'$(SkipInferTargetOSName)' != 'true'">
<TargetsFreeBSD Condition="'$(TargetOS)' == 'FreeBSD'">true</TargetsFreeBSD>
<Targetsillumos Condition="'$(TargetOS)' == 'illumos'">true</Targetsillumos>
<TargetsSolaris Condition="'$(TargetOS)' == 'Solaris'">true</TargetsSolaris>
<TargetsLinux Condition="'$(TargetOS)' == 'Linux' or '$(TargetOS)' == 'Android'">true</TargetsLinux>
<TargetsNetBSD Condition="'$(TargetOS)' == 'NetBSD'">true</TargetsNetBSD>
<TargetsOSX Condition="'$(TargetOS)' == 'OSX'">true</TargetsOSX>
<TargetsiOS Condition="'$(TargetOS)' == 'iOS'">true</TargetsiOS>
<TargetstvOS Condition="'$(TargetOS)' == 'tvOS'">true</TargetstvOS>
<TargetsiOSSimulator Condition="'$(TargetsiOS)' == 'true' and ('$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'x86')">true</TargetsiOSSimulator>
<TargetstvOSSimulator Condition="'$(TargetstvOS)' == 'true' and '$(TargetArchitecture)' == 'x64'">true</TargetstvOSSimulator>
<TargetsAndroid Condition="'$(TargetOS)' == 'Android'">true</TargetsAndroid>
<TargetsBrowser Condition="'$(TargetOS)' == 'Browser'">true</TargetsBrowser>
<TargetsWindows Condition="'$(TargetOS)' == 'windows'">true</TargetsWindows>
<TargetsUnix Condition="'$(TargetsFreeBSD)' == 'true' or '$(Targetsillumos)' == 'true' or '$(TargetsSolaris)' == 'true' or '$(TargetsLinux)' == 'true' or '$(TargetsNetBSD)' == 'true' or '$(TargetsOSX)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true'">true</TargetsUnix>
</PropertyGroup>

<!--Feature switches -->
<PropertyGroup>
<EnableNgenOptimization Condition="'$(EnableNgenOptimization)' == '' and '$(Configuration)' == 'Release'">true</EnableNgenOptimization>
Expand All @@ -76,4 +180,6 @@
<!-- Turn off end of life target framework checks as we intentionally build older .NETCoreApp configurations. -->
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)native\naming.props" />
</Project>
10 changes: 2 additions & 8 deletions eng/native/init-distro-rid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ initNonPortableDistroRid()
#
# __DistroRid
# __PortableBuild
# __RuntimeId
#
initDistroRidGlobal()
{
Expand Down Expand Up @@ -194,13 +193,8 @@ initDistroRidGlobal()

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

exit 1
else
echo "__DistroRid: ${__DistroRid}"
echo "__RuntimeId: ${__DistroRid}"

__RuntimeId="${__DistroRid}"
export __RuntimeId
fi

echo "__DistroRid: ${__DistroRid}"
}
53 changes: 31 additions & 22 deletions eng/native/naming.props
Original file line number Diff line number Diff line change
@@ -1,45 +1,54 @@
<Project>
<PropertyGroup>
<StaticLibPrefix>lib</StaticLibPrefix>
</PropertyGroup>

<!-- Add path globs specific to native binaries to exclude unnecessary files from packages. -->
<Choose>
<When Condition=" '$(_runtimeOSFamily)' == 'win' OR $(RuntimeIdentifier.StartsWith('win')) ">
<When Condition="$(PackageRID.StartsWith('win'))">
<PropertyGroup>
<ApplicationFileExtension>.exe</ApplicationFileExtension>
<LibraryFilePrefix></LibraryFilePrefix>
<LibraryFileExtension>.dll</LibraryFileExtension>
<StaticLibraryFileExtension>.lib</StaticLibraryFileExtension>
<SymbolFileExtension>.pdb</SymbolFileExtension>
<ExeSuffix>.exe</ExeSuffix>
<LibSuffix>.dll</LibSuffix>
<StaticLibSuffix>.lib</StaticLibSuffix>
<SymbolsSuffix>.pdb</SymbolsSuffix>
</PropertyGroup>
</When>
<When Condition=" '$(_runtimeOSFamily)' == 'osx' or $(RuntimeIdentifier.StartsWith('osx')) or '$(_runtimeOSFamily)' == 'ios' or $(RuntimeIdentifier.StartsWith('ios'))">
<When Condition="$(PackageRID.StartsWith('osx'))">
<PropertyGroup>
<LibraryFilePrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibraryFilePrefix>
<LibraryFileExtension>.dylib</LibraryFileExtension>
<StaticLibraryFileExtension>.a</StaticLibraryFileExtension>
<SymbolFileExtension>.dwarf</SymbolFileExtension>
<LibPrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibPrefix>
<LibSuffix>.dylib</LibSuffix>
<StaticLibSuffix>.a</StaticLibSuffix>
<SymbolsSuffix>.dwarf</SymbolsSuffix>
</PropertyGroup>
</When>
<When Condition=" '$(_runtimeOSFamily)' == 'android' ">
<When Condition="$(PackageRID.StartsWith('android'))">
<PropertyGroup>
<LibraryFilePrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibraryFilePrefix>
<LibraryFileExtension>.so</LibraryFileExtension>
<StaticLibraryFileExtension>.a</StaticLibraryFileExtension>
<LibPrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibPrefix>
<LibSuffix>.so</LibSuffix>
<StaticLibSuffix>.a</StaticLibSuffix>
<!--symbols included in .so, like Linux, but can be generated externally and if so, uses .debug ext-->
<SymbolFileExtension>.debug</SymbolFileExtension>
<SymbolsSuffix>.debug</SymbolsSuffix>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<LibraryFilePrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibraryFilePrefix>
<LibraryFileExtension>.so</LibraryFileExtension>
<StaticLibraryFileExtension>.a</StaticLibraryFileExtension>
<SymbolFileExtension>.dbg</SymbolFileExtension>
<LibPrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibPrefix>
<LibSuffix>.so</LibSuffix>
<StaticLibSuffix>.a</StaticLibSuffix>
<SymbolsSuffix>.dbg</SymbolsSuffix>
</PropertyGroup>
</Otherwise>
</Choose>

<ItemGroup>
<AdditionalLibPackageExcludes Condition="'$(SymbolFileExtension)' != ''" Include="%2A%2A\%2A$(SymbolFileExtension)" />
<AdditionalSymbolPackageExcludes Condition="'$(LibraryFileExtension)' != ''" Include="%2A%2A\%2A.a;%2A%2A\%2A$(LibraryFileExtension)" />
<AdditionalLibPackageExcludes Condition="'$(SymbolsSuffix)' != ''" Include="%2A%2A\%2A$(SymbolsSuffix)" />
<AdditionalSymbolPackageExcludes Condition="'$(LibSuffix)' != ''" Include="%2A%2A\%2A.a;%2A%2A\%2A$(LibSuffix)" />
</ItemGroup>

<!-- arcade is using long name for this property; 'SymbolFileExtension'.
remove this property group when arcade is updated with short name (SymbolsSuffix). -->
<PropertyGroup>
<SymbolFileExtension>$(SymbolsSuffix)</SymbolFileExtension>
</PropertyGroup>

</Project>
16 changes: 0 additions & 16 deletions src/coreclr/dir.common.props
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,6 @@
<StableVersion Condition="'$(StabilizePackageVersion)' == 'true' and '$(StableVersion)' == ''">$(PackageVersion)</StableVersion>
</PropertyGroup>

<!-- Set up common target properties that we use to conditionally include sources -->
<PropertyGroup>
<TargetsFreeBSD Condition="'$(TargetOS)' == 'FreeBSD'">true</TargetsFreeBSD>
<TargetsLinux Condition="'$(TargetOS)' == 'Linux'">true</TargetsLinux>
<TargetsNetBSD Condition="'$(TargetOS)' == 'NetBSD'">true</TargetsNetBSD>
<Targetsillumos Condition="'$(TargetOS)' == 'illumos'">true</Targetsillumos>
<TargetsSolaris Condition="'$(TargetOS)' == 'Solaris'">true</TargetsSolaris>
<TargetsOSX Condition="'$(TargetOS)' == 'OSX'">true</TargetsOSX>
<TargetsWindows Condition="'$(TargetOS)' == 'windows'">true</TargetsWindows>

<TargetsUnix Condition="'$(TargetsFreeBSD)' == 'true' or '$(TargetsLinux)' == 'true' or '$(TargetsNetBSD)' == 'true' or '$(TargetsOSX)' == 'true' or '$(Targetsillumos)' == 'true' or '$(TargetsSolaris)' == 'true'">true</TargetsUnix>

<!-- We are only tracking Linux Distributions for Nuget RID mapping -->
<DistroRid Condition="'$(TargetsLinux)' == 'true'">$(__DistroRid)</DistroRid>
</PropertyGroup>

<!-- Set the kind of PDB to Portable -->
<PropertyGroup>
<DebugType Condition="'$(DebugType)' == ''">Portable</DebugType>
Expand Down
Loading