Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit b86c75b

Browse files
amieresnosami
authored andcommitted
Simple changes to make it compatible with WASM (dotnet#8722)
* ifEmptyUse fSharpCompilerLocation In Wasm `Assembly.Location` do not have directory path since assemblies reside in memory. * Check GetEnvironmentVariable("FSHARP_COMPILER_BIN") before tryAppConfig In Wasm `tryAppConfig` throws and env var `FSHARP_COMPILER_BIN` never gets tested, so do it first * ifEmptyUse with IsNullOrWhiteSpace
1 parent 774f6af commit b86c75b

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/fsharp/DotNetFrameworkDependencies.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
2828
// Use the location of this dll
2929
location
3030

31+
let inline ifEmptyUse alternative filename = if String.IsNullOrWhiteSpace filename then alternative else filename
32+
3133
let getFSharpCoreLibraryName = "FSharp.Core"
3234
let getFsiLibraryName = "FSharp.Compiler.Interactive.Settings"
3335
let getDefaultFSharpCoreLocation = Path.Combine(fSharpCompilerLocation, getFSharpCoreLibraryName + ".dll")
3436
let getDefaultFsiLibraryLocation = Path.Combine(fSharpCompilerLocation, getFsiLibraryName + ".dll")
35-
let implementationAssemblyDir = Path.GetDirectoryName(typeof<obj>.Assembly.Location)
37+
let implementationAssemblyDir = Path.GetDirectoryName(typeof<obj>.Assembly.Location) |> ifEmptyUse fSharpCompilerLocation
3638

3739
// Use the ValueTuple that is executing with the compiler if it is from System.ValueTuple
3840
// or the System.ValueTuple.dll that sits alongside the compiler. (Note we always ship one with the compiler)

src/utils/CompilerLocationUtils.fs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ module internal FSharpEnvironment =
189189
// Check for an app.config setting to redirect the default compiler location
190190
// Like fsharp-compiler-location
191191
try
192+
// We let you set FSHARP_COMPILER_BIN. I've rarely seen this used and its not documented in the install instructions.
193+
match Environment.GetEnvironmentVariable("FSHARP_COMPILER_BIN") with
194+
| result when not (String.IsNullOrWhiteSpace result) -> Some result
195+
|_->
192196
// FSharp.Compiler support setting an appKey for compiler location. I've never seen this used.
193197
let result = tryAppConfig "fsharp-compiler-location"
194198
match result with
@@ -201,11 +205,6 @@ module internal FSharpEnvironment =
201205
match probePoint with
202206
| Some p when safeExists (Path.Combine(p,"FSharp.Core.dll")) -> Some p
203207
| _ ->
204-
// We let you set FSHARP_COMPILER_BIN. I've rarely seen this used and its not documented in the install instructions.
205-
let result = Environment.GetEnvironmentVariable("FSHARP_COMPILER_BIN")
206-
if not (String.IsNullOrEmpty(result)) then
207-
Some result
208-
else
209208
// For the prototype compiler, we can just use the current domain
210209
tryCurrentDomain()
211210
with e -> None

0 commit comments

Comments
 (0)