Skip to content

Commit 17f24c1

Browse files
committed
corebeforeafter
1 parent 273cea5 commit 17f24c1

File tree

4 files changed

+86
-8
lines changed

4 files changed

+86
-8
lines changed

src/FSharp.Build/Microsoft.FSharp.Targets

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ this file.
235235
</FSharpEmbedResXSource>
236236

237237
<ItemGroup>
238-
<CompileBefore Include="@(_FsGeneratedResXSource)" />
238+
<Compile Include="@(_FsGeneratedResXSource)" CompileOrder="CompileBefore" />
239239
<FsGeneratedSource Include="@(_FsGeneratedResXSource)" />
240240
<FileWrites Include="@(_FsGeneratedResXSource)" />
241241
</ItemGroup>
@@ -247,20 +247,39 @@ this file.
247247
</FSharpEmbedResourceText>
248248

249249
<ItemGroup>
250-
<CompileBefore Include="@(_FsGeneratedTxtSource)" />
250+
<Compile Include="@(_FsGeneratedTxtSource)" CompileOrder="CompileBefore" />
251251
<FsGeneratedSource Include="@(_FsGeneratedTxtSource)" />
252252
<EmbeddedResource Include="@(_FsGeneratedResx)" />
253253
<FileWrites Include="@(_FsGeneratedTxtSource)" />
254254
<FileWrites Include="@(_FsGeneratedResx)" />
255255
</ItemGroup>
256256
</Target>
257257

258+
<Target Name="FSharpSourceCodeCompileOrder">
259+
<!-- implement <CompileOrder>CompileBefore</CompileOrder> -->
260+
<ItemGroup>
261+
<__Sources Remove="*" />
262+
<__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileFirst'))" />
263+
<__Sources Include="@(CompileBefore)" />
264+
<__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileBefore'))" />
265+
<__Sources Include="@(Compile->WithMetadataValue('CompileOrder', ''))" />
266+
<__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileAfter'))" />
267+
<__Sources Include="@(CompileAfter)" />
268+
<__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileLast'))" />
269+
</ItemGroup>
270+
<ItemGroup>
271+
<Compile Remove="*" />
272+
<CompileBefore Remove="*" />
273+
<CompileAfter Remove="*" />
274+
<Compile Include="@(__Sources)" />
275+
</ItemGroup>
276+
<Message Importance="low" Text="FSharpSourceCodeCompileOrder:Sources: '@(Sources)'" />
277+
</Target>
278+
258279
<Target
259280
Name="CoreCompile"
260281
Inputs="$(MSBuildAllProjects);
261-
@(CompileBefore);
262282
@(Compile);
263-
@(CompileAfter);
264283
@(FscCompilerTools);
265284
@(_CoreCompileResourceInputs);
266285
@(ManifestNonResxWithNoCultureOnDisk);
@@ -284,7 +303,7 @@ this file.
284303
$(NonExistentFile);
285304
@(CustomAdditionalCompileOutputs)"
286305
Returns="@(FscCommandLineArgs)"
287-
DependsOnTargets="$(CoreCompileDependsOn)"
306+
DependsOnTargets="$(CoreCompileDependsOn);FSharpSourceCodeCompileOrder"
288307
>
289308

290309
<Error
@@ -321,6 +340,7 @@ this file.
321340
<EmbeddedFiles Include="@(FsGeneratedSource)" KeepDuplicates="false" Condition="'$(SourceLink)'!='' or '$(EmbeddedFiles)'!='' or '$(EmbedAllSources)'!=''" />
322341
</ItemGroup>
323342

343+
324344
<!-- Dotnet SDK requires SimpleResolution to be true Legacy project system build not -->
325345
<PropertyGroup>
326346
<FscOtherFlags Condition="'$(SimpleResolution)' == 'true'">--simpleresolution $(OtherFlags)</FscOtherFlags>
@@ -371,7 +391,7 @@ this file.
371391
Resources="@(ActualEmbeddedResources)"
372392
SkipCompilerExecution="$(SkipCompilerExecution)"
373393
SourceLink="$(SourceLink)"
374-
Sources="@(CompileBefore);@(Compile);@(CompileAfter)"
394+
Sources="@(Compile)"
375395
SubsystemVersion="$(SubsystemVersion)"
376396
Tailcalls="$(Tailcalls)"
377397
TargetType="$(OutputType)"
@@ -434,7 +454,7 @@ this file.
434454
Overwrite="true"/>
435455

436456
<ItemGroup Condition="'$(AdditionalSourcesText)' != ''">
437-
<CompileBefore Include="$(TargetFrameworkMonikerAssemblyAttributesPath)" />
457+
<Compile Include="$(TargetFrameworkMonikerAssemblyAttributesPath)"><CompileOrder>BeforeCompile</CompileOrder></Compile>
438458
<_FsGeneratedTfmAttributesSource Include="$(TargetFrameworkMonikerAssemblyAttributesPath)" />
439459
</ItemGroup>
440460
</Target>

