Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo compile before - add fail on plainbuild error #17103

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions azure-pipelines-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ stages:
- script: dotnet build .\FSharp.Compiler.Service.sln /bl:\"artifacts/log/$(_BuildConfig)/ServiceRegularBuild.binlog\"
workingDirectory: $(Build.SourcesDirectory)
displayName: Regular rebuild of FSharp.Compiler.Service.sln
continueOnError: true
continueOnError: false
condition: always()

# Plain FCS build Linux
Expand All @@ -739,7 +739,7 @@ stages:
- script: dotnet build ./FSharp.Compiler.Service.sln /bl:\"artifacts/log/$(_BuildConfig)/ServiceRegularBuild.binlog\"
workingDirectory: $(Build.SourcesDirectory)
displayName: Regular rebuild of FSharp.Compiler.Service.sln
continueOnError: true
continueOnError: false
condition: always()

# Plain FCS build Mac
Expand All @@ -765,7 +765,7 @@ stages:
- script: dotnet build ./FSharp.Compiler.Service.sln /bl:\"artifacts/log/$(_BuildConfig)/ServiceRegularBuild.binlog\"
workingDirectory: $(Build.SourcesDirectory)
displayName: Regular rebuild of FSharp.Compiler.Service.sln
continueOnError: true
continueOnError: false
condition: always()

# Build and run fast benchmarks
Expand Down
32 changes: 27 additions & 5 deletions src/FSharp.Build/Microsoft.FSharp.Targets
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ this file.
</FSharpEmbedResXSource>

<ItemGroup>
<CompileBefore Include="@(_FsGeneratedResXSource)" />
<Compile Include="@(_FsGeneratedResXSource)" CompileOrder="CompileBefore" />
<FsGeneratedSource Include="@(_FsGeneratedResXSource)" />
<FileWrites Include="@(_FsGeneratedResXSource)" />
</ItemGroup>
Expand All @@ -247,14 +247,35 @@ this file.
</FSharpEmbedResourceText>

<ItemGroup>
<CompileBefore Include="@(_FsGeneratedTxtSource)" />
<Compile Include="@(_FsGeneratedTxtSource)" CompileOrder="CompileBefore" />
<FsGeneratedSource Include="@(_FsGeneratedTxtSource)" />
<EmbeddedResource Include="@(_FsGeneratedResx)" />
<FileWrites Include="@(_FsGeneratedTxtSource)" />
<FileWrites Include="@(_FsGeneratedResx)" />
</ItemGroup>
</Target>

<Target Name="FSharpSourceCodeCompileOrder">
<!-- implement <CompileOrder>CompileBefore</CompileOrder> -->
<ItemGroup>
<__Sources Remove="@(__Sources)" />
<__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileFirst'))" />
<__Sources Include="@(CompileBefore)" />
<__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileBefore'))" />
<__Sources Include="@(Compile->WithMetadataValue('CompileOrder', ''))" />
<__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileAfter'))" />
<__Sources Include="@(CompileAfter)" />
<__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileLast'))" />
</ItemGroup>
<ItemGroup>
<Compile Remove="@(Compile)" />
<CompileBefore Remove="@(CompileBefore)" />
<CompileAfter Remove="@(CompileAfter)" />
<Compile Include="@(__Sources)" />
</ItemGroup>
<Message Importance="low" Text="FSharpSourceCodeCompileOrder:Sources: '@(__Sources)'" />
</Target>

<Target
Name="CoreCompile"
Inputs="$(MSBuildAllProjects);
Expand Down Expand Up @@ -284,7 +305,7 @@ this file.
$(NonExistentFile);
@(CustomAdditionalCompileOutputs)"
Returns="@(FscCommandLineArgs)"
DependsOnTargets="$(CoreCompileDependsOn)"
DependsOnTargets="$(CoreCompileDependsOn);FSharpSourceCodeCompileOrder"
>

<Error
Expand Down Expand Up @@ -321,6 +342,7 @@ this file.
<EmbeddedFiles Include="@(FsGeneratedSource)" KeepDuplicates="false" Condition="'$(SourceLink)'!='' or '$(EmbeddedFiles)'!='' or '$(EmbedAllSources)'!=''" />
</ItemGroup>


<!-- Dotnet SDK requires SimpleResolution to be true Legacy project system build not -->
<PropertyGroup>
<FscOtherFlags Condition="'$(SimpleResolution)' == 'true'">--simpleresolution $(OtherFlags)</FscOtherFlags>
Expand Down Expand Up @@ -371,7 +393,7 @@ this file.
Resources="@(ActualEmbeddedResources)"
SkipCompilerExecution="$(SkipCompilerExecution)"
SourceLink="$(SourceLink)"
Sources="@(CompileBefore);@(Compile);@(CompileAfter)"
Sources="@(Compile)"
SubsystemVersion="$(SubsystemVersion)"
Tailcalls="$(Tailcalls)"
TargetType="$(OutputType)"
Expand Down Expand Up @@ -434,7 +456,7 @@ this file.
Overwrite="true"/>

