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

Build FSI and FSC using AppHost #10736

Merged
merged 5 commits into from
Dec 21, 2020
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
4 changes: 2 additions & 2 deletions FSharpTests.Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<FscToolPath>$([System.IO.Path]::GetDirectoryName('$(DOTNET_HOST_PATH)'))</FscToolPath>
<FscToolExe Condition="'$(OS)' != 'Unix'">dotnet.exe</FscToolExe>
<FscToolExe Condition="'$(OS)' == 'Unix'">dotnet</FscToolExe>
<DotnetFscCompilerPath>$(MSBuildThisFileDirectory)artifacts\bin\fsc\$(Configuration)\netcoreapp3.1\fsc.exe</DotnetFscCompilerPath>
<DotnetFscCompilerPath>$(MSBuildThisFileDirectory)artifacts\bin\fsc\$(Configuration)\netcoreapp3.1\fsc.dll</DotnetFscCompilerPath>

<FsiToolPath>$([System.IO.Path]::GetDirectoryName('$(DOTNET_HOST_PATH)'))</FsiToolPath>
<FsiToolExe Condition="'$(OS)' != 'Unix'">dotnet.exe</FsiToolExe>
<FsiToolExe Condition="'$(OS)' == 'Unix'">dotnet</FsiToolExe>
<DotnetFsiCompilerPath>$(MSBuildThisFileDirectory)artifacts\bin\fsi\$(Configuration)\netcoreapp3.1\fsi.exe</DotnetFsiCompilerPath>
<DotnetFsiCompilerPath>$(MSBuildThisFileDirectory)artifacts\bin\fsi\$(Configuration)\netcoreapp3.1\fsi.dll</DotnetFsiCompilerPath>
</PropertyGroup>

<!-- SDK targets override -->
Expand Down
2 changes: 1 addition & 1 deletion eng/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function Update-Arguments() {
$script:bootstrap = $True
}
} else {
if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.exe") -or (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.runtimeconfig.json")) {
if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.dll") -or (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.runtimeconfig.json")) {
$script:bootstrap = $True
}
}
Expand Down
71 changes: 46 additions & 25 deletions src/buildtools/AssemblyCheck/AssemblyCheck.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,52 @@ module AssemblyCheck =
let private devVersionPattern = new Regex(@"-(ci|dev)", RegexOptions.Compiled)

let verifyEmbeddedPdb (filename:string) =
use fileStream = File.OpenRead(filename)
let reader = new PEReader(fileStream)
let mutable hasEmbeddedPdb = false

try
for entry in reader.ReadDebugDirectory() do
match entry.Type with
| DebugDirectoryEntryType.CodeView ->
let _ = reader.ReadCodeViewDebugDirectoryData(entry)
()

| DebugDirectoryEntryType.EmbeddedPortablePdb ->
let _ = reader.ReadEmbeddedPortablePdbDebugDirectoryData(entry)
hasEmbeddedPdb <- true
()

| DebugDirectoryEntryType.PdbChecksum ->
let _ = reader.ReadPdbChecksumDebugDirectoryData(entry)
()

| _ -> ()
with | e -> printfn "Error validating assembly %s\nMessage: %s" filename (e.ToString())
hasEmbeddedPdb
let isManagedDll =
try
// Is il assembly? throws if not
let _ = AssemblyName.GetAssemblyName(filename).Version
true
with
| :? System.BadImageFormatException -> false // uninterested in embedded pdbs for native dlls

if isManagedDll then
use fileStream = File.OpenRead(filename)
let reader = new PEReader(fileStream)
let mutable hasEmbeddedPdb = false

try
for entry in reader.ReadDebugDirectory() do
match entry.Type with
| DebugDirectoryEntryType.CodeView ->
let _ = reader.ReadCodeViewDebugDirectoryData(entry)
()

| DebugDirectoryEntryType.EmbeddedPortablePdb ->
let _ = reader.ReadEmbeddedPortablePdbDebugDirectoryData(entry)
hasEmbeddedPdb <- true
()

| DebugDirectoryEntryType.PdbChecksum ->
let _ = reader.ReadPdbChecksumDebugDirectoryData(entry)
()

| _ -> ()
with
| e -> printfn "Error validating assembly %s\nMessage: %s" filename (e.ToString())

hasEmbeddedPdb
else
true

let verifyAssemblies (binariesPath:string) =

let excludedAssemblies =
[ ] |> Set.ofList

let maybeNativeExe =
[ "fsi.exe"
"fsc.exe" ] |> Set.ofList

let fsharpAssemblies =
[ "FSharp*.dll"
"fsc.exe"
Expand All @@ -63,8 +80,12 @@ module AssemblyCheck =
let failedVersionCheck =
fsharpAssemblies
|> List.filter (fun a ->
let assemblyVersion = AssemblyName.GetAssemblyName(a).Version
assemblyVersion = versionZero || assemblyVersion = versionOne)
try
let assemblyVersion = AssemblyName.GetAssemblyName(a).Version
assemblyVersion = versionZero || assemblyVersion = versionOne
with | :? System.BadImageFormatException ->
// fsc.exe and fsi.exe are il on the desktop and native on the coreclr
Set.contains (Path.GetFileName(a)) maybeNativeExe |> not)

