Skip to content

Commit

Permalink
Fable support
Browse files Browse the repository at this point in the history
  • Loading branch information
ncave committed Mar 29, 2019
1 parent 0633603 commit 57a54e0
Show file tree
Hide file tree
Showing 95 changed files with 8,019 additions and 3,602 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ artifacts/*.nupkg
*.orig
*.mdf
*.ldf
.paket/paket.exe
fcs/.paket/paket.exe
paket-files
docsrc/tools/FSharp.Formatting.svclog
src/fsharp/FSharp.Compiler.Service/pplex.fs
Expand All @@ -202,6 +202,7 @@ src/fsharp/FSharp.Compiler.Service/pppars.fsi
*.cto
*.vstman
project.lock.json
.vscode

src/fsharp/FSharp.Compiler.Service/FSComp.fs
src/fsharp/FSharp.Compiler.Service/FSComp.resx
Expand Down
32 changes: 32 additions & 0 deletions fcs/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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.0/fslex.dll"
Expand All @@ -107,6 +111,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.0/fslex.dll"
let fsyaccPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fsyacc/Proto/netcoreapp2.0/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 @@ -134,6 +162,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 57a54e0

Please sign in to comment.