Skip to content
Permalink
Browse files

[Build] Use RuntimeIdentifier to separate graphics API runtimes

  • Loading branch information
xen2 committed Oct 29, 2018
1 parent 3a4e324 commit 78b6d2d6090f705f2c9c4e9f22a849a9f4bcbc1f
@@ -212,6 +212,7 @@
<ItemGroup>
<_XenkoDepsFile Include="@(ReferencePath->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<_XenkoDepsFile Include="@(ReferenceDependencyPaths->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<None Include="@(_XenkoDepsFile)" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>

@@ -136,14 +136,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xenko.Engine", "..\sources\
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xenko.Graphics", "..\sources\engine\Xenko.Graphics\Xenko.Graphics.csproj", "{FB06C76A-6BB7-40BE-9AFA-FEC13B045FB5}"
ProjectSection(ProjectDependencies) = postProject
{1E54A9A2-4439-4444-AE57-6D2ED3C0DC47} = {1E54A9A2-4439-4444-AE57-6D2ED3C0DC47}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xenko.Engine.Tests.Windows", "..\sources\engine\Xenko.Engine.Tests\Xenko.Engine.Tests.Windows.csproj", "{A8F8D125-7A22-489F-99BC-9A02F545A17F}"
ProjectSection(ProjectDependencies) = postProject
{39AE9C77-E94B-404F-8768-B6261B3C1E0E} = {39AE9C77-E94B-404F-8768-B6261B3C1E0E}
{50D1A3BB-4B41-4EF5-8D2F-3618A3B6C698} = {50D1A3BB-4B41-4EF5-8D2F-3618A3B6C698}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xenko.Input.Tests.Windows", "..\sources\engine\Xenko.Input.Tests\Xenko.Input.Tests.Windows.csproj", "{01700344-CF44-482C-BEBC-60213B0F844C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xenko.Input.Tests.Windows", "..\sources\engine\Xenko.Input.Tests\Xenko.Input.Tests.Windows.csproj", "{01700344-CF44-482C-BEBC-60213B0F844C}"
ProjectSection(ProjectDependencies) = postProject
{84DEB606-77ED-49CD-9AED-D2B13C1F5A1E} = {84DEB606-77ED-49CD-9AED-D2B13C1F5A1E}
{1677B922-CCF0-44DE-B57E-1CDD3D2B8E8A} = {1677B922-CCF0-44DE-B57E-1CDD3D2B8E8A}
@@ -155,7 +158,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xenko.Input.Tests.Windows",
{42780CBD-3FE7-48E3-BD5B-59945EA20137} = {42780CBD-3FE7-48E3-BD5B-59945EA20137}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xenko.Core.Tests", "..\sources\core\Xenko.Core.Tests\Xenko.Core.Tests.csproj", "{5AA408BA-E766-453E-B661-E3D7EC46E2A6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xenko.Core.Tests", "..\sources\core\Xenko.Core.Tests\Xenko.Core.Tests.csproj", "{5AA408BA-E766-453E-B661-E3D7EC46E2A6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Xenko.Importer.FBX", "..\sources\tools\Xenko.Importer.FBX\Xenko.Importer.FBX.vcxproj", "{0467D515-FD66-4B8A-A128-CB642C2ED03F}"
EndProject
@@ -185,7 +188,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xenko.TextureConverter.Test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xenko.ProjectGenerator", "..\sources\tools\Xenko.ProjectGenerator\Xenko.ProjectGenerator.csproj", "{4B299721-18EA-4B6D-AFD5-2D6E188B97BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xenko.Audio.Tests.Windows", "..\sources\engine\Xenko.Audio.Tests\Xenko.Audio.Tests.Windows.csproj", "{7AF4B563-AAD3-42FF-B91E-84B9D34D904A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xenko.Audio.Tests.Windows", "..\sources\engine\Xenko.Audio.Tests\Xenko.Audio.Tests.Windows.csproj", "{7AF4B563-AAD3-42FF-B91E-84B9D34D904A}"
ProjectSection(ProjectDependencies) = postProject
{50D1A3BB-4B41-4EF5-8D2F-3618A3B6C698} = {50D1A3BB-4B41-4EF5-8D2F-3618A3B6C698}
EndProjectSection
@@ -3933,6 +3936,7 @@ Global
{6F473FA6-4F8B-4FBA-AE33-EE5AF997D50C} = {1AE1AC60-5D2F-4CA7-AE20-888F44551185}
{4A15BAAD-AA37-4754-A2BF-8D4049211E36} = {1AE1AC60-5D2F-4CA7-AE20-888F44551185}
{1AC70118-C90F-4EC6-9D8B-C628BDF900F7} = {4C142567-C42B-40F5-B092-798882190209}
{2FCA2D8B-B10F-4DCA-9847-4221F74BA586} = {5D2D3BE8-9910-45CA-8E45-95660DA4C563}
{C121A566-555E-42B9-9B0A-1696529A9088} = {4C142567-C42B-40F5-B092-798882190209}
{FB06C76A-6BB7-40BE-9AFA-FEC13B045FB5} = {4C142567-C42B-40F5-B092-798882190209}
{A8F8D125-7A22-489F-99BC-9A02F545A17F} = {A7ED9F01-7D78-4381-90A6-D50E51C17250}
@@ -3975,7 +3979,6 @@ Global
{50D1A3BB-4B41-4EF5-8D2F-3618A3B6C698} = {A2A4342E-024B-4063-B10C-1DA96CA3046D}
{7DBC5A0B-76F5-4D9E-9798-540DA214099C} = {860946E4-CC77-4FDA-A4FD-3DB2A502A696}
{117BF9F8-D2D9-4D32-9702-251C3E038090} = {A47B451D-3162-410F-BAF7-C650C4B7A4B0}
{2FCA2D8B-B10F-4DCA-9847-4221F74BA586} = {5D2D3BE8-9910-45CA-8E45-95660DA4C563}
{C904D2C6-5A15-4E0B-8432-33967E1735AA} = {F765035E-F4F4-4CFA-BA02-755DC677AA97}
{49AAA22D-D1C8-4E0F-82E8-F462D5442463} = {52AE329E-B588-40D0-A578-8D0DB1BD83E5}
{BB9DEEEF-F18C-40D8-B016-6434CC71B8C3} = {4C142567-C42B-40F5-B092-798882190209}
@@ -48,7 +48,7 @@ internal static void __Initialize__()
{
new LibraryDependency
{
LibraryRange = new LibraryRange(Assembly.GetEntryAssembly().GetName().Name, new VersionRange(new NuGetVersion(XenkoVersion.NuGetVersion)), LibraryDependencyTarget.Package),
LibraryRange = new LibraryRange(Assembly.GetExecutingAssembly().GetName().Name, new VersionRange(new NuGetVersion(XenkoVersion.NuGetVersion)), LibraryDependencyTarget.Package),
}
},
TargetFrameworks =
@@ -68,6 +68,7 @@ internal static void __Initialize__()
var request = new RestoreRequest(spec, provider, context, logger)
{
LockFilePath = "project.lock.json",
RequestedRuntimes = { "win7-d3d11" },
};

var command = new RestoreCommand(request);
@@ -82,7 +83,9 @@ internal static void __Initialize__()
{
foreach (var file in library.Files)
{
if (file.StartsWith("lib/net"))
var extension = Path.GetExtension(file).ToLowerInvariant();
if ((file.StartsWith("runtimes/win-d3d11/lib/net") || file.StartsWith("lib/net"))
&& (extension == ".dll" || extension == ".exe"))
{
assemblies.Add(Path.Combine(installPath, library.Path, file));
}
@@ -42,7 +42,7 @@
<Target Name="XenkoRunAssemblyProcessor" DependsOnTargets="ResolveAssemblyReferences">
<WriteLinesToFile File="$(IntermediateOutputPath)XenkoReferences.cache" Lines="@(ReferencePath)" Overwrite="true" />
<ItemGroup>
<XenkoAddReference Include="@(ReferencePath)" Condition="'%(ReferencePath.ExternallyResolved)' == 'true'" />
<XenkoAddReference Include="@(ReferencePath)" Condition="'%(ReferencePath.ExternallyResolved)' == 'true' Or '%(ReferencePath.BuildReference)' == 'true'" />
</ItemGroup>
<PropertyGroup>
<XenkoAssemblyProcessorOptions Condition="'$(XenkoAssemblyProcessorOptions)' == ''">--auto-notify-property --parameter-key --auto-module-initializer --serialization</XenkoAssemblyProcessorOptions>
@@ -66,4 +66,67 @@
$(PrepareForRunDependsOn)
</PrepareForRunDependsOn>
</PropertyGroup>

<!--
*****************************************************************************************************************************
Dependencies reading (from .ssdeps)
Important: Please keep in sync with Xenko.Core.PostSettings.Dependencies.Targets
*****************************************************************************************************************************
-->
<!-- List dependency files from .ssdeps -->
<Target Name="_XenkoListDepsFiles" DependsOnTargets="ResolveAssemblyReferences;ResolvePackageAssets">
<ItemGroup>
<_XenkoDepsFile Include="@(ReferencePath->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<_XenkoDepsFile Include="@(ReferenceDependencyPaths->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<_XenkoDepsFile Include="@(RuntimeCopyLocalItems->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<None Include="@(_XenkoDepsFile)" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>

<!-- Note: this target Outputs are not real, used so that it gets expanded for each file
also, if _XenkoDepsFile is empty the target is still called so check for it -->
<Target Name="_XenkoBuildDependencies" DependsOnTargets="_XenkoListDepsFiles" Outputs="%(_XenkoDepsFile.Identity)">
<!-- Read dependencies from file -->
<ReadLinesFromFile File="%(_XenkoDepsFile.Identity)" Condition="'%(_XenkoDepsFile.Identity)' != ''">
<Output TaskParameter="Lines" ItemName="_XenkoDependencyLocal"/>
</ReadLinesFromFile>
<PropertyGroup>
<_XenkoSourceDir>%(_XenkoDepsFile.RootDir)%(_XenkoDepsFile.Directory)</_XenkoSourceDir>
</PropertyGroup>
<ItemGroup>
<_XenkoDependencyLocal>
<!-- Note: Using regex match rather than regex split or string split to avoid MSBuild MissingMethodException -->
<Type>$([System.Text.RegularExpressions.Regex]::Match('%(Identity)', `(.*);(.*);(.*)`).get_Groups().get_Item(1).ToString())</Type>
<SourcePath>$([System.Text.RegularExpressions.Regex]::Match('%(Identity)', `(.*);(.*);(.*)`).get_Groups().get_Item(2).ToString())</SourcePath>
<Link>$([System.Text.RegularExpressions.Regex]::Match('%(Identity)', `(.*);(.*);(.*)`).get_Groups().get_Item(3).ToString())</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</_XenkoDependencyLocal>
<_XenkoDependencyContent Include="@(_XenkoDependencyLocal->'$(_XenkoSourceDir)%(SourcePath)')" Condition="'%(_XenkoDependencyLocal.Type)' == 'Content'"/>
<_XenkoDependencyNativeLib Include="@(_XenkoDependencyLocal->'$(_XenkoSourceDir)%(SourcePath)')" Condition="'%(_XenkoDependencyLocal.Type)' == 'NativeLib'"/>
</ItemGroup>

<!-- Message -->
<Message Importance="Normal" Text="Detected dependency from %(_XenkoDepsFile.FileName)" Condition="'%(_XenkoDepsFile.Identity)' != ''"/>
<Message Importance="Normal" Text=" %(_XenkoDependencyLocal.Type): %(_XenkoDependencyLocal.Identity) => %(_XenkoDependencyLocal.Link)"/>

<!-- Cleanup so that _XenkoDependencyLocal is local -->
<ItemGroup>
<_XenkoDependencyLocal Remove="@(_XenkoDependencyLocal)"/>
</ItemGroup>
</Target>

<Target Name="_XenkoCopyContent" DependsOnTargets="_XenkoBuildDependencies" AfterTargets="ResolveAssemblyReferences">
<ItemGroup>
<Content Include="@(_XenkoDependencyContent)"/>
</ItemGroup>
</Target>

<!-- Copy native libraries to output -->
<Target Name="_XenkoSetupNativeLibraries" DependsOnTargets="_XenkoBuildDependencies" AfterTargets="ResolveAssemblyReferences" Condition="'$(XenkoPlatform)' == 'Windows'">
<ItemGroup>
<None Include="@(_XenkoDependencyNativeLib)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Target>
</Project>
@@ -652,8 +652,8 @@ protected override void DrawCore(RenderContext context, RenderDrawContext drawCo

for (var i = 0; i < 2; i++)
{
#if XENKO_GRAPHICS_API_DIRECT3D11 && XENKO_PLATFORM_UWP
if (drawContext.GraphicsDevice.Presenter is WindowsMixedRealityGraphicsPresenter graphicsPresenter)
#if XENKO_PLATFORM_UWP
if (GraphicsDevice.Platform == GraphicsPlatform.Direct3D11 && drawContext.GraphicsDevice.Presenter is WindowsMixedRealityGraphicsPresenter graphicsPresenter)
{
isWindowsMixedReality = true;

@@ -113,9 +113,7 @@ public static string ProductLocation

// This code is for backward compatibility only where the generated games
// would not explicitly create the context, but would just use a Winform
#if XENKO_PLATFORM_WINDOWS_DESKTOP
#if (XENKO_UI_WINFORMS || XENKO_UI_WPF)
/// <summary>
#if XENKO_PLATFORM_WINDOWS_DESKTOP && (XENKO_UI_WINFORMS || XENKO_UI_WPF) /// <summary>
/// Performs an implicit conversion from <see cref="Control"/> to <see cref="GameContextWinforms"/>.
/// </summary>
/// <param name="control">Winform control</param>
@@ -125,8 +123,9 @@ public static string ProductLocation
{
return new GameContextWinforms(control);
}
#endif

#if XENKO_GRAPHICS_API_OPENGL
#if (XENKO_PLATFORM_WINDOWS_DESKTOP || XENKO_PLATFORM_UNIX) && XENKO_GRAPHICS_API_OPENGL && XENKO_UI_OPENTK
/// <summary>
/// Performs an implicit conversion from <see cref="OpenTK.GameWindow"/> to <see cref="GameContextOpenTK"/>.
/// </summary>
@@ -137,8 +136,6 @@ public static string ProductLocation
{
return new GameContextOpenTK(gameWindow);
}
#endif
#endif
#endif
}

@@ -21,6 +21,26 @@
</When>
</Choose>
<Import Condition="$(XenkoUI.Contains('SDL'))" Project="..\..\targets\SDL.targets" />
<Choose>
<When Condition="$(XenkoUI.Contains('WINFORMS')) OR $(XenkoUI.Contains('WPF'))">
<ItemGroup>
<Reference Include="System.Windows.Forms" />
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition=" '$(XenkoGraphicsApi)' == 'OpenGL' Or '$(XenkoGraphicsApi)' == 'OpenGLES' ">
<Choose>
<When Condition=" '$(XenkoPlatform)' == 'Windows' ">
<ItemGroup>
<Reference Include="OpenTK" Private="True">
<HintPath>$(XenkoDependenciesDir)OpenTK\OpenTK.dll</HintPath>
</Reference>
</ItemGroup>
</When>
</Choose>
</When>
</Choose>
<ItemGroup>
<Compile Include="..\..\shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
@@ -1,4 +1,4 @@
<Project>
<Project>
<PropertyGroup>
<XenkoAssemblySign>true</XenkoAssemblySign>
<XenkoGraphicsApiDependent>true</XenkoGraphicsApiDependent>
@@ -22,6 +22,34 @@
</Choose>
<Import Condition="$(XenkoUI.Contains('SDL'))" Project="..\..\targets\SDL.targets" />
<Choose>
<When Condition=" '$(XenkoGraphicsApi)' == 'OpenGL' Or '$(XenkoGraphicsApi)' == 'OpenGLES' ">
<Choose>
<When Condition="('$(XenkoPlatform)' == 'Linux') or ('$(XenkoPlatform)' == 'macOS')">
<ItemGroup>
<Reference Include="OpenTK">
<HintPath Condition="'$(XenkoRuntime)' == ''">$(XenkoDependenciesDir)OpenTK\$(XenkoPlatform)\OpenTK.dll</HintPath>
<HintPath Condition="'$(XenkoRuntime)' != ''">$(XenkoDependenciesDir)OpenTK\$(XenkoRuntime)\$(XenkoPlatform)\OpenTK.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition=" '$(XenkoPlatform)' == 'Windows' ">
<ItemGroup>
<Reference Include="OpenTK">
<HintPath Condition="'$(XenkoRuntime)' == ''">$(XenkoDependenciesDir)OpenTK\OpenTK.dll</HintPath>
<HintPath Condition="'$(XenkoRuntime)' == 'CoreCLR'">$(XenkoDependenciesDir)OpenTK\$(XenkoRuntime)\$(XenkoPlatform)\OpenTK.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition=" '$(XenkoPlatform)' == 'Android' Or '$(XenkoPlatform)' == 'iOS' ">
<ItemGroup>
<Reference Include="OpenTK-1.1">
<HintPath Condition="'$(XenkoPlatform)' == 'Android'">$(XenkoDependenciesDir)OpenTK\Android\OpenTK-1.1.dll</HintPath>
<HintPath Condition="'$(XenkoPlatform)' == 'iOS'">$(XenkoDependenciesDir)OpenTK\iOS\OpenTK-1.1.dll</HintPath>
</Reference>
</ItemGroup>
</When>
</Choose>
</When>
<When Condition=" '$(XenkoGraphicsApi)' == 'Vulkan' ">
<Choose>
<When Condition=" '$(XenkoPlatform)' == 'Windows'">
@@ -195,6 +223,7 @@
<ProjectReference Include="..\Xenko.Native\Xenko.Native.csproj" />
<ProjectReference Include="..\Xenko.Shaders\Xenko.Shaders.csproj" />
<ProjectReference Include="..\Xenko\Xenko.csproj" />
<PackageReference Include="Microsoft.NETCore.Platforms" Version="2.1.1" />
<PackageReference Include="SharpDX.Direct3D11" Version="4.0.1" Condition="'$(XenkoGraphicsApi)' == 'Direct3D11'" />
<PackageReference Include="SharpDX.Direct3D12" Version="4.0.1" Condition="'$(XenkoGraphicsApi)' == 'Direct3D12'" />
<PackageReference Include="SharpDX.D3DCompiler" Version="4.0.1" Condition="'$(XenkoGraphicsApi)' == 'Direct3D11' Or '$(XenkoGraphicsApi)' == 'Direct3D12'" />
@@ -211,6 +240,7 @@
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="runtime.json" Pack="true" PackagePath="/" />
<None Include="Shaders.Bytecodes\CompileShaders.cmd" />
<None Include="Shaders.Bytecodes\Graphics.xkpkg" />
<None Include="Shaders.Bytecodes\Shaders.xkeffectlog" />
@@ -293,7 +323,9 @@
<Target Name="IncludeExtraAssemblies">
<ItemGroup>
<BuildOutputInPackage Include="$(OutputPath)SharpFont.dll" />
<BuildOutputInPackage Include="$(OutputPath)SDL2-CS.dll" />
<BuildOutputInPackage Include="$(OutputPath)SharpVulkan.dll" Condition=" '$(XenkoGraphicsApi)' == 'Vulkan' " />
<BuildOutputInPackage Include="$(OutputPath)OpenTK*.dll" Condition=" '$(XenkoGraphicsApi)' == 'OpenGL' " />
<BuildOutputInPackage Include="$(OutputPath)SDL2-CS.dll" Condition="$(XenkoUI.Contains('SDL'))" />
</ItemGroup>
</Target>
</Project>
@@ -0,0 +1,19 @@
{
"runtimes": {
"win": {
"#import": [
"win-d3d"
]
},
"win-d3d": {
"#import": [
"win"
]
},
"win-opengl": {
"#import": [
"win"
]
}
}
}
@@ -1,4 +1,4 @@
<Project>
<Project>
<PropertyGroup>
<XenkoAssemblySign>true</XenkoAssemblySign>
<XenkoGraphicsApiDependent>true</XenkoGraphicsApiDependent>
@@ -18,6 +18,13 @@
</When>
</Choose>
<Import Condition="$(XenkoUI.Contains('SDL'))" Project="..\..\targets\SDL.targets" />
<Choose>
<When Condition="$(XenkoUI.Contains('WINFORMS')) OR $(XenkoUI.Contains('WPF'))">
<ItemGroup>
<Reference Include="System.Windows.Forms" />
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Compile Include="..\..\shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>

0 comments on commit 78b6d2d

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