if failedVersionCheck.Length > 0 then
printfn "The following assemblies had a version of %A or %A" versionZero versionOne
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<PropertyGroup Condition="'$(DisableAutoSetFscCompilerPath)' != 'true' and '$(DOTNET_HOST_PATH)' != ''">
<FscToolPath Condition="'$(FscToolPath)' == ''">$([System.IO.Path]::GetDirectoryName($(DOTNET_HOST_PATH)))</FscToolPath>
<FscToolExe Condition="'$(FscToolExe)' == ''">$([System.IO.Path]::GetFileName($(DOTNET_HOST_PATH)))</FscToolExe>
<DotnetFscCompilerPath Condition="'$(DotnetFscCompilerPath)' == ''">"$(MSBuildThisFileDirectory)fsc.exe"</DotnetFscCompilerPath>
<DotnetFscCompilerPath Condition="'$(DotnetFscCompilerPath)' == ''">"$(MSBuildThisFileDirectory)fsc.dll"</DotnetFscCompilerPath>

<FsiToolPath Condition="'$(FsiToolPath)' == ''">$([System.IO.Path]::GetDirectoryName($(DOTNET_HOST_PATH)))</FsiToolPath>
<FsiToolExe Condition="'$(FsiToolExe)' == ''">$([System.IO.Path]::GetFileName($(DOTNET_HOST_PATH)))</FsiToolExe>
<DotnetFsiCompilerPath Condition="'$(DotnetFscCompilerPath)' == ''">"$(MSBuildThisFileDirectory)fsi.exe"</DotnetFsiCompilerPath>
<DotnetFsiCompilerPath Condition="'$(DotnetFscCompilerPath)' == ''">"$(MSBuildThisFileDirectory)fsi.dll"</DotnetFsiCompilerPath>
</PropertyGroup>

<ItemGroup Condition="'$(DisableImplicitSystemValueTupleReference)' != 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
this approach gives a very small deployment. Which is kind of necessary.
-->
<!-- assemblies -->
<file src="fsc\$Configuration$\netcoreapp3.1\fsc.exe" target="lib\netcoreapp3.1" />
<file src="fsi\$Configuration$\netcoreapp3.1\fsi.exe" target="lib\netcoreapp3.1" />
<file src="fsc\$Configuration$\netcoreapp3.1\fsc.dll" target="lib\netcoreapp3.1" />
<file src="fsi\$Configuration$\netcoreapp3.1\fsi.dll" target="lib\netcoreapp3.1" />
<file src="FSharp.Core\$Configuration$\netstandard2.0\FSharp.Core.dll" target="lib\netcoreapp3.1" />
<file src="FSharp.Core\$Configuration$\netstandard2.0\FSharp.Core.xml" target="lib\netcoreapp3.1" />
<file src="FSharp.Compiler.Private\$Configuration$\netstandard2.0\FSharp.Compiler.Private.dll" target="lib\netcoreapp3.1" />
Expand Down
3 changes: 1 addition & 2 deletions src/fsharp/fsc/fsc.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
<TargetFrameworks Condition="'$(ProtoTargetFramework)' != ''">$(ProtoTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp3.1</TargetFrameworks>
<TargetExt>.exe</TargetExt>
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>
<AllowCrossTargeting>true</AllowCrossTargeting>
<OtherFlags>$(OtherFlags) --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
<NGenBinary>true</NGenBinary>
<UseAppHost>false</UseAppHost>
<UseAppHost>true</UseAppHost>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
Expand Down
3 changes: 1 addition & 2 deletions src/fsharp/fsi/fsi.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
<TargetFrameworks Condition="'$(ProtoTargetFramework)' != ''">$(ProtoTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp3.1</TargetFrameworks>
<TargetExt>.exe</TargetExt>
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>
<AllowCrossTargeting>true</AllowCrossTargeting>
<OtherFlags>--warnon:1182 --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
<Win32Resource>fsi.res</Win32Resource>
<NGenBinary>true</NGenBinary>
<UseAppHost>false</UseAppHost>
<UseAppHost>true</UseAppHost>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Test.Utilities/CompilerAssert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ let main argv = 0"""
let args =
options
|> Array.append defaultProjectOptions.OtherOptions
|> Array.append [| "fsc.exe"; inputFilePath; "-o:" + outputFilePath; (if isExe then "--target:exe" else "--target:library"); "--nowin32manifest" |]
|> Array.append [| "fsc.dll"; inputFilePath; "-o:" + outputFilePath; (if isExe then "--target:exe" else "--target:library"); "--nowin32manifest" |]
let errors, _ = checker.Compile args |> Async.RunSynchronously
errors, outputFilePath

Expand Down
8 changes: 7 additions & 1 deletion tests/FSharp.Test.Utilities/TestFramework.fs
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,19 @@ let config configurationName envVars =
if File.Exists(repoLocalDotnetPath) then repoLocalDotnetPath
else DOTNET_EXE

#if !NETCOREAPP
let FSI_PATH = ("fsi" ++ configurationName ++ fsiArchitecture ++ "fsi.exe")
#else
let FSI_PATH = ("fsi" ++ configurationName ++ fsiArchitecture ++ "fsi.dll")
#endif
let FSI_FOR_SCRIPTS = requireArtifact FSI_PATH
let FSI = requireArtifact FSI_PATH
#if !NETCOREAPP
let FSIANYCPU = requireArtifact ("fsiAnyCpu" ++ configurationName ++ "net472" ++ "fsiAnyCpu.exe")
#endif
let FSC = requireArtifact ("fsc" ++ configurationName ++ fscArchitecture ++ "fsc.exe")
#else
let FSC = requireArtifact ("fsc" ++ configurationName ++ fscArchitecture ++ "fsc.dll")
brettfo marked this conversation as resolved.
Show resolved Hide resolved
#endif
let FSCOREDLLPATH = requireArtifact ("FSharp.Core" ++ configurationName ++ fsharpCoreArchitecture ++ "FSharp.Core.dll")

let defaultPlatform =
Expand Down