src/FSharp.Core/FSharp.Core.fsproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,25 @@
6161
</EmbeddedResource>
6262
<EmbeddedResource Include="ILLink.LinkAttributes.xml" LogicalName="ILLink.LinkAttributes.xml" />
6363
<EmbeddedResource Include="ILLink.Substitutions.xml" LogicalName="ILLink.Substitutions.xml" />
64+
</ItemGroup>
65+
<ItemGroup Condition="'$(Configuration)' == 'Proto'">
66+
<!-- This can be removed once CompileBefore support is shipped in an rtm relase -->
6467
<CompileBefore Include="prim-types-prelude.fsi">
6568
<Link>Primitives/prim-types-prelude.fsi</Link>
6669
</CompileBefore>
6770
<CompileBefore Include="prim-types-prelude.fs">
6871
<Link>Primitives/prim-types-prelude.fs</Link>
6972
</CompileBefore>
73+
</ItemGroup>
74+
<ItemGroup Condition="'$(Configuration)' != 'Proto'">
75+
<Compile Include="prim-types-prelude.fsi" CompileOrder="CompileFirst">
76+
<Link>Primitives/prim-types-prelude.fsi</Link>
77+
</Compile>
78+
<Compile Include="prim-types-prelude.fs" CompileOrder="CompileFirst">
79+
<Link>Primitives/prim-types-prelude.fs</Link>
80+
</Compile>
81+
</ItemGroup>
82+
<ItemGroup>
7083
<Compile Include="prim-types.fsi">
7184
<Link>Primitives/prim-types.fsi</Link>
7285
</Compile>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<Project ToolsVersion="4.0" DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
3+
<!-- Initialize Variables -->
4+
<PropertyGroup>
5+
<FSharpCompilerPath></FSharpCompilerPath>
6+
</PropertyGroup>
7+
8+
<!-- Expected Values -->
9+
<PropertyGroup>
10+
<ExpectedFSharpShimPresent>true</ExpectedFSharpShimPresent>
11+
<ExpectedFSharpCompilerPath>/Common7/IDE/CommonExtensions/Microsoft/FSharp/Tools/</ExpectedFSharpCompilerPath>
12+
<ExpectedFscToolExe>fscAnyCpu.exe</ExpectedFscToolExe>
13+
<ExpectedFscToolPath>_VsInstallRoot_/Common7/IDE/CommonExtensions/Microsoft/FSharp/Tools/</ExpectedFscToolPath>
14+
<ExpectedDotnetFscCompilerPath></ExpectedDotnetFscCompilerPath>
15+
<ExpectedCompile>One;Two;Three;Four;Five;Six;Seven;Eight;Nine;Ten;Eleven;Twelve;Thirteen;Fourteen</ExpectedCompile>
16+
</PropertyGroup>
17+
18+
<Import Project="ToolsTest.props" />
19+
20+
<PropertyGroup>
21+
</PropertyGroup>
22+
23+
<ItemGroup>
24+
<CompileAfter Include="Eleven" />
25+
<Compile Include="Thirteen" CompileOrder="CompileLast" />
26+
<CompileBefore Include="Three" />
27+
<CompileAfter Include="Twelve" />
28+
<CompileBefore Include="Four" />
29+
<Compile Include="Seven" />
30+
<Compile Include="Eight" />
31+
<Compile Include="Five" CompileOrder="CompileBefore" />
32+
<Compile Include="One" CompileOrder="CompileFirst" />
33+
<Compile Include="Nine" CompileOrder="CompileAfter" />
34+
<Compile Include="Fourteen" CompileOrder="CompileLast" />
35+
<Compile Include="Ten" CompileOrder="CompileAfter" />
36+
<Compile Include="Two" CompileOrder="CompileFirst" />
37+
<Compile Include="Six" CompileOrder="CompileBefore" />
38+
</ItemGroup>
39+
40+
<Import Project="ToolsTest.targets" />
41+
42+
</Project>

tests/fsharp/SDKTests/tests/ToolsTest.targets

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
<Import Project="$(TargetsDirectory)\Microsoft.FSharp.targets" />
66

7-
<Target Name="Test">
7+
<Target Name="Test" DependsOnTargets="FSharpSourceCodeCompileOrder">
88
<Message Importance="High" Text="===========================================================================================================" />
99
<Message Importance="High" Text="Testing : $(MSBuildProjectName)" />
1010

11+
1112
<!-- check for expected settings -->
1213
<Error Condition="'$(ExpectedFSharpShimPresent)' != '$(FSharp_Shim_Present)'" Text="FSharp_Shim_Present expected:'$(ExpectedFSharpShimPresent)' actual: '$(FSharp_Shim_Present)'" />
1314

@@ -17,6 +18,8 @@
1718

1819
<Error Condition="'$(ExpectedFscToolPath)' != '$(FscToolPath)'" Text="FscToolPath: expected:'$(ExpectedFscToolPath)' actual:'$(FscToolPath)'" />
1920

21+
<Error Condition="'$(ExpectedCompile)' != '' and '$(ExpectedCompile)' != '@(Sources)'" Text="ExpectedCompile: expected:'$(ExpectedCompile)' actual:'@(Compile)'" />
22+
2023
<Error Condition="'$(ExpectedDotnetFscCompilerPath)' == '' and '$(DotnetFscCompilerPath)' != ''" Text="DotnetFscCompilerPath expected to be empty actual:'$(DotnetFscCompilerPath)'" />
2124

2225
<Error Condition="'$(ExpectedDotnetFscCompilerPath)' != '' and $([System.String]::new('$(DotnetFscCompilerPath)').EndsWith('$(ExpectedDotnetFscCompilerPath)')) == true" Text="DotnetFscCompilerPath expected to end with: '$(ExpectedDotnetFscCompilerPath)' actual:'$(DotnetFscCompilerPath)'" />

0 commit comments

Comments
 (0)