Skip to content

Instantly share code, notes, and snippets.

@kg
Created October 23, 2024 17:19
Show Gist options
  • Save kg/62e61e0a1933df014c9868038acf6c56 to your computer and use it in GitHub Desktop.
Save kg/62e61e0a1933df014c9868038acf6c56 to your computer and use it in GitHub Desktop.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<XNAPropertiesOverridePath>$(SolutionDir)XNA.Override.props</XNAPropertiesOverridePath>
</PropertyGroup>
<Import Project="$(XNAPropertiesOverridePath)" Condition="Exists('$(XNAPropertiesOverridePath)')" />
<PropertyGroup>
<!-- workaround for common typo in project files -->
<FNALibsPath Condition="'$(FNALibsPath)' == ''">$(FNALibPath)</FNALibsPath>
<!-- auto-sense FNA in nearby folders if no explicit path provided -->
<FNAPathWasAutoselected Condition="'$(FNAPath)' == ''">true</FNAPathWasAutoselected>
<FNALibsPathWasAutoselected Condition="'$(FNALibsPath)' == ''">true</FNALibsPathWasAutoselected>
<AutoPlatforms Condition="'$(AutoPlatforms)' == ''">false</AutoPlatforms>
</PropertyGroup>
<PropertyGroup Condition="'$(FNAPathWasAutoselected)' == 'true'">
<FNAPath Condition="Exists('$(ProjectDir)\FNA')">$(ProjectDir)\FNA</FNAPath>
<FNAPath Condition="Exists('$(ProjectDir)\..\FNA')">$(ProjectDir)\..\FNA</FNAPath>
<FNAPath Condition="Exists('$(SolutionDir)\FNA')">$(SolutionDir)\FNA</FNAPath>
<FNAPath Condition="Exists('$(SquaredPath)\..\FNA')">$(SquaredPath)\..\FNA</FNAPath>
</PropertyGroup>
<PropertyGroup Condition="'$(FNALibsPathWasAutoselected)' == 'true'">
<FNALibsPath Condition="Exists('$(FNAPath)\fnalibs')">$(FNAPath)\fnalibs</FNALibsPath>
<FNALibsPath Condition="Exists('$(ProjectDir)\fnalibs')">$(ProjectDir)\fnalibs</FNALibsPath>
<FNALibsPath Condition="Exists('$(ProjectDir)\..\fnalibs')">$(ProjectDir)\..\fnalibs</FNALibsPath>
<FNALibsPath Condition="Exists('$(SolutionDir)\fnalibs')">$(SolutionDir)\fnalibs</FNALibsPath>
<FNALibsPath Condition="Exists('$(FNAPath)\..\FNALibs')">$(FNAPath)\..\FNALibs</FNALibsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<AutoEnableFNA>false</AutoEnableFNA>
<AutoPlatformTarget>x86</AutoPlatformTarget>
<FNAPlatformTarget>x86</FNAPlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x64' ">
<AutoEnableFNA>false</AutoEnableFNA>
<AutoPlatformTarget>x64</AutoPlatformTarget>
<FNAPlatformTarget>x64</FNAPlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'FNA' ">
<AutoEnableFNA>true</AutoEnableFNA>
<AutoPlatformTarget>x86</AutoPlatformTarget>
<FNAPlatformTarget>x86</FNAPlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'FNA-x64' ">
<AutoEnableFNA>true</AutoEnableFNA>
<AutoPlatformTarget>x64</AutoPlatformTarget>
<FNAPlatformTarget>x64</FNAPlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(AutoPlatforms)' == 'true'">
<EnableFNA Condition="'$(EnableFNA)' == ''">$(AutoEnableFNA)</EnableFNA>
</PropertyGroup>
<PropertyGroup Condition="'$(AutoPlatforms)' != 'true'">
<EnableFNA Condition="'$(EnableFNA)' == ''">false</EnableFNA>
</PropertyGroup>
<PropertyGroup Condition="'$(EnableFNA)' == 'true'">
<DefineConstants>$(DefineConstants);FNA;SDL2</DefineConstants>
<PlatformTarget Condition=" '$(AutoPlatforms)' == 'true' ">$(AutoPlatformTarget)</PlatformTarget>
<ShaderCompilerDefines>$(ShaderCompilerDefines)/D FNA=1 /D XNA=0</ShaderCompilerDefines>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(FNAPath)\FNA.csproj">
<Project>{35253CE1-C864-4CD3-8249-4D1319748E8F}</Project>
<Name>FNA</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="$(FNALibsPath)\$(FNAPlatformTarget)\*.dll;$(FNALibsPath)\$(FNAPlatformTarget)\*.pdb" Condition="'$(OutputType)' != 'Library'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="ValidateFNAPaths" BeforeTargets="BeforeBuild">
<Message Text="Configuration: $(Configuration)" />
<Message Text="Platform: $(Platform)" />
<Message Text="No property overrides found at '$(XNAPropertiesOverridePath)'" Condition="!Exists('$(XNAPropertiesOverridePath)')" />
<Message Importance="High" Text="Loaded property overrides from '$(XNAPropertiesOverridePath)'" Condition="Exists('$(XNAPropertiesOverridePath)')" />
<Message Importance="High" Text="Automatic platforms enabled? $(AutoPlatforms)" />
<Message Importance="High" Condition="'$(AutoPlatforms)' == 'true'" Text="Automatic platforms selected FNA? $(AutoEnableFNA)" />
<Message Importance="High" Text="FNA enabled? $(EnableFNA)" />
<Message Importance="High" Condition="'$(EnableFNA)' == 'false'" Text="Automatically forcing x86 for XNA." />
<Message Importance="High" Condition="'$(EnableFNA)' == 'true'" Text="FNA path: '$(FNAPath)'" />
<Message Importance="High" Condition="'$(FNAPathWasAutoselected)' == 'true'" Text="FNA path was auto-selected" />
<Message Importance="High" Condition="'$(EnableFNA)' == 'true'" Text="FNAlibs path: '$(FNALibsPath)'" />
<Message Importance="High" Condition="'$(FNALibsPathWasAutoselected)' == 'true'" Text="FNALibs path was auto-selected" />
<Message Importance="High" Condition="'$(EnableFNA)' == 'true'" Text="Copying FNALibs from '$(FNALibsPath)\$(PlatformTarget)\*.dll'." />
<Error Text="EnableFNA is set and FNAPath could not be automatically detected after searching nearby folders." Condition=" ('$(FNAPath)' == '') And ('$(EnableFNA)' == 'true') " />
<Error Text="FNA3D.dll could not be found in the configured FNALibsPath\FNAPlatformTarget: '$(FNALibsPath)\$(FNAPlatformTarget)\FNA3D.dll'." Condition=" ('$(EnableFNA)' == 'true') And !Exists('$(FNALibsPath)\$(FNAPlatformTarget)\FNA3D.dll') " />
<Error Text="FNALibsPath '$(FNALibsPath)' does not exist or is not set" Condition=" !Exists('$(FNALibsPath)') And ('$(EnableFNA)' == 'true') " />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment