Skip to content

Commit

Permalink
Fable support
Browse files Browse the repository at this point in the history
  • Loading branch information
ncave committed Apr 13, 2020
1 parent 0e742c8 commit 54dc967
Show file tree
Hide file tree
Showing 104 changed files with 4,690 additions and 215 deletions.
2 changes: 1 addition & 1 deletion fcs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<!-- The LKG FSI.EXE requires MSBuild 15 to be installed, which is painful -->
<ToolsetFsiToolPath>$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools</ToolsetFsiToolPath>
<ToolsetFsiToolExe>fsi.exe</ToolsetFsiToolExe>
<FcsFSharpCorePkgVersion>4.6.2</FcsFSharpCorePkgVersion>
<FcsFSharpCorePkgVersion>4.7.1</FcsFSharpCorePkgVersion>
<FcsTargetNetFxFramework>net461</FcsTargetNetFxFramework>
</PropertyGroup>
</Project>
32 changes: 32 additions & 0 deletions fcs/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Target.create "BuildVersion" (fun _ ->
Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" buildVersion) |> ignore
)

Target.create "BuildTools" (fun _ ->
runDotnet __SOURCE_DIRECTORY__ "build" "../src/buildtools/buildtools.proj -v n -c Proto"
)

Target.create "Build" (fun _ ->
runDotnet __SOURCE_DIRECTORY__ "build" "../src/buildtools/buildtools.proj -v n -c Proto"
let fslexPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fslex/Proto/netcoreapp3.0/fslex.dll"
Expand All @@ -88,6 +92,30 @@ Target.create "NuGet" (fun _ ->
}) "FSharp.Compiler.Service.sln"
)

Target.create "CodeGen.Fable" (fun _ ->
let outDir = __SOURCE_DIRECTORY__ + "/fcs-fable/codegen/"

// build FCS codegen
let fslexPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fslex/Proto/netcoreapp3.0/fslex.dll"
let fsyaccPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fsyacc/Proto/netcoreapp3.0/fsyacc.dll"
runDotnet outDir "build" (sprintf "-v n /p:FsLexPath=%s /p:FsYaccPath=%s" fslexPath fsyaccPath)

// run FCS fssrgen (without .resx output, inlining it instead)
runDotnet outDir "run" "-- ../../../src/fsharp/FSComp.txt FSComp.fs"
runDotnet outDir "run" "-- ../../../src/fsharp/fsi/FSIstrings.txt FSIstrings.fs"

// Fable-specific (comment the #line directive as it is not supported)
["lex.fs"; "pplex.fs"; "illex.fs"; "ilpars.fs"; "pars.fs"; "pppars.fs"]
|> Seq.map (fun fileName -> outDir + fileName)
|> Shell.regexReplaceInFilesWithEncoding @"(?<!/)# (?=\d)" "//# " Text.Encoding.UTF8

// // prevent stack overflows on large files (make lexer rules inline)
// let pattern = @"(?<=and )(?!inline )([a-zA-Z]+ )+ *lexbuf "
// ["lex.fs"; "pplex.fs"; "illex.fs"]
// |> Seq.map (fun fileName -> outDir + fileName)
// |> Shell.regexReplaceInFilesWithEncoding pattern @"inline $0" Text.Encoding.UTF8
)

Target.create "GenerateDocsEn" (fun _ ->
runDotnet "docsrc/tools" "fake" "run generate.fsx"
)
Expand All @@ -114,6 +142,10 @@ Target.create "TestAndNuGet" ignore

open Fake.Core.TargetOperators

"Clean"
==> "BuildTools"
==> "CodeGen.Fable"

"Start"
=?> ("BuildVersion", isAppVeyorBuild)
==> "Restore"
Expand Down
3 changes: 3 additions & 0 deletions fcs/fcs-fable/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Codegen
codegen/*.fs
codegen/*.fsi
Loading

0 comments on commit 54dc967

Please sign in to comment.