Skip to content

Commit

Permalink
Fable support
Browse files Browse the repository at this point in the history
  • Loading branch information
ncave committed Aug 5, 2019
1 parent e6d7183 commit 334cbc3
Show file tree
Hide file tree
Showing 97 changed files with 4,625 additions and 199 deletions.
34 changes: 33 additions & 1 deletion fcs/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let dotnetExePath =
if File.Exists(pathToCli) then
pathToCli
else
DotNetCli.InstallDotNetSDK "2.2.105"
DotNetCli.InstallDotNetSDK "2.2.108"

let runDotnet workingDir args =
let result =
Expand Down Expand Up @@ -90,6 +90,10 @@ Target "BuildVersion" (fun _ ->
Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" buildVersion) |> ignore
)

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

Target "Build" (fun _ ->
runDotnet __SOURCE_DIRECTORY__ "build ../src/buildtools/buildtools.proj -v n -c Proto"
let fslexPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fslex/Proto/netcoreapp2.1/fslex.dll"
Expand All @@ -110,6 +114,30 @@ Target "NuGet" (fun _ ->
runDotnet __SOURCE_DIRECTORY__ "pack FSharp.Compiler.Service.sln -v n -c Release"
)

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

// build FCS codegen
let fslexPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fslex/Proto/netcoreapp2.1/fslex.dll"
let fsyaccPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fsyacc/Proto/netcoreapp2.1/fsyacc.dll"
runDotnet outDir (sprintf "build -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)
|> 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)
// |> RegexReplaceInFilesWithEncoding pattern @"inline $0" Text.Encoding.UTF8
)

Target "GenerateDocsEn" (fun _ ->
executeFSIWithArgs "docsrc/tools" "generate.fsx" [] [] |> ignore
)
Expand Down Expand Up @@ -137,6 +165,10 @@ Target "Release" DoNothing
Target "GenerateDocs" DoNothing
Target "TestAndNuGet" DoNothing

"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 334cbc3

Please sign in to comment.