Skip to content

Commit

Permalink
Using fable-metadata for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Feb 12, 2019
1 parent f227105 commit ca531d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"fable-compiler": "^2.1.0-beta-003",
"fable-loader": "^2.0.0",
"fable-splitter": "^2.0.1",
"fable-metadata": "1.0.0-beta-002",
"mocha": "^5.2.0",
"shelljs": "^0.8.3",
"terser": "^3.10.0",
Expand Down
22 changes: 9 additions & 13 deletions src/dotnet/Fable.Compiler/CLI/ProjectCracker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ type ScriptOption =
| Dll of string
| FablePackage of FablePackage

let getCrackedProjects (checker: FSharpChecker) (projFile: string) =
let getCrackedProjects (checker: FSharpChecker) (projFile: string) (rootDir: string) =
match (Path.GetExtension projFile).ToLower() with
| ".fsx" ->
let fsprojOptions = getProjectOptionsFromScript checker projFile
Expand All @@ -317,22 +317,18 @@ let getCrackedProjects (checker: FSharpChecker) (projFile: string) =
)

let dllReferences =
let (/) a b = Path.Combine(a,b)

parsedOptions
|> List.map (function | ScriptOption.Dll dll -> Some dll | _ -> None)
|> List.choose id
|> fun dllRx ->
Array.fold (fun dllRs rf ->
if not (List.exists (fun r -> Path.GetFileNameWithoutExtension(r) = rf) dllRs) then
let dllPath =
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) then
System.IO.Path.Combine("/usr/lib/mono/4.7.1-api/Facades", sprintf "%s.dll" rf)
else
System.IO.Path.Combine(@"C:\Windows\Microsoft.NET\Framework64\v4.0.30319", sprintf "%s.dll" rf) // TODO: get path to full framework or mono
if System.IO.File.Exists(dllPath) |> not then
dllRs // System.Reflection.Metadata & System.Reflection.TypeExtensions don't exist in full framework.
// I think these Reflection APIs are in System.Reflection.dll and are found at runtime.
else
dllPath::dllRs
rootDir / "node_modules" / "fable-metadata" / "lib" / (sprintf "%s.dll" rf)

dllPath::dllRs
else
dllRs
) dllRx Fable.Repl.Metadata.references_core
Expand Down Expand Up @@ -367,11 +363,11 @@ let getCrackedProjects (checker: FSharpChecker) (projFile: string) =
// file for changes. In some cases that editor will lock the file which can cause fable to
// get a read error. If that happens the lock is usually brief so we can reasonably wait
// for it to be released.
let retryGetCrackedProjects (checker: FSharpChecker) (projFile: string) =
let retryGetCrackedProjects (checker: FSharpChecker) (projFile: string) (rootDir: string) =
let retryUntil = (DateTime.Now + TimeSpan.FromSeconds 2.)
let rec retry () =
try
getCrackedProjects checker projFile
getCrackedProjects checker projFile rootDir
with
| :? IOException as ioex ->
if retryUntil > DateTime.Now then
Expand Down Expand Up @@ -435,7 +431,7 @@ let getFullProjectOpts (checker: FSharpChecker) (define: string[]) (rootDir: str
let projFile = Path.GetFullPath(projFile)
if not(File.Exists(projFile)) then
failwith ("File does not exist: " + projFile)
let projRefs, mainProj = retryGetCrackedProjects checker projFile
let projRefs, mainProj = retryGetCrackedProjects checker projFile rootDir
let fableLibraryPath, pkgRefs =
copyFableLibraryAndPackageSources rootDir mainProj.PackageReferences
let projOpts =
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,11 @@ fable-loader@^2.0.0:
dependencies:
fable-utils "^1.1.0"

fable-metadata@1.0.0-beta-002:
version "1.0.0-beta-002"
resolved "https://registry.yarnpkg.com/fable-metadata/-/fable-metadata-1.0.0-beta-002.tgz#17c49a0e96413406e864ccb08cc2b11fc1adb9e9"
integrity sha512-PVDgurXItCEYLjzJAQRls/e5mfXsPbo7LrGIj5m2Iy8gztQMXHI4i1Tc3rY+kLAcLd9wgMGgaMBxAbahwQclWA==

fable-splitter@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/fable-splitter/-/fable-splitter-2.0.2.tgz#64d281ccc703f502fd5862d108613cee0408cd03"
Expand Down

0 comments on commit ca531d9

Please sign in to comment.