/
Stride.Core.targets
232 lines (198 loc) · 14.9 KB
/
Stride.Core.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!-- Build file post-included by all Stride projects -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Add Default targets used by Msbuild for undefined Platforms / or when skipping compilation under a platform -->
<Target Name="Build"/>
<Target Name="Clean"/>
<Target Name="ReBuild"/>
<Target Name="Publish"/>
<Target Name="GetTargetPath"/>
<Target Name="GetNativeManifest"/>
<Target Name="GetPackagingOutputs"/>
<!--Import Local Post Settings for the solution being loaded -->
<Import Project="$(SolutionDir)$(SolutionName).Build.targets" Condition="Exists('$(SolutionDir)$(SolutionName).Build.targets')" />
<Import Project="$(SolutionDir)Stride.Core.Build.targets" Condition="Exists('$(SolutionDir)Stride.Core.Build.targets')" />
<!-- Workaround: GetPackagingOutputs from UWP (uap) try to build ProjectReference with current TFM, and that's the only way I could find to skip it -->
<Target Name="_StrideRemoveTargetFrameworkBeforeGetPackagingOutputs" BeforeTargets="GetPackagingOutputs">
<ItemGroup>
<ProjectReferenceWithConfiguration>
<UndefineProperties>%(ProjectReferenceWithConfiguration.UndefineProperties);TargetFramework</UndefineProperties>
</ProjectReferenceWithConfiguration>
</ItemGroup>
</Target>
<!-- Linux Compatibility Properties -->
<PropertyGroup>
<TEMP>$([System.IO.Path]::GetTempPath())</TEMP>
</PropertyGroup>
<!-- Code Analysis -->
<PropertyGroup Condition="'$(StrideCodeAnalysis)' == 'true'">
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Stride.ruleset</CodeAnalysisRuleSet>
<!--<TreatWarningsAsErrors>true</TreatWarningsAsErrors>-->
</PropertyGroup>
<ItemGroup Condition="'$(StrideCodeAnalysis)' == 'true'">
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta008" PrivateAssets="All" />
</ItemGroup>
<!-- Disable analyzers unless StrideEnableCodeAnalysis is set (note: PackageReference can't depend on external Condition) -->
<Target Name="DisableAnalyzersForStrideBuild"
BeforeTargets="CoreCompile"
Condition="'$(StrideEnableCodeAnalysis)' != 'true'">
<ItemGroup>
<!-- We want to include Stride analyzers by default -->
<AnalyzersNotToRemove Include="@(Analyzer)" Condition="$([System.String]::Copy(%(FullPath)).Contains('Stride'))" />
<AnalyzersToRemove Include="@(Analyzer)" Exclude="@(AnalyzersNotToRemove)" />
<Analyzer Remove="@(AnalyzersToRemove)"/>
</ItemGroup>
</Target>
<!-- docfx doesn't like if there is no TargetFramework set by default -->
<PropertyGroup Condition="'$(StrideBuildDoc)' == 'true'">
<TargetFramework Condition="'$(TargetFramework)' == ''">$(TargetFrameworks.Split(';', StringSplitOptions.RemoveEmptyEntries)[0])</TargetFramework>
</PropertyGroup>
<!-- Setup compiler targets per platform / language -->
<PropertyGroup>
<!-- On Android, everything is library (even Exe) -->
<OutputType Condition=" '$(TargetFramework)' == '$(StrideFrameworkAndroid)' ">Library</OutputType>
</PropertyGroup>
<!-- User Documentation (.usrdoc) -->
<PropertyGroup Condition="'$(StridePublicApi)' == 'true'">
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.usrdoc</AllowedOutputExtensionsInPackageBuildOutputFolder>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);_StrideRegisterUserDocOutputs</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<Target Name="_StrideRegisterUserDocOutputs">
<ItemGroup Condition="Exists('$(OutputPath)$(AssemblyName).usrdoc')">
<BuildOutputInPackage Include="$(OutputPath)$(AssemblyName).usrdoc"/>
</ItemGroup>
</Target>
<Target Name="_StrideRegisterUserDocReferenceRelatedFileExtensions" Condition="'$(StridePublicApi)' == 'true'" BeforeTargets="ResolveAssemblyReferences">
<PropertyGroup>
<AllowedReferenceRelatedFileExtensions>$(AllowedReferenceRelatedFileExtensions);.usrdoc</AllowedReferenceRelatedFileExtensions>
</PropertyGroup>
</Target>
<PropertyGroup>
<StrideCompilerTargetsEnable Condition=" '$(TargetFramework)' != '$(StrideFramework)' and '$(TargetFramework)' == '$(StrideFrameworkWindows)' and $(StrideWindowsOnly) == 'true'">false</StrideCompilerTargetsEnable>
<!-- Skip unit tests if requested -->
<StrideCompilerTargetsEnable Condition="'$(StrideSkipUnitTests)' == 'true' And $(StrideOutputFolder.StartsWith('Tests'))">false</StrideCompilerTargetsEnable>
<!-- If StrideCompilerTargetsEnable is set to false, override LanguageTargets to an empty one -->
<LanguageTargets Condition="'$(StrideCompilerTargetsEnable)' == 'false'">$(MSBuildThisFileDirectory)Stride.Core.DisableBuild.targets</LanguageTargets>
<StrideAssemblyProcessorFramework>netstandard2.0</StrideAssemblyProcessorFramework>
<StrideAssemblyProcessorExt>.dll</StrideAssemblyProcessorExt>
<StrideAssemblyProcessorHash Condition="'$(StrideAssemblyProcessorBasePath)' != ''">$([System.IO.File]::ReadAllText('$(StrideAssemblyProcessorBasePath)\$(StrideAssemblyProcessorFramework)\Stride.Core.AssemblyProcessor.Packed$(StrideAssemblyProcessorExt).hash'))</StrideAssemblyProcessorHash>
<StrideAssemblyProcessorTempBasePath Condition="'$(StrideAssemblyProcessorBasePath)' != ''">$(TEMP)\Stride\AssemblyProcessor\$(StrideAssemblyProcessorHash)\$(StrideAssemblyProcessorFramework)\</StrideAssemblyProcessorTempBasePath>
<StrideAssemblyProcessorTempPath Condition="'$(StrideAssemblyProcessorBasePath)' != ''">$(StrideAssemblyProcessorTempBasePath)Stride.Core.AssemblyProcessor.Packed$(StrideAssemblyProcessorExt)</StrideAssemblyProcessorTempPath>
</PropertyGroup>
<!-- Setup default output path for C++ projects -->
<PropertyGroup>
<OutputPath Condition="'$(StrideProjectType)' == 'Cpp'">$(OutDir)</OutputPath>
<IntermediateOutputPath Condition="'$(StrideProjectType)' == 'Cpp'">$(IntDir)</IntermediateOutputPath>
</PropertyGroup>
<!-- C++ doesn't auto-import language targets -->
<Import Condition="'$(StrideProjectType)' == 'Cpp' And '$(StrideCompilerTargetsEnable)' != 'false'" Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<!-- Assembly Processor -->
<UsingTask TaskName="AssemblyProcessorTask" AssemblyFile="$(StrideAssemblyProcessorTempPath)" Condition=" '$(StrideAssemblyProcessorTempPath)' != '' And '$(StrideAssemblyProcessorDev)' != 'true' "/>
<Target Name="RunStrideAssemblyProcessor" BeforeTargets="CopyFilesToOutputDirectory" Condition=" '$(StrideAssemblyProcessor)' == 'true' and '$(StrideAssemblyProcessorTempPath)' != '' and '$(StrideAssemblyProcessorGlobal)' == 'true' and '$(StrideAssemblyProcessorOptions)' != '' ">
<PropertyGroup>
<!-- Add Stride.Core path to assembly search directory -->
<StrideAssemblyProcessorOptions Condition="'$(StrideCoreAssemblyPath)' != ''">$(StrideAssemblyProcessorOptions) --assembly="$(StrideCoreAssemblyPath)"</StrideAssemblyProcessorOptions>
</PropertyGroup>
<WriteLinesToFile File="$(IntermediateOutputPath)StrideReferences.cache" Lines="@(ReferencePath)" Overwrite="true" />
<!--Add platform and target framework to assembly processor options-->
<PropertyGroup>
<StrideAssemblyProcessorOptions>--platform=$(StridePlatform) --targetFramework=$(TargetFrameworkVersion) $(StrideAssemblyProcessorOptions)</StrideAssemblyProcessorOptions>
<StrideAssemblyProcessorOptions>$(StrideAssemblyProcessorOptions) --references-file="$(IntermediateOutputPath)StrideReferences.cache"</StrideAssemblyProcessorOptions>
<StrideAssemblyProcessorOptions Condition="'$(AssemblyOriginatorKeyFile)' != ''">$(StrideAssemblyProcessorOptions) --signkeyfile="$(AssemblyOriginatorKeyFile)"</StrideAssemblyProcessorOptions>
<StrideAssemblyProcessorOptions Condition="'$(DocumentationFile)' != ''">$(StrideAssemblyProcessorOptions) --docfile="$(DocumentationFile)"</StrideAssemblyProcessorOptions>
<StrideAssemblyProcessorOptions>$(StrideAssemblyProcessorOptions) --Werror</StrideAssemblyProcessorOptions>
<StrideAssemblyProcessorOptions>$(StrideAssemblyProcessorOptions) "$(IntermediateOutputPath)$(TargetName)$(TargetExt)"</StrideAssemblyProcessorOptions>
</PropertyGroup>
<!-- Copy task to temp directory (otherwise MSBuild lock the task file and we can't reinstall package in dev mode) -->
<ItemGroup>
<StrideAssemblyProcessorFilesToCopy Include="$(StrideAssemblyProcessorBasePath)$(StrideAssemblyProcessorFramework)\*.*" />
</ItemGroup>
<Copy SourceFiles="@(StrideAssemblyProcessorFilesToCopy)" DestinationFolder="$(StrideAssemblyProcessorTempBasePath)" Condition="!Exists('$(StrideAssemblyProcessorTempPath)')" />
<!-- Run assembly processor -->
<Message Importance="High" Text=""$(StrideAssemblyProcessorTempPath)" $(StrideAssemblyProcessorOptions)"/>
<AssemblyProcessorTask Condition=" '$(StrideAssemblyProcessorDev)' != 'true' " Arguments="$(StrideAssemblyProcessorOptions)"/>
<!-- Dev mode: don't use task to avoid locking the file -->
<Exec Condition=" '$(StrideAssemblyProcessorDev)' == 'true' " Command=""$(StrideAssemblyProcessorTempPath)" $(StrideAssemblyProcessorOptions)"/>
<!-- Copy User Documentation (.usrdoc) file to output -->
<Copy
Condition="'$(StridePublicApi)' == 'true' And Exists('%(RelativeDir)%(Filename).usrdoc')"
SourceFiles="@(DocFileItem->'%(RelativeDir)%(Filename).usrdoc')"
DestinationFolder="$(OutDir)"
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
>
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
</Copy>
</Target>
<Import Project="$(MSBuildThisFileDirectory)Stride.Core.PostSettings.Dependencies.targets"/>
<Import Condition="'$(StrideNativeOutputName)' != ''" Project="$(MSBuildThisFileDirectory)..\native\Stride.Native.targets" />
<!-- Workaround for https://github.com/dotnet/project-system/issues/6227 (UpToDateCheck: always fail if projects.assets.json is updated) -->
<Target Name="_GenerateCompileInputsProjectAssets" AfterTargets="_GenerateCompileInputs">
<ItemGroup>
<CustomAdditionalCompileInputs Include="$(ProjectAssetsFile)" />
</ItemGroup>
</Target>
<!-- Auto NuGet build packages and deploy them -->
<Target Name="StrideAutoPackDeploy" AfterTargets="Pack">
<Copy Condition="'%(Extension)' == '.nupkg'" SourceFiles="@(NuGetPackOutput)" DestinationFolder="$(LocalAppData)\Stride\NugetDev"/>
<!-- Deleting .sha512 file and/or .nupkg.metadata seems to be enough for NuGet restore to force extract new package and properly compile dependent projects -->
<Delete Files="$(NuGetPackageRoot)\$(PackageId.ToLowerInvariant())\$(PackageVersion)\$(PackageId).$(PackageVersion).nupkg.sha512"/>
<Delete Files="$(NuGetPackageRoot)\$(PackageId.ToLowerInvariant())\$(PackageVersion)\.nupkg.metadata"/>
</Target>
<PropertyGroup Condition="$(DesignTimeBuild) != 'true' And '$(StrideSkipAutoPack)' != 'true'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<AllowedOutputExtensionsInPackageBuildOutputFolder>.so;.a;.bin;.dylib;$(AllowedOutputExtensionsInPackageBuildOutputFolder)</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<!-- Auto NuGet build packages and deploy them -->
<Import Project="$(MSBuildThisFileDirectory)Stride.AutoPack.targets"/>
<!-- Generate localization satellite assemblies -->
<Target Name="StrideGenerateLocalizationSatelliteDlls"
BeforeTargets="SatelliteDllsProjectOutputGroup"
AfterTargets="Build"
Returns="@(SatelliteDllsProjectOutputGroupOutput)"
Condition="'$(StrideLocalized)' == 'true'">
<ItemGroup>
<!-- Current list of languages to try to generate -->
<StrideTranslations Include="fr;ja;es;de;ru;it;ko"/>
<StrideTranslations Include="zh-Hans">
<Source>zh_HANS-CN</Source>
</StrideTranslations>
<_StrideTranslations Include="@(StrideTranslations)">
<Source Condition="%(StrideTranslations.Source) == ''">%(StrideTranslations.Identity)</Source>
</_StrideTranslations>
</ItemGroup>
<Message Importance="High" Text="Generating translation for %(_StrideTranslations.Identity) %(_StrideTranslations.SourceFolder)"/>
<Exec Condition="Exists('$(SolutionDir)..\sources\localization\%(_StrideTranslations.Source)\$(TargetName).%(_StrideTranslations.Source).po')"
Command=""$(SolutionDir)..\deps\Gettext.Net\GNU.Gettext.Msgfmt.exe" -r $(TargetName) -d "$(TargetDir)\" -l %(_StrideTranslations.Identity) -L "$(SolutionDir)..\deps\Gettext.Net" "$(MSBuildThisFileDirectory)..\localization\%(_StrideTranslations.Source)\$(TargetName).%(_StrideTranslations.Source).po"" />
<ItemGroup>
<SatelliteDllsProjectOutputGroupOutputIntermediate Include="$(OutDir)%(_StrideTranslations.Identity)\$(TargetName).Messages.resources.dll" Condition="Exists('$(OutDir)%(_StrideTranslations.Identity)\$(TargetName).Messages.resources.dll')">
<TargetPath>%(_StrideTranslations.Identity)\$(TargetName).Messages.resources.dll</TargetPath>
<Culture>%(_StrideTranslations.Identity)</Culture>
</SatelliteDllsProjectOutputGroupOutputIntermediate>
</ItemGroup>
</Target>
<Target Name="_StrideSetFinalOutputPathOnBuildOutputFiles" AfterTargets="_GetBuildOutputFilesWithTfm">
<ItemGroup>
<BuildOutputInPackage Update="@(BuildOutputInPackage)" Condition="'%(BuildOutputInPackage.FinalOutputPath)' == ''">
<FinalOutputPath>$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '%(BuildOutputInPackage.FullPath)'))</FinalOutputPath>
</BuildOutputInPackage>
</ItemGroup>
</Target>
<PropertyGroup>
<_SdkLanguageSourceName Condition="'$(MSBuildProjectExtension)' == '.csproj'">CSharp</_SdkLanguageSourceName>
</PropertyGroup>
<!-- A workaround for https://github.com/microsoft/msbuild/issues/4584 and resolves https://github.com/onovotny/MSBuildSdkExtras/issues/176 -->
<Target Name="_RemoveNativeReferencesManifest" Condition="'$(TargetFramework)' == '$(StrideFrameworkiOS)'" AfterTargets="BuiltProjectOutputGroup">
<ItemGroup>
<_BuiltProjectOutputGroupOutputIntermediate Remove="$(OutDir)$(_DeploymentTargetApplicationManifestFileName)" />
<BuiltProjectOutputGroupOutput Remove="$(ProjectDir)$(OutDir)$(_DeploymentTargetApplicationManifestFileName)" />
</ItemGroup>
</Target>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition="'$(StrideProjectType)' != 'Cpp'" />
</Project>