stride/sources/targets/Stride.Core.props

247 строки
14 KiB
XML

<!-- Build file pre-included by all Stride projects -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Setup this part according to your project if you want your .csproj to compile individually without going through the .sln file -->
<PropertyGroup>
<SolutionName Condition=" '$(SolutionName)' == '' ">Stride</SolutionName>
</PropertyGroup>
<!-- Setup StridePlatform according to current TargetFramework -->
<PropertyGroup>
<StrideFramework>net8.0</StrideFramework>
<StrideFrameworkWindows>net8.0-windows</StrideFrameworkWindows>
<StrideFrameworkAndroid>net8.0-android</StrideFrameworkAndroid>
<StrideFrameworkiOS>net8.0-ios</StrideFrameworkiOS>
<StrideFrameworkUWP>uap10.0.16299</StrideFrameworkUWP>
<!-- Default values -->
<StridePlatformOriginal>$(StridePlatform)</StridePlatformOriginal>
<StridePlatform>Windows</StridePlatform>
<StridePlatform Condition=" '$([MSBuild]::IsOSPlatform(Linux))' Or '$(RuntimeIdentifier.StartsWith(linux))' ">Linux</StridePlatform>
<StridePlatform Condition=" $(RuntimeIdentifier.StartsWith('osx')) ">macOS</StridePlatform>
<StridePlatform Condition=" '$(TargetFramework)' == '$(StrideFrameworkUWP)' ">UWP</StridePlatform>
<StridePlatform Condition=" '$(TargetFramework)' == '$(StrideFrameworkAndroid)' ">Android</StridePlatform>
<StridePlatform Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' ">iOS</StridePlatform>
<StridePlatformFullName Condition="'$(StridePlatformFullName)' == ''">$(StridePlatform)</StridePlatformFullName>
<StridePlatformDeps Condition=" '$(TargetFramework)' == '$(StrideFramework)' Or '$(TargetFramework)' == '$(StrideFrameworkWindows)' ">dotnet</StridePlatformDeps>
<StridePlatformDeps Condition=" '$(TargetFramework)' == '$(StrideFrameworkUWP)' ">UWP</StridePlatformDeps>
<StridePlatformDeps Condition=" '$(TargetFramework)' == '$(StrideFrameworkAndroid)' ">Android</StridePlatformDeps>
<StridePlatformDeps Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' ">iOS</StridePlatformDeps>
</PropertyGroup>
<!--Import Local Pre Settings for the solution being loaded -->
<Import Project="$(MSBuildThisFileDirectory)..\..\build\$(SolutionName).Build.props" Condition="Exists('$(MSBuildThisFileDirectory)..\..\build\$(SolutionName).Build.props')" />
<Import Project="$(MSBuildThisFileDirectory)..\..\build\Stride.Core.Build.props" Condition="Exists('$(MSBuildThisFileDirectory)..\..\build\Stride.Core.Build.props')" />
<Import Project="$(MSBuildThisFileDirectory)Stride.Core.TargetFrameworks.Editor.props" />
<!--
Settings StridePlatform specific
-->
<PropertyGroup>
<StridePlatformDefines>STRIDE_PLATFORM_DESKTOP</StridePlatformDefines>
<!-- Note: ideally we would split using ItemGroup but then PropertyGroup are not properly evaluated if they contain ItemGroup (unless using Targets) -->
<StridePlatforms Condition="'$(StridePlatforms)' == ''">Windows</StridePlatforms>
<!-- Let's support escaped MSBuild variables, in case it was sent from Stride.build (not sure why but I couldn't make it work properly when passing to MSBuild.Properties) -->
<StridePlatforms>$([MSBuild]::Unescape('$(StridePlatforms)'))</StridePlatforms>
<_StridePlatforms>;$(StridePlatforms);</_StridePlatforms>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == '$(StrideFrameworkUWP)'">
<!-- Fixes for GetPackagingOutputs (note: not sure if still necessary) -->
<WindowsAppContainer>false</WindowsAppContainer>
<AppxPackage>false</AppxPackage>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<PropertyGroup Condition=" '$(StrideRuntime)' == 'true' ">
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<!-- Add net8.0 no matter what (needed for references) -->
<StrideRuntimeTargetFrameworks>net8.0</StrideRuntimeTargetFrameworks>
<StrideRuntimeTargetFrameworks Condition="$(_StridePlatforms.Contains(';Windows;')) And '$(StrideExplicitWindowsRuntime)' == 'true'">$(StrideRuntimeTargetFrameworks);net8.0-windows</StrideRuntimeTargetFrameworks>
<StrideRuntimeTargetFrameworks Condition="$(_StridePlatforms.Contains(';UWP;'))">$(StrideRuntimeTargetFrameworks);uap10.0.16299</StrideRuntimeTargetFrameworks>
<StrideRuntimeTargetFrameworks Condition="$(_StridePlatforms.Contains(';Android;'))">$(StrideRuntimeTargetFrameworks);net8.0-android</StrideRuntimeTargetFrameworks>
<StrideRuntimeTargetFrameworks Condition="$(_StridePlatforms.Contains(';iOS;'))">$(StrideRuntimeTargetFrameworks);net8.0-ios</StrideRuntimeTargetFrameworks>
<StrideRuntimeTargetFrameworks>$([MSBuild]::Unescape($(StrideRuntimeTargetFrameworks.Trim(';'))))</StrideRuntimeTargetFrameworks>
<TargetFrameworks>$(StrideRuntimeTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
<!-- Force a full Build & Pack if dependency was only built with a single TargetFramework (which would set IsInnerBuild and skip any Pack logic)
This is only a problem when building from command line, Visual Studio builds each project completely.
Recursion is automatically avoided by MSBuild not rebuilding same target
(we have to be careful to not introduce new global variables otherwise build becomes non-deterministic). -->
<Target Name="_StrideTriggerPackOnInnerBuild"
BeforeTargets="CoreCompile"
Condition="'$(BuildingInsideVisualStudio)' != 'true' And '$(GeneratePackageOnBuild)' == 'true'">
<MSBuild Projects="@(_MSBuildProjectReferenceExistent)"
Condition="'%(_MSBuildProjectReferenceExistent.SetTargetFramework)' != ''"
BuildInParallel="$(BuildInParallel)"
Targets="Build;Pack"
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove);TargetFramework;StrideGraphicsApi">
</MSBuild>
</Target>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<GenerateProjectSpecificOutputFolder>false</GenerateProjectSpecificOutputFolder>
<!-- Defines the language of the project being compiled CSharp or Cpp - defined by default to CSharp, must be overriden to Cpp in a Cpp project -->
<StrideProjectType Condition="'$(MSBuildProjectExtension)' == '.vcxproj'">Cpp</StrideProjectType>
<StrideProjectType Condition="'$(StrideProjectType)' == ''">CSharp</StrideProjectType>
<!-- Flag used per-project settings to specify that it should only be compiled on Windows Desktop-->
<StrideWindowsOnly Condition="'$(StrideWindowsOnly)' == ''">false</StrideWindowsOnly>
<StrideSdkTargets Condition="'$(StrideSdkTargets)' == ''">$(MSBuildThisFileDirectory)Stride.Core.targets</StrideSdkTargets>
</PropertyGroup>
<!-- Ensure appropriate Solution Platform are available -->
<Choose>
<When Condition=" '$(StridePlatform)' == 'Android' ">
<PropertyGroup Condition=" '$(Platform)' == 'Android' "/>
</When>
<When Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' ">
<PropertyGroup Condition=" '$(Platform)' == 'iPhone' "/>
<PropertyGroup Condition=" '$(Platform)' == 'iPhoneSimulator' "/>
</When>
</Choose>
<Import Project="$(MSBuildThisFileDirectory)Stride.PackageVersion.targets"/>
<!-- Sdk settings -->
<PropertyGroup>
<!-- If we don't set it, default targets will add PlatformName in some cases -->
<BaseOutputPath>bin\</BaseOutputPath>
<OutputPath>$(BaseOutputPath)$(Configuration)\</OutputPath>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<!-- Default values -->
<PropertyGroup>
<StrideAssemblyProcessor Condition="'$(StrideAssemblyProcessor)' == ''">false</StrideAssemblyProcessor>
<StrideAssemblyProcessorOptions Condition="'$(StrideAssemblyProcessorOptions)' == ''">--auto-module-initializer --serialization</StrideAssemblyProcessorOptions>
</PropertyGroup>
<!--
Global Settings per project
-->
<PropertyGroup>
<StrideCommonDependenciesDir Condition="'$(StrideCommonDependenciesDir)' == ''">$(MSBuildThisFileDirectory)..\..\deps\</StrideCommonDependenciesDir>
<StrideCommonDependenciesDir Condition="'$(StrideCommonDependenciesDir)' != '' and !HasTrailingSlash('$(StrideCommonDependenciesDir)')">$(StrideCommonDependenciesDir)\</StrideCommonDependenciesDir>
<ErrorReport>prompt</ErrorReport>
<FileAlignment>512</FileAlignment>
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFramework)' Or '$(TargetFramework)' == '$(StrideFrameworkWindows)' ">
<StridePlatformDefines>STRIDE_PLATFORM_DESKTOP</StridePlatformDefines>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkUWP)' ">
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<StridePlatformDefines>STRIDE_PLATFORM_UWP</StridePlatformDefines>
<ExtrasUwpMetaPackageVersion>6.2.12</ExtrasUwpMetaPackageVersion>
<TargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<GenerateLibraryLayout>false</GenerateLibraryLayout>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkAndroid)' ">
<StridePlatformDefines>STRIDE_PLATFORM_MONO_MOBILE;STRIDE_PLATFORM_ANDROID</StridePlatformDefines>
<AndroidStoreUncompressedFileExtensions />
<MandroidI18n />
<!-- Avoid Xamarin.Android.Common.targets(519,3): error MSB4044: The "FilterAssemblies" task was not given a value for the required parameter "DesignTimeBuild". -->
<DesignTimeBuild Condition="'$(DesignTimeBuild)' == ''">False</DesignTimeBuild>
<!-- Use AssemblyName rather than RootNamespace for Resource class otherwise it might clash between some assemblies (i.e. Stride and Stride.Engine) -->
<AndroidResgenNamespace>$(AssemblyName)</AndroidResgenNamespace>
<!-- Needs to be set to 21 as long as generated entry point projects are - otherwise user gets a lot of build warnings -->
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkAndroid)' And '$(OutputType)' == 'Exe' ">
<AndroidApplication>true</AndroidApplication>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkAndroid)' And '$(Configuration)' == 'Debug' ">
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkAndroid)' And '$(Configuration)' == 'Release' ">
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
</PropertyGroup>
<!-- Workaround for https://github.com/xamarin/xamarin-android/issues/1235 -->
<Target Name="_FixupLibraryProjectsEmbeddedResource" AfterTargets="_AddLibraryProjectsEmbeddedResourceToProject">
<ItemGroup>
<_LibraryProjectsEmbeddedResource Include="@(EmbeddedResource)" Condition="'%(Identity)' == '$(IntermediateOutputPath)__AndroidLibraryProjects__.zip'"/>
<EmbeddedResource Remove="@(_LibraryProjectsEmbeddedResource)"/>
<EmbeddedResource Include="@(_LibraryProjectsEmbeddedResource)">
<LogicalName>__AndroidLibraryProjects__.zip</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Target>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' ">
<Platform Condition=" '$(Platform)' == '' ">iPhone</Platform>
<StridePlatformDefines>STRIDE_PLATFORM_MONO_MOBILE;STRIDE_PLATFORM_IOS</StridePlatformDefines>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
</PropertyGroup>
<Choose>
<When Condition=" '$(TargetFramework)' == '$(StrideFrameworkUWP)' ">
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
</When>
</Choose>
<!-- Create empty project platform configuration so that MSBuild and Visual Studio Configuration Manager know about it -->
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' And '$(Configuration)|$(Platform)' == 'Debug|iPhone' "/>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' And '$(Configuration)|$(Platform)' == 'Release|iPhone' "/>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' And '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' "/>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' And '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' "/>
<!--
Settings StrideNETRuntime specific
-->
<PropertyGroup Condition="$(TargetFramework.StartsWith('net8'))">
<StrideNETRuntimeDefines>STRIDE_RUNTIME_CORECLR</StrideNETRuntimeDefines>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(StridePlatformDefines);$(DefineConstants)</DefineConstants>
<DefineConstants Condition="'$(StrideNETRuntimeDefines)' != ''">$(DefineConstants);$(StrideNETRuntimeDefines)</DefineConstants>
<DefineConstants Condition="'$(StridePackageBuild)' == 'true'">$(DefineConstants);STRIDE_PACKAGE_BUILD</DefineConstants>
</PropertyGroup>
<!-- SourceLink -->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Condition="'$(StrideProjectType)' == 'CSharp'" PrivateAssets="All"/>
</ItemGroup>
<!-- Copy the libcore.a and libfreetype.a libraries to the project root directory for future native link. -->
<Target Name="CopyStrideNativeLibraries" Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' and '$(OutputType)' == 'Exe'">
</Target>
<!-- Used by Stride.build to detect if unit tests prefer to run in 32 or 64 bits (note: it's a copy of Stride.UnitTests.targets one because some unit tests import Stride.Core.props rather than Stride.UnitTests.props) -->
<Target Name="_StrideAfterGetTargetPathWithTargetPlatformMoniker" AfterTargets="GetTargetPathWithTargetPlatformMoniker">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Update="$(TargetPath)">
<PlatformTarget>$(PlatformTarget)</PlatformTarget>
</TargetPathWithTargetPlatformMoniker>
</ItemGroup>
</Target>
<!-- Include Stride analyzer/code generator -->
<Import Project="$(MSBuildThisFileDirectory)Stride.Core.CompilerServices.props"/>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" Condition="'$(StrideProjectType)' != 'Cpp'" />
</Project>