<ItemGroup Condition="'$(AdditionalSourcesText)' != ''">
<CompileBefore Include="$(TargetFrameworkMonikerAssemblyAttributesPath)" />
<Compile Include="$(TargetFrameworkMonikerAssemblyAttributesPath)"><CompileOrder>CompileBefore</CompileOrder></Compile>
<_FsGeneratedTfmAttributesSource Include="$(TargetFrameworkMonikerAssemblyAttributesPath)" />
</ItemGroup>
</Target>
Expand Down
13 changes: 13 additions & 0 deletions src/FSharp.Core/FSharp.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,25 @@
</EmbeddedResource>
<EmbeddedResource Include="ILLink.LinkAttributes.xml" LogicalName="ILLink.LinkAttributes.xml" />
<EmbeddedResource Include="ILLink.Substitutions.xml" LogicalName="ILLink.Substitutions.xml" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Proto' or '$(BUILDING_USING_DOTNET)' == 'true'">
<!-- This can be removed once CompileBefore support is shipped in an rtm relase -->
<CompileBefore Include="prim-types-prelude.fsi">
<Link>Primitives/prim-types-prelude.fsi</Link>
</CompileBefore>
<CompileBefore Include="prim-types-prelude.fs">
<Link>Primitives/prim-types-prelude.fs</Link>
</CompileBefore>
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' != 'Proto' and '$(BUILDING_USING_DOTNET)' != 'true'">
<Compile Include="prim-types-prelude.fsi" CompileOrder="CompileFirst">
<Link>Primitives/prim-types-prelude.fsi</Link>
</Compile>
<Compile Include="prim-types-prelude.fs" CompileOrder="CompileFirst">
<Link>Primitives/prim-types-prelude.fs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="prim-types.fsi">
<Link>Primitives/prim-types.fsi</Link>
</Compile>
Expand Down
42 changes: 42 additions & 0 deletions tests/fsharp/SDKTests/tests/CompileOrder - BeforeAndAfter.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project ToolsVersion="4.0" DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Initialize Variables -->
<PropertyGroup>
<FSharpCompilerPath></FSharpCompilerPath>
</PropertyGroup>

<!-- Expected Values -->
<PropertyGroup>
<ExpectedFSharpShimPresent>true</ExpectedFSharpShimPresent>
<ExpectedFSharpCompilerPath>/Common7/IDE/CommonExtensions/Microsoft/FSharp/Tools/</ExpectedFSharpCompilerPath>
<ExpectedFscToolExe>fscAnyCpu.exe</ExpectedFscToolExe>
<ExpectedFscToolPath>_VsInstallRoot_/Common7/IDE/CommonExtensions/Microsoft/FSharp/Tools/</ExpectedFscToolPath>
<ExpectedDotnetFscCompilerPath></ExpectedDotnetFscCompilerPath>
<ExpectedCompile>One;Two;Three;Four;Five;Six;Seven;Eight;Nine;Ten;Eleven;Twelve;Thirteen;Fourteen</ExpectedCompile>
</PropertyGroup>

<Import Project="ToolsTest.props" />

<PropertyGroup>
</PropertyGroup>

<ItemGroup>
<CompileAfter Include="Eleven" />
<Compile Include="Thirteen" CompileOrder="CompileLast" />
<CompileBefore Include="Three" />
<CompileAfter Include="Twelve" />
<CompileBefore Include="Four" />
<Compile Include="Seven" />
<Compile Include="Eight" />
<Compile Include="Five" CompileOrder="CompileBefore" />
<Compile Include="One" CompileOrder="CompileFirst" />
<Compile Include="Nine" CompileOrder="CompileAfter" />
<Compile Include="Fourteen" CompileOrder="CompileLast" />
<Compile Include="Ten" CompileOrder="CompileAfter" />
<Compile Include="Two" CompileOrder="CompileFirst" />
<Compile Include="Six" CompileOrder="CompileBefore" />
</ItemGroup>

<Import Project="ToolsTest.targets" />

</Project>
5 changes: 4 additions & 1 deletion tests/fsharp/SDKTests/tests/ToolsTest.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

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

<Target Name="Test">
<Target Name="Test" DependsOnTargets="FSharpSourceCodeCompileOrder">
<Message Importance="High" Text="===========================================================================================================" />
<Message Importance="High" Text="Testing : $(MSBuildProjectName)" />


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

Expand All @@ -17,6 +18,8 @@

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

<Error Condition="'$(ExpectedCompile)' != '' and '$(ExpectedCompile)' != '@(Compile)'" Text="ExpectedCompile: expected:'$(ExpectedCompile)' actual:'@(Compile)'" />

<Error Condition="'$(ExpectedDotnetFscCompilerPath)' == '' and '$(DotnetFscCompilerPath)' != ''" Text="DotnetFscCompilerPath expected to be empty actual:'$(DotnetFscCompilerPath)'" />

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