dotnet: rework RID management

This commit is contained in:
Mizux Seiha
2022-11-15 13:36:09 +01:00
parent 7293caad10
commit 80c098279d
3 changed files with 26 additions and 28 deletions

View File

@@ -44,25 +44,26 @@ endif()
set(DOTNET_PACKAGE Google.OrTools)
set(DOTNET_PACKAGES_DIR "${PROJECT_BINARY_DIR}/dotnet/packages")
# Runtime IDentifier
# see: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
set(DOTNET_PLATFORM arm64)
else()
set(DOTNET_PLATFORM x64)
endif()
if(APPLE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
set(RUNTIME_IDENTIFIER osx-arm64)
else()
set(RUNTIME_IDENTIFIER osx-x64)
endif()
set(DOTNET_RID osx-${DOTNET_PLATFORM})
elseif(UNIX)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
set(RUNTIME_IDENTIFIER linux-arm64)
else()
set(RUNTIME_IDENTIFIER linux-x64)
endif()
set(DOTNET_RID linux-${DOTNET_PLATFORM})
elseif(WIN32)
set(RUNTIME_IDENTIFIER win-x64)
set(DOTNET_RID win-${DOTNET_PLATFORM})
else()
message(FATAL_ERROR "Unsupported system !")
endif()
set(DOTNET_NATIVE_PROJECT ${DOTNET_PACKAGE}.runtime.${RUNTIME_IDENTIFIER})
message(STATUS ".Net RID: ${DOTNET_RID}")
set(DOTNET_NATIVE_PROJECT ${DOTNET_PACKAGE}.runtime.${DOTNET_RID})
message(STATUS ".Net runtime project: ${DOTNET_NATIVE_PROJECT}")
set(DOTNET_NATIVE_PROJECT_DIR ${PROJECT_BINARY_DIR}/dotnet/${DOTNET_NATIVE_PROJECT})
message(STATUS ".Net runtime project build path: ${DOTNET_NATIVE_PROJECT_DIR}")
@@ -71,12 +72,6 @@ message(STATUS ".Net runtime project build path: ${DOTNET_NATIVE_PROJECT_DIR}")
# see: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version
set(DOTNET_LANG "9.0")
message(STATUS ".Net C# language version: ${DOTNET_LANG}")
# see: Platform
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
set(DOTNET_PLATFORM arm64)
else()
set(DOTNET_PLATFORM x64)
endif()
# see: https://docs.microsoft.com/en-us/dotnet/standard/frameworks
if(USE_DOTNET_CORE_31 AND USE_DOTNET_6)

View File

@@ -3,7 +3,7 @@
<OutputType>Library</OutputType>
<LangVersion>@DOTNET_LANG@</LangVersion>
@DOTNET_TFM@
<RuntimeIdentifier>@RUNTIME_IDENTIFIER@</RuntimeIdentifier>
<RuntimeIdentifier>@DOTNET_RID@</RuntimeIdentifier>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>@DOTNET_PROJECT@</AssemblyName>
<Version>@PROJECT_VERSION@</Version>
@@ -101,12 +101,12 @@
<!-- Validate at least one runtime package has been generated -->
<Target Name="ValidateRuntimePackage" BeforeTargets="GenerateNuspec">
<ItemGroup>
<RuntimePackage Include="@DOTNET_PACKAGES_DIR@/@DOTNET_PROJECT@.runtime.@RUNTIME_IDENTIFIER@.*.nupkg"/>
<RuntimePackage Include="@DOTNET_PACKAGES_DIR@/@DOTNET_PROJECT@.runtime.@DOTNET_RID@.*.nupkg"/>
</ItemGroup>
<Message Importance="high" Text="------- $(OS)"/>
<Message Importance="high" Text="Package @DOTNET_PROJECT@.runtime.@RUNTIME_IDENTIFIER@: found" Condition="Exists('@(RuntimePackage)')"/>
<Message Importance="high" Text="Package @DOTNET_PROJECT@.runtime.@RUNTIME_IDENTIFIER@: not found" Condition="!Exists('@(RuntimePackage)')"/>
<Error Text="You must locally 'dotnet pack' the @DOTNET_PROJECT@.runtime.@RUNTIME_IDENTIFIER@ Project." Condition="!Exists('@(RuntimePackage)')"/>
<Message Importance="high" Text="Package @DOTNET_PROJECT@.runtime.@DOTNET_RID@: found" Condition="Exists('@(RuntimePackage)')"/>
<Message Importance="high" Text="Package @DOTNET_PROJECT@.runtime.@DOTNET_RID@: not found" Condition="!Exists('@(RuntimePackage)')"/>
<Error Text="You must locally 'dotnet pack' the @DOTNET_PROJECT@.runtime.@DOTNET_RID@ Project." Condition="!Exists('@(RuntimePackage)')"/>
</Target>
<!-- Copy all .proto file(s) -->
@@ -173,7 +173,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="@DOTNET_PROJECT@.runtime.@RUNTIME_IDENTIFIER@" Version="@PROJECT_VERSION@"/>
<PackageReference Include="@DOTNET_PROJECT@.runtime.@DOTNET_RID@" Version="@PROJECT_VERSION@"/>
</ItemGroup>
</Project>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
@DOTNET_TFM@
<RuntimeIdentifier>@RUNTIME_IDENTIFIER@</RuntimeIdentifier>
<RuntimeIdentifier>@DOTNET_RID@</RuntimeIdentifier>
<AssemblyName>google-ortools-native</AssemblyName>
<Version>@PROJECT_VERSION@</Version>
@@ -11,7 +11,7 @@
<IncludeBuildOutput>false</IncludeBuildOutput>
<!-- Pack Option -->
<Title>Google.OrTools @RUNTIME_IDENTIFIER@ v@PROJECT_VERSION@</Title>
<Title>Google.OrTools @DOTNET_RID@ v@PROJECT_VERSION@</Title>
<PackageId>@DOTNET_NATIVE_PROJECT@</PackageId>
<!-- Signing -->
@@ -24,8 +24,11 @@
<ItemGroup>
<!-- Native library must be in native directory... -->
<!-- If ortools is built as a STATIC_LIBRARY (e.g. Windows) then we don't have to include it -->
<Content Include="$<TARGET_FILE:google-ortools-native>$<$<STREQUAL:$<TARGET_PROPERTY:@PROJECT_NAME@,TYPE>,SHARED_LIBRARY>:;$<TARGET_SONAME_FILE:@PROJECT_NAME@>>">
<PackagePath>runtimes/@RUNTIME_IDENTIFIER@/native/%(Filename)%(Extension)</PackagePath>
<Content Include="
$<TARGET_FILE:google-ortools-native>
$<$<STREQUAL:$<TARGET_PROPERTY:@PROJECT_NAME@,TYPE>,SHARED_LIBRARY>:;$<TARGET_SONAME_FILE:@PROJECT_NAME@>>
">
<PackagePath>runtimes/@DOTNET_RID@/native/%(Filename)%(Extension)</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>