mirror of
https://github.com/anoma/juvix.git
synced 2024-12-20 13:21:47 +03:00
32449e1212
The problem with readFile and writeFile from text [Data.Text.IO](https://hackage.haskell.org/package/text-2.0.2/docs/Data-Text-IO.html) is that they use the system locale to determine the text encoding format. Our assumption is that all Juvix source files are UTF-8 encoded. I cannot reproduce the issue with using the old APIs on my machine, it can be reproduced on Arch linux. I'm not sure how to write a specific test for this. * Closes https://github.com/anoma/juvix/issues/2472
25 lines
902 B
Haskell
25 lines
902 B
Haskell
module Commands.Dev.Core.Compile where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.Core.Compile.Base
|
|
import Commands.Dev.Core.Compile.Options
|
|
import Juvix.Compiler.Core.Data.InfoTable qualified as Core
|
|
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
|
|
|
|
runCommand :: forall r. (Members '[Embed IO, App] r) => CompileOptions -> Sem r ()
|
|
runCommand opts = do
|
|
file <- getFile
|
|
s <- readFile (toFilePath file)
|
|
tab <- getRight (mapLeft JuvixError (Core.runParserMain file Core.emptyInfoTable s))
|
|
let arg = PipelineArg opts file tab
|
|
case opts ^. compileTarget of
|
|
TargetWasm32Wasi -> runCPipeline arg
|
|
TargetNative64 -> runCPipeline arg
|
|
TargetGeb -> runGebPipeline arg
|
|
TargetVampIR -> runVampIRPipeline arg
|
|
TargetCore -> return ()
|
|
TargetAsm -> runAsmPipeline arg
|
|
where
|
|
getFile :: Sem r (Path Abs File)
|
|
getFile = getMainFile (opts ^. compileInputFile)
|