-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nemerle.MSBuild.targets
375 lines (318 loc) · 18.5 KB
/
Nemerle.MSBuild.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<Project>
<UsingTask
TaskName="Nemerle.Tools.MSBuildTask.Ncc"
AssemblyFile="$(Nemerle)\Nemerle.Tools.MSBuildTask.dll"/>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<DefaultLanguageSourceExtension>.n</DefaultLanguageSourceExtension>
<Language>Nemerle</Language>
</PropertyGroup>
<PropertyGroup>
<!-- "None" is not technically a valid DebugType, so we can't pass it in as such
to the compiler. So here, we modify the properties so they make sense. -->
<DebugSymbols Condition=" '$(DebugType)' == 'none' ">false</DebugSymbols>
<DebugType Condition=" '$(DebugType)' == 'none' "></DebugType>
<_DisabledWarnings>$(NoWarn)</_DisabledWarnings>
<!-- Provide a facility to override UseHostCompilerIfAvailable-->
<UseHostCompilerIfAvailable Condition=" '$(UseHostCompilerIfAvailable)' == ''">true</UseHostCompilerIfAvailable>
</PropertyGroup>
<!-- Set BaseIntermediateOutputPath if IntermediateOutputPath was set, like C# does -->
<PropertyGroup>
<BaseIntermediateOutputPath Condition="'$(IntermediateOutputPath)' != '' and '$(BaseIntermediateOutputPath)' == '' ">$(IntermediateOutputPath)</BaseIntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<DocFileItem Include="$(DocumentationFile)" Condition="'$(DocumentationFile)'!=''"/>
</ItemGroup>
<ItemGroup Condition=" '$(DebugSymbols)' == 'true' ">
<_DebugSymbolsIntermediatePath Include="@(IntermediateAssembly->'%(RootDir)%(Directory)%(Filename).pdb')"/>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.Common.targets" />
<Target Name="_GenerateAssemblyInfo" AfterTargets="GenerateAssemblyInfo" Condition="'$(GenerateAssemblyInfo)' == 'true'">
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyCompanyAttribute" Condition="'$(Company)' != '' and '$(GenerateAssemblyCompanyAttribute)' == 'true'">
<_Parameter1>$(Company)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyConfigurationAttribute" Condition="'$(Configuration)' != '' and '$(GenerateAssemblyConfigurationAttribute)' == 'true'">
<_Parameter1>$(Configuration)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyCopyrightAttribute" Condition="'$(Copyright)' != '' and '$(GenerateAssemblyCopyrightAttribute)' == 'true'">
<_Parameter1>$(Copyright)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyDescriptionAttribute" Condition="'$(Description)' != '' and '$(GenerateAssemblyDescriptionAttribute)' == 'true'">
<_Parameter1>$(Description)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyFileVersionAttribute" Condition="'$(FileVersion)' != '' and '$(GenerateAssemblyFileVersionAttribute)' == 'true'">
<_Parameter1>$(FileVersion)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyInformationalVersionAttribute" Condition="'$(InformationalVersion)' != '' and '$(GenerateAssemblyInformationalVersionAttribute)' == 'true'">
<_Parameter1>$(InformationalVersion)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyProductAttribute" Condition="'$(Product)' != '' and '$(GenerateAssemblyProductAttribute)' == 'true'">
<_Parameter1>$(Product)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyTitleAttribute" Condition="'$(AssemblyTitle)' != '' and '$(GenerateAssemblyTitleAttribute)' == 'true'">
<_Parameter1>$(AssemblyTitle)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyVersionAttribute" Condition="'$(AssemblyVersion)' != '' and '$(GenerateAssemblyVersionAttribute)' == 'true'">
<_Parameter1>$(AssemblyVersion)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Resources.NeutralResourcesLanguageAttribute" Condition="'$(NeutralLanguage)' != '' and '$(GenerateNeutralResourcesLanguageAttribute)' == 'true'">
<_Parameter1>$(NeutralLanguage)</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<!-- Ensure the generated assemblyinfo file is not already part of the Compile sources, as a workaround for https://github.com/dotnet/sdk/issues/114 -->
<Compile Remove="$(GeneratedAssemblyInfoFile)" />
</ItemGroup>
<WriteLinesToFile File="$(GeneratedAssemblyInfoFile)" Lines="@(AssemblyAttribute->'[assembly: %(Identity)(@"%(_Parameter1)")]')" Overwrite="true" />
<ItemGroup>
<FileWrites Include="$(GeneratedAssemblyInfoFile)" />
<Compile Include="$(GeneratedAssemblyInfoFile)" />
</ItemGroup>
</Target>
<ItemDefinitionGroup>
<MacroProjectReference>
<Private>False</Private>
<OutputItemType>macro</OutputItemType>
</MacroProjectReference>
</ItemDefinitionGroup>
<!--
============================================================
SplitProjectReferencesByType (for MSBUILD 3.5)
Split project references into two lists: VC project references and all others (handled by the MSBuild engine)
[IN]
@(ProjectReference), @(MacroProjectReference) - the list of all project references
[OUT]
@(VCProjectReference) - the list of VC (managed VC++ to be exact) project references
@(NonVCProjectReference) - the list of non-VC project references (MSBuild and potentially VSIP projects)
============================================================
-->
<Target
Name="SplitProjectReferencesByType"
Condition="('@(ProjectReference)' != '') or ('@(MacroProjectReference)' != '' )">
<!-- Assign a project configuration to each project reference if we're building a solution file. -->
<AssignProjectConfiguration
ProjectReferences="@(ProjectReference);@(MacroProjectReference)"
SolutionConfigurationContents="$(CurrentSolutionConfigurationContents)"
Condition="'$(BuildingSolutionFile)'=='true'">
<Output TaskParameter="AssignedProjects" ItemName="_ProjectReferenceWithConfiguration"/>
</AssignProjectConfiguration>
<ItemGroup>
<!--
Otherwise (regular command line build or building inside the IDE) just copy the references
as we don't need their configurations
-->
<_ProjectReferenceWithConfiguration Condition="'$(BuildingSolutionFile)'!='true'" Include="@(ProjectReference);@(MacroProjectReference)"/>
</ItemGroup>
<ItemGroup>
<!-- Copy all VC project references to the VCProjectReference item list (using the VC project extension) -->
<VCProjectReference Include="@(_ProjectReferenceWithConfiguration)" Condition="'%(Extension)'=='.vcproj'"/>
<!-- Copy the rest of the project references to the NonVCProjectReference item list -->
<NonVCProjectReference Include="@(_ProjectReferenceWithConfiguration)" Condition="'%(Extension)'!='.vcproj'"/>
</ItemGroup>
</Target>
<!--
============================================================
AssignProjectConfiguration (for MSBUILD 4.0)
Assigns the appropriate configuration to each project in the list of project references passed in.
[IN]
@(ProjectReference), @(MacroProjectReference) - the list of all project references
[OUT]
@(ProjectReferenceWithConfiguration) - the list of project references (MSBuild and potentially VSIP projects)
with metadata values FullConfiguration, Configuration, Platform,
SetConfiguration, and SetPlatform
============================================================
-->
<Target
Name="AssignProjectConfiguration"
Condition="('@(ProjectReference)' != '') or ('@(MacroProjectReference)' != '' )">
<PropertyGroup>
<OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration Condition="'$(OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration)' == ''">false</OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration>
<ShouldUnsetParentConfigurationAndPlatform Condition="'$(ShouldUnsetParentConfigurationAndPlatform)' == '' and ('$(BuildingInsideVisualStudio)' == 'true' or '$(BuildingSolutionFile)' == 'true')">true</ShouldUnsetParentConfigurationAndPlatform>
<ShouldUnsetParentConfigurationAndPlatform Condition="'$(ShouldUnsetParentConfigurationAndPlatform)' == ''">false</ShouldUnsetParentConfigurationAndPlatform>
</PropertyGroup>
<!-- Assign a project configuration to each project reference if we're building a solution file. -->
<AssignProjectConfiguration
ProjectReferences="@(ProjectReference);@(MacroProjectReference)"
CurrentProjectConfiguration="$(Configuration)"
CurrentProjectPlatform="$(Platform)"
DefaultToVcxPlatformMapping="$(DefaultToVcxPlatformMapping)"
VcxToDefaultPlatformMapping="$(VcxToDefaultPlatformMapping)"
OutputType="$(OutputType)"
ResolveConfigurationPlatformUsingMappings="false"
SolutionConfigurationContents="$(CurrentSolutionConfigurationContents)"
OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration = "$(OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration)"
ShouldUnsetParentConfigurationAndPlatform = "$(ShouldUnsetParentConfigurationAndPlatform)" >
<!-- EMITTED FOR COMPATIBILITY REASONS ONLY. CONSUME PROJECTREFERENCEWITHCONFIGURATION INSTEAD -->
<Output TaskParameter="AssignedProjects" ItemName="_ProjectReferenceWithConfiguration"/>
<Output TaskParameter="UnassignedProjects" ItemName="_ProjectReferenceWithConfiguration"/>
<Output TaskParameter="AssignedProjects" ItemName="ProjectReferenceWithConfiguration"/>
<Output TaskParameter="UnassignedProjects" ItemName="ProjectReferenceWithConfiguration"/>
</AssignProjectConfiguration>
<ItemGroup>
<_ProjectReferenceWithConfiguration>
<BuildReference Condition="'%(_ProjectReferenceWithConfiguration.BuildReference)' == ''">true</BuildReference>
<ReferenceOutputAssembly Condition="'%(_ProjectReferenceWithConfiguration.ReferenceOutputAssembly)' == ''">true</ReferenceOutputAssembly>
</_ProjectReferenceWithConfiguration>
<ProjectReferenceWithConfiguration>
<BuildReference Condition="'%(ProjectReferenceWithConfiguration.BuildReference)' == ''">true</BuildReference>
<ReferenceOutputAssembly Condition="'%(ProjectReferenceWithConfiguration.ReferenceOutputAssembly)' == ''">true</ReferenceOutputAssembly>
</ProjectReferenceWithConfiguration>
</ItemGroup>
</Target>
<PropertyGroup>
<ResolveReferencesDependsOn>$(ResolveReferencesDependsOn);ResolveMacroAssemblyReferences</ResolveReferencesDependsOn>
<ResolveMacroAssemblyReferencesDependsOn>$(ResolveAssemblyReferences)</ResolveMacroAssemblyReferencesDependsOn>
<ResolveAssemblyReferencesDependsOn>$(ResolveAssemblyReferences);ResolveMacroAssemblyReferences</ResolveAssemblyReferencesDependsOn>
</PropertyGroup>
<Target
Name="ResolveMacroAssemblyReferences"
Condition=" '@(MacroReference)' != '' "
DependsOnTargets="$(ResolveMacroAssemblyReferencesDependsOn)">
<ItemGroup>
<_ReferenceInstalledAssemblyDirectory Include="$(TargetFrameworkDirectory)" />
<_ReferenceInstalledAssemblySubsets Include="$(TargetFrameworkSubset)" />
</ItemGroup>
<!--
Only read and write cache file at build time, skip it for load time because its more
expensive to write the newly created cache file.
-->
<PropertyGroup>
<ResolveMacroAssemblyReferencesStateFile Condition="'$(BuildingProject)'=='true'">$(IntermediateOutputPath)ResolveMacroAssemblyReference.cache</ResolveMacroAssemblyReferencesStateFile>
</PropertyGroup>
<ResolveAssemblyReference
Assemblies="@(MacroReference)"
TargetFrameworkDirectories="@(_ReferenceInstalledAssemblyDirectory)"
InstalledAssemblyTables="@(InstalledAssemblyTables);@(RedistList)"
CandidateAssemblyFiles="@(Content);@(None)"
SearchPaths="$(AssemblySearchPaths)"
AllowedAssemblyExtensions="$(AllowedReferenceAssemblyFileExtensions)"
AllowedRelatedFileExtensions="$(AllowedReferenceRelatedFileExtensions)"
TargetProcessorArchitecture="$(ProcessorArchitecture)"
AutoUnify="$(AutoUnifyAssemblyReferences)"
FindDependencies="false"
FindSatellites="false"
FindSerializationAssemblies="false"
FindRelatedFiles="false"
Silent="false"
IgnoreDefaultInstalledAssemblyTables="$(IgnoreInstalledAssemblyTables)"
IgnoreDefaultInstalledAssemblySubsetTables="$(IgnoreInstalledAssemblySubsetTables)"
TargetFramework="$(TargetFramework)"
StateFile="$(ResolveMacroAssemblyReferencesStateFile)"
InstalledAssemblySubsetTables="@(InstalledAssemblySubsetTables)"
TargetFrameworkSubsets="@(_ReferenceInstalledAssemblySubsets)"
FullTargetFrameworkSubsetNames="$(FullReferenceAssemblyNames)">
<Output TaskParameter="ResolvedFiles" ItemName="MacroReferencePath"/>
</ResolveAssemblyReference>
</Target>
<!--
The CreateManifestResourceNames target create the manifest resource names from the .RESX
files.
[IN]
@(EmbeddedResource) - The list of EmbeddedResource items that have been pre-processed to add metadata about resource type
Expected Metadata "Type" can either be "Resx" or "Non-Resx"
[OUT]
@(EmbeddedResource) - EmbeddedResource items with metadata
For C# applications the transformation is like:
Resources1.resx => RootNamespace.Resources1 => Build into main assembly
SubFolder\Resources1.resx => RootNamespace.SubFolder.Resources1 => Build into main assembly
Resources1.fr.resx => RootNamespace.Resources1.fr => Build into satellite assembly
Resources1.notaculture.resx => RootNamespace.Resources1.notaculture => Build into main assembly
For other project systems, this transformation may be different.
-->
<PropertyGroup>
<CreateManifestResourceNamesDependsOn></CreateManifestResourceNamesDependsOn>
</PropertyGroup>
<Target
Name="CreateManifestResourceNames"
Condition="'@(EmbeddedResource)' != ''"
DependsOnTargets="$(CreateManifestResourceNamesDependsOn)"
>
<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
<!-- Create manifest names for culture and non-culture Resx files, and for non-culture Non-Resx resources -->
<CreateCSharpManifestResourceName
ResourceFiles="@(EmbeddedResource)"
RootNamespace="$(RootNamespace)"
Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and ('%(EmbeddedResource.WithCulture)' == 'false' or '%(EmbeddedResource.Type)' == 'Resx')">
<Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />
</CreateCSharpManifestResourceName>
<!-- Create manifest names for all culture non-resx resources -->
<CreateCSharpManifestResourceName
ResourceFiles="@(EmbeddedResource)"
RootNamespace="$(RootNamespace)"
PrependCultureAsDirectory="false"
Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx'">
<Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />
</CreateCSharpManifestResourceName>
<ItemGroup>
<EmbeddedResource Remove="@(EmbeddedResource)" Condition="'%(EmbeddedResource.ManifestResourceName)' == ''"/>
<EmbeddedResource Include="@(_Temporary)" />
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
</Target>
<PropertyGroup>
<CoreCompileDependsOn>_ComputeNonExistentFileProperty</CoreCompileDependsOn>
</PropertyGroup>
<Target
Name="CoreCompile"
Inputs="$(MSBuildAllProjects);
@(Compile);
@(_CoreCompileResourceInputs);
$(ApplicationIcon);
$(AssemblyOriginatorKeyFile);
@(ReferencePath);
@(CompiledLicenseFile);
@(EmbeddedDocumentation);
$(Win32Resource);
$(Win32Manifest);
@(CustomAdditionalCompileInputs)"
Outputs="@(DocFileItem);
@(IntermediateAssembly);
@(_DebugSymbolsIntermediatePath);
@(CustomAdditionalCompileOutputs)"
DependsOnTargets="$(CoreCompileDependsOn)"
>
<ItemGroup>
<_NonMacroReferencePath Include="@(ReferencePath)" Condition="%(ReferencePath.OutputItemType) != 'macro'" />
<_MacroProjectReferencePath Include="@(ReferencePath)" Condition="%(ReferencePath.OutputItemType) == 'macro'" />
</ItemGroup>
<Ncc
AdditionalLibPaths="$(AdditionalLibPaths)"
CheckIntegerOverflow="$(CheckIntegerOverflow)"
CompilerPath="$(Nemerle)"
CompilerStackSize="$(CompilerStackSize)"
CustomArguments="$(CustomArguments)"
DefineConstants="$(DefineConstants)"
DisabledWarnings="$(_DisabledWarnings)"
DocumentationFile="@(DocFileItem)"
EmitDebugInformation="$(DebugSymbols)"
EnabledWarnings="$(EnabledWarnings)"
IndentationSyntax="$(IndentationSyntax)"
KeyFile="$(KeyOriginatorFile)"
MacroReferences="@(_MacroProjectReferencePath);@(MacroReferencePath)"
NoLogo="$(NoLogo)"
NoStdLib="$(NoStdLib)"
NoStdMacros="$(NoStdMacros)"
Optimize="$(Optimize)"
OutputAssembly="@(IntermediateAssembly)"
Platform="$(PlatformTarget)"
ProjectPath="$(MSBuildProjectFullPath)"
References="@(_NonMacroReferencePath)"
Resources="@(ManifestResourceWithNoCulture);@(ManifestNonResxWithNoCultureOnDisk);@(CompiledLicenseFile)"
ResponseFiles="$(CompilerResponseFile)"
RootNamespace="$(RootNamespace)"
RunDebugger="$(RunDebugger)"
Sources="@(Compile)"
TargetType="$(OutputType)"
ToolPath="$(CscToolPath)"
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
WarningLevel="$(WarningLevel)"
Win32Resource="$(Win32Resource)" />
<ItemGroup>
<_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />
</ItemGroup>
<CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''"/>
</Target>
</Project>