stride/sources/targets/Stride.Core.PostSettings.De...

169 строки
10 KiB
XML

<!-- Build file post-included by all Stride projects -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AllowedOutputExtensionsInPackageBuildOutputFolder>.ssdeps; $(AllowedOutputExtensionsInPackageBuildOutputFolder)</AllowedOutputExtensionsInPackageBuildOutputFolder>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);_StrideRegisterDependenciesOutputs</TargetsForTfmSpecificBuildOutput>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_StrideRegisterPackageFiles</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>
<!--
*****************************************************************************************************************************
Dependencies reading (from .ssdeps)
*****************************************************************************************************************************
-->
<!-- List dependency files from .ssdeps -->
<Target Name="_StrideListDepsFiles" DependsOnTargets="ResolveAssemblyReferences">
<ItemGroup>
<_StrideDepsFile Include="@(ReferencePath->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<_StrideDepsFile Include="@(ReferenceDependencyPaths->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<None Include="@(_StrideDepsFile)" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>
<!-- Note: this target Outputs are not real, used so that it gets expanded for each file
also, if _StrideDepsFile is empty the target is still called so check for it -->
<Target Name="_StrideBuildDependencies" DependsOnTargets="_StrideListDepsFiles" Outputs="%(_StrideDepsFile.Identity)">
<!-- Read dependencies from file -->
<ReadLinesFromFile File="%(_StrideDepsFile.Identity)" Condition="'%(_StrideDepsFile.Identity)' != ''">
<Output TaskParameter="Lines" ItemName="_StrideDependencyLocal"/>
</ReadLinesFromFile>
<PropertyGroup>
<_StrideSourceDir>%(_StrideDepsFile.RootDir)%(_StrideDepsFile.Directory)</_StrideSourceDir>
</PropertyGroup>
<ItemGroup>
<_StrideDependencyLocal>
<!-- 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>
</_StrideDependencyLocal>
<_StrideDependencyContent Include="@(_StrideDependencyLocal->'$(_StrideSourceDir)%(SourcePath)')" Condition="'%(_StrideDependencyLocal.Type)' == 'Content'"/>
<_StrideDependencyNativeLib Include="@(_StrideDependencyLocal->'$(_StrideSourceDir)%(SourcePath)')" Condition="'%(_StrideDependencyLocal.Type)' == 'NativeLib'"/>
</ItemGroup>
<!-- Message -->
<Message Importance="Normal" Text="Detected dependency from %(_StrideDepsFile.FileName)" Condition="'%(_StrideDepsFile.Identity)' != ''"/>
<Message Importance="Normal" Text=" %(_StrideDependencyLocal.Type): %(_StrideDependencyLocal.Identity) => %(_StrideDependencyLocal.Link)"/>
<!-- Cleanup so that _StrideDependencyLocal is local -->
<ItemGroup>
<_StrideDependencyLocal Remove="@(_StrideDependencyLocal)"/>
</ItemGroup>
</Target>
<Target Name="_StrideCopyContent" DependsOnTargets="_StrideBuildDependencies" AfterTargets="ResolveAssemblyReferences" Condition="'$(StrideDependenciesCopy)' != 'false'">
<ItemGroup>
<Content Include="@(_StrideDependencyContent)" Pack="False"/>
</ItemGroup>
</Target>
<!--
*****************************************************************************************************************************
Native libraries setup (from .ssdeps)
*****************************************************************************************************************************
-->
<Target Name="_StrideSetupNativeLibraries" DependsOnTargets="_StrideBuildDependencies" AfterTargets="ResolveAssemblyReferences" Condition="'$(StrideDependenciesCopy)' != 'false'">
<!-- Windows, UWP, Linux & macOS -->
<ItemGroup Condition=" '$(TargetFramework)' == '$(StrideFramework)' Or '$(TargetFramework)' == '$(StrideFrameworkWindows)' Or '$(TargetFramework)' == '$(StrideFrameworkUWP)' ">
<None Include="@(_StrideDependencyNativeLib)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<!-- Android -->
<ItemGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkAndroid)' ">
<AndroidNativeLibrary Include="@(_StrideDependencyNativeLib)"/>
</ItemGroup>
<!--iOS -->
<ItemGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' ">
<!-- strip any "lib" prefix and populate the LibraryName value -->
<_StrideDependencyNativeLib>
<LibraryName>$([System.Text.RegularExpressions.Regex]::Match('%(Filename)', `(lib)*(.+)`).get_Groups().get_Item(2).ToString())</LibraryName>
</_StrideDependencyNativeLib>
<None Include="@(_StrideDependencyNativeLib)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == '$(StrideFrameworkiOS)' ">
<MtouchExtraArgsLibs>$(StrideMTouchExtras) -L"%24{ProjectDir}" @(_StrideDependencyNativeLib->'-l%(LibraryName) "%24{ProjectDir}/%(Filename)%(Extension)"',' ')</MtouchExtraArgsLibs>
<MtouchExtraArgs>$(MtouchExtraArgs) --compiler=clang -cxx -gcc_flags '-lstdc++ $(MtouchExtraArgsLibs)'</MtouchExtraArgs>
</PropertyGroup>
</Target>
<!--
*****************************************************************************************************************************
Dependencies generation (to .ssdeps)
*****************************************************************************************************************************
-->
<Target Name="_StrideGenerateDependenciesCore">
<!-- Set TargetPath on StrideContent and StrideNativeLib -->
<AssignTargetPath RootFolder="$(OutputPath)" Files="@(StrideContent)">
<Output TaskParameter="AssignedFiles" ItemName="_StrideContentAssigned"/>
</AssignTargetPath>
<AssignTargetPath RootFolder="$(OutputPath)" Files="@(StrideNativeLib)">
<Output TaskParameter="AssignedFiles" ItemName="_StrideNativeLibAssigned"/>
</AssignTargetPath>
<!-- Combine into _StrideDependencyToCopy (and add RelativePath and Type) -->
<ItemGroup>
<_StrideDependencyToCopy Include="@(_StrideContentAssigned)">
<RelativePath Condition="'%(_StrideContentAssigned.RelativePath)' == ''">%(TargetPath)</RelativePath>
<Type>Content</Type>
<Destination>$(OutDir)%(TargetPath)</Destination>
</_StrideDependencyToCopy>
<_StrideDependencyToCopy Include="@(_StrideNativeLibAssigned)">
<RelativePath Condition="'%(_StrideNativeLibAssigned.RelativePath)' == ''">%(TargetPath)</RelativePath>
<Type>NativeLib</Type>
<Destination>$(OutDir)%(TargetPath)</Destination>
</_StrideDependencyToCopy>
<_StrideDependencyToCopy Remove="@(_StrideNativeLibAssigned)" Condition=" '$(StridePackageBuild)' == 'true' And '%(_StrideNativeLibAssigned.Extension)' == '.pdb' "/>
</ItemGroup>
<!-- Copy files -->
<Copy
SourceFiles = "@(_StrideDependencyToCopy)"
DestinationFiles = "@(_StrideDependencyToCopy->'%(Destination)')"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(CreateHardLinksForAdditionalFilesIfPossible)">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
</Copy>
<!-- Write file containing list of dependent files (or delete it if nothing) -->
<WriteLinesToFile Condition="'@(_StrideDependencyToCopy)' != ''" File="$(OutputPath)$(TargetName).ssdeps" Lines="@(_StrideDependencyToCopy->'%(Type);%(TargetPath);%(RelativePath)')" Overwrite="true"/>
<Delete Condition="'@(_StrideDependencyToCopy)' == ''" Files="$(OutputPath)$(TargetName).ssdeps"/>
</Target>
<!-- Build -->
<Target Name="_StrideGenerateDependencies" Condition="'$(TargetFramework)' != '' Or '$(StrideProjectType)' == 'Cpp'" DependsOnTargets="_StrideGenerateDependenciesCore" AfterTargets="CopyFilesToOutputDirectory"/>
<!-- Packaging -->
<Target Name="_StrideRegisterDependenciesOutputs" Condition="'$(TargetFramework)' != ''" DependsOnTargets="_StrideGenerateDependenciesCore">
<ItemGroup Condition="'@(_StrideDependencyToCopy)' != ''">
<BuildOutputInPackage Include="$(OutputPath)$(AssemblyName).ssdeps" />
</ItemGroup>
</Target>
<Target Name="_StrideRegisterPackageFiles" Condition="'$(TargetFramework)' != ''" DependsOnTargets="_StrideGenerateDependenciesCore">
<ItemGroup Condition="'@(_StrideDependencyToCopy)' != ''">
<!-- Native dependencies go to the runtimes/RID/native folder -->
<TfmSpecificPackageFile Include="@(_StrideDependencyToCopy)"
Condition=" '%(_StrideDependencyToCopy.Type)' == 'NativeLib' "
PackagePath="%(_StrideDependencyToCopy.TargetPath)" />
<!-- Content goes to contentFiles/any/any (language/tfm) with CopyToOutput=true and BuildAction=None -->
<TfmSpecificPackageFile Include="@(_StrideDependencyToCopy)"
Condition=" '%(_StrideDependencyToCopy.Type)' == 'Content' "
PackagePath="contentFiles/any/any/%(_StrideDependencyToCopy.TargetPath)"
PackageCopyToOutput="true"
BuildAction="None" />
</ItemGroup>
</Target>
</Project>