2022-05-30 18:46:17 +03:00
|
|
|
module Commands.Compile where
|
|
|
|
|
2022-09-14 17:16:15 +03:00
|
|
|
import Commands.Base
|
|
|
|
import Commands.Compile.Options
|
2023-03-14 18:24:07 +03:00
|
|
|
import Commands.Dev.Core.Compile.Base qualified as Compile
|
|
|
|
import Commands.Extra.Compile qualified as Compile
|
2022-05-30 18:46:17 +03:00
|
|
|
import Data.Text.IO qualified as TIO
|
2023-03-14 18:24:07 +03:00
|
|
|
import Juvix.Compiler.Core qualified as Core
|
|
|
|
import Juvix.Compiler.Core.Pretty qualified as Core
|
2023-03-15 18:41:39 +03:00
|
|
|
import Juvix.Compiler.Core.Transformation.DisambiguateNames qualified as Core
|
2022-05-30 18:46:17 +03:00
|
|
|
|
Update CI to install Smoke, Github actions, and Makefile fixes (#1735)
This PR adds some maintenance at different levels to the CI config, the
Make file, and formatting.
- Most of the actions used by the CI related to haskell, ormolu, hlint
and pre-commit have been updated because Github requires NodeJS 16. This
change removes all the old warnings related to nodeJs.
In the case of ormolu, the new version makes us format some files that
were not formatted before, similarly with hlint.
- The CI has been updated to use the latest version of the Smoke testing
framework, which introduced installation of the dependencies for Linux
(libicu66) and macOS (icu4c) in the CI. In the case of macOS, the CI
uses a binary for smoke. For Linux, we use stack to build smoke from the
source. The source here is in a fork of [the official Smoke
repo](https://github.com/SamirTalwar/smoke). Such includes some
features/changes that are not yet in the official repo.
- The Makefile runs the ormolu and hlint targets using as a path for the
binaries the environment variables ORMOLU and HLINT. Thus, export those
variables in your environment before running `make check,` `make format`
or `make hlint`. Otherwise, the Makefile will use the binaries provided
by `stack`.
Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-01-24 13:50:23 +03:00
|
|
|
runCommand :: (Members '[Embed IO, App] r) => CompileOptions -> Sem r ()
|
2022-09-14 17:16:15 +03:00
|
|
|
runCommand opts@CompileOptions {..} = do
|
2023-04-19 17:56:48 +03:00
|
|
|
inputFile <- fromAppPathFile _compileInputFile
|
2023-03-14 18:24:07 +03:00
|
|
|
Core.CoreResult {..} <- runPipeline _compileInputFile upToCore
|
|
|
|
let arg =
|
|
|
|
Compile.PipelineArg
|
|
|
|
{ _pipelineArgFile = inputFile,
|
|
|
|
_pipelineArgOptions = opts,
|
|
|
|
_pipelineArgInfoTable = _coreResultTable
|
|
|
|
}
|
|
|
|
case _compileTarget of
|
|
|
|
TargetNative64 -> Compile.runCPipeline arg
|
|
|
|
TargetWasm32Wasi -> Compile.runCPipeline arg
|
|
|
|
TargetGeb -> Compile.runGebPipeline arg
|
|
|
|
TargetCore -> writeCoreFile arg
|
|
|
|
TargetAsm -> Compile.runAsmPipeline arg
|
|
|
|
|
|
|
|
writeCoreFile :: (Members '[Embed IO, App] r) => Compile.PipelineArg -> Sem r ()
|
2023-03-27 11:42:27 +03:00
|
|
|
writeCoreFile pa@Compile.PipelineArg {..} = do
|
|
|
|
entryPoint <- Compile.getEntry pa
|
2023-03-14 18:24:07 +03:00
|
|
|
coreFile <- Compile.outputFile _pipelineArgOptions _pipelineArgFile
|
2023-03-27 11:42:27 +03:00
|
|
|
r <- runReader entryPoint $ runError @JuvixError $ Core.toEval _pipelineArgInfoTable
|
2023-03-20 12:13:07 +03:00
|
|
|
case r of
|
|
|
|
Left e -> exitJuvixError e
|
|
|
|
Right tab ->
|
|
|
|
embed $ TIO.writeFile (toFilePath coreFile) (show $ Core.ppOutDefault (Core.disambiguateNames tab))
|