Skip to content
Permalink
Browse files

[Build] Properly fix how RuntimeIdentifier is used for multi graphics…

… API per platform
  • Loading branch information
xen2 committed Dec 12, 2018
1 parent ec0771e commit 2000eb74fb2a39634b5d3b387556e10a388f0740
@@ -56,7 +56,7 @@
<!--Compile assets for all XenkoPackage items and only for an executable-->
<Target Name="XenkoCompileAsset" Condition="'$(XenkoIsExecutable)' == 'true'">
<PropertyGroup>
<XenkoCompileAssetCommandProxy>$(XenkoCompileAssetCommandProxy) $(XenkoCompileAssetOptions) --disable-auto-compile --project-configuration &quot;$(Configuration)&quot; --platform=$(XenkoPlatform) --project-configuration=$(Configuration) --output-path=&quot;$(XenkoCompileAssetOutputPath)&quot; --build-path=&quot;$(XenkoCompileAssetBuildPath)&quot; --package-file=&quot;$(MSBuildProjectFullPath)&quot; --log-pipe=&quot;$(XenkoBuildEngineLogPipeUrl)&quot;</XenkoCompileAssetCommandProxy>
<XenkoCompileAssetCommandProxy>$(XenkoCompileAssetCommandProxy) $(XenkoCompileAssetOptions) --disable-auto-compile --project-configuration &quot;$(Configuration)&quot; --platform=$(XenkoPlatform) --project-configuration=$(Configuration) --property:RuntimeIdentifier=$(RuntimeIdentifier) --output-path=&quot;$(XenkoCompileAssetOutputPath)&quot; --build-path=&quot;$(XenkoCompileAssetBuildPath)&quot; --package-file=&quot;$(MSBuildProjectFullPath)&quot; --log-pipe=&quot;$(XenkoBuildEngineLogPipeUrl)&quot;</XenkoCompileAssetCommandProxy>
<XenkoCompileAssetCommandProxy Condition="'$(XenkoBuildEngineLogVerbose)' != ''">$(XenkoCompileAssetCommandProxy) --verbose</XenkoCompileAssetCommandProxy>
<XenkoCompileAssetCommandProxy Condition="'$(XenkoBuildEngineLogDebug)' != ''">$(XenkoCompileAssetCommandProxy) --debug</XenkoCompileAssetCommandProxy>
</PropertyGroup>
@@ -36,6 +36,21 @@ public static GraphicsPlatform GetGraphicsPlatform(this AssetCompilerContext con
if (context.OptionProperties.TryGetValue("XenkoGraphicsApi", out graphicsApi))
return (GraphicsPlatform)Enum.Parse(typeof(GraphicsPlatform), graphicsApi);

if (context.OptionProperties.TryGetValue("RuntimeIdentifier", out var runtimeIdentifier))
{
if (runtimeIdentifier.Contains("-d3d11"))
return GraphicsPlatform.Direct3D11;
else if (runtimeIdentifier.Contains("-d3d12"))
return GraphicsPlatform.Direct3D12;
// Note: testing opengles before opengl since one string contains another
else if (runtimeIdentifier.Contains("-opengles"))
return GraphicsPlatform.OpenGLES;
else if (runtimeIdentifier.Contains("-opengl"))
return GraphicsPlatform.OpenGL;
else if (runtimeIdentifier.Contains("-vulkan"))
return GraphicsPlatform.Vulkan;
}

// Ohterwise, use default as fallback
return context.Platform.GetDefaultGraphicsPlatform();
}
@@ -34,11 +34,15 @@
<XenkoRuntimeTargetFrameworks>$([MSBuild]::Unescape($(XenkoRuntimeTargetFrameworks.Trim(';'))))</XenkoRuntimeTargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition=" '$(XenkoRuntime)' == 'true' ">
<TargetFrameworks Condition="$(XenkoRuntimeTargetFrameworks.Contains(';'))">$(XenkoRuntimeTargetFrameworks)</TargetFrameworks>
<TargetFramework Condition="!$(XenkoRuntimeTargetFrameworks.Contains(';'))">$(XenkoRuntimeTargetFrameworks)</TargetFramework>
<PropertyGroup Condition=" '$(XenkoRuntime)' == 'true'">
<XenkoForceCrossTargeting Condition="$(XenkoRuntimeTargetFrameworks.Contains(';'))">true</XenkoForceCrossTargeting>
<!-- Should ideally go into non-Core targets (but we currently don't know XenkoPlatforms until PreSettings.Local is included) -->
<XenkoForceCrossTargeting Condition=" '$(XenkoGraphicsApiDependent)' == 'true' And '$(XenkoGraphicsApiDependentBuildAll)' == 'true' And ('$(XenkoPlatforms)' == 'Windows' Or '$(XenkoPlatforms)' == 'Linux')">true</XenkoForceCrossTargeting>

<TargetFrameworks Condition="'$(XenkoForceCrossTargeting)' == 'true'">$(XenkoRuntimeTargetFrameworks)</TargetFrameworks>
<TargetFramework Condition="'$(XenkoForceCrossTargeting)' != 'true'">$(XenkoRuntimeTargetFrameworks)</TargetFramework>
<!-- UpToDate check doesn't work with multi-TFM projects! https://github.com/dotnet/project-system/issues/2487 -->
<DisableFastUpToDateCheck Condition="$(TargetFrameworks.Contains(';'))">true</DisableFastUpToDateCheck>
<DisableFastUpToDateCheck Condition="'$(XenkoForceCrossTargeting)' == 'true'">true</DisableFastUpToDateCheck>
<!--<TargetFrameworks>net45;uap10.0;monoandroid50;xamarinios10;netstandard2.0</TargetFrameworks>-->
</PropertyGroup>

@@ -21,7 +21,7 @@

<!--Import global Xenko settings-->
<Import Project="$(MSBuildThisFileDirectory)..\targets\Xenko.Core.GlobalSettings.targets"/>

<!-- Include platform dependent assembly when specified -->
<PropertyGroup Condition="'$(XenkoGraphicsApiDependent)' == 'true' And '$(XenkoGraphicsApiDependentBuildAll)' == 'true'">
<RuntimeIdentifiers Condition="'$(TargetFramework)' == 'net45'">win7-d3d11;win7-d3d12;win7-opengl;win7-opengles;win7-vulkan</RuntimeIdentifiers>
@@ -38,15 +38,11 @@
<XenkoGraphicsApi Condition="'$(RuntimeIdentifier)' == 'win7-opengl'">OpenGL</XenkoGraphicsApi>
<XenkoGraphicsApi Condition="'$(RuntimeIdentifier)' == 'win7-opengles'">OpenGLES</XenkoGraphicsApi>
<XenkoGraphicsApi Condition="'$(RuntimeIdentifier)' == 'win7-vulkan'">Vulkan</XenkoGraphicsApi>

<XenkoGraphicsApi Condition="'$(RuntimeIdentifier)' == 'linux-opengl'">OpenGL</XenkoGraphicsApi>
<XenkoGraphicsApi Condition="'$(RuntimeIdentifier)' == 'linux-vulkan'">Vulkan</XenkoGraphicsApi>
</PropertyGroup>
<!-- Force cross-targeting if there is multiple runtime identifiers -->
<PropertyGroup Condition="$(RuntimeIdentifiers.Contains(';')) And '$(TargetFrameworks)' == ''">
<TargetFrameworks>$(TargetFramework)</TargetFrameworks>
<TargetFramework></TargetFramework>
</PropertyGroup>

<!-- Use default runtime as ref assembly -->
<PropertyGroup Condition="'$(RuntimeIdentifierDefault)' != '' And '$(RuntimeIdentifier)' == '$(RuntimeIdentifierDefault)'">
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);XenkoIncludeRefAssemblies</TargetsForTfmSpecificBuildOutput>

0 comments on commit 2000eb7

Please sign in to comment.
You can’t perform that action at this time.