Skip to content

Commit

Permalink
tower-aadl, tower-mini: runWriteT for compileUnits
Browse files Browse the repository at this point in the history
  • Loading branch information
sorki committed Dec 17, 2023
1 parent b15a26b commit b5128b8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
11 changes: 9 additions & 2 deletions tower-aadl/src/Tower/AADL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ import Data.Char
import Control.Monad hiding (forever)

import System.FilePath (addExtension, takeFileName, (<.>))
import System.IO (hPutStrLn, stderr)
import System.Exit (exitFailure)

import MonadLib (runWriterT)
import Text.PrettyPrint.Leijen hiding ((</>))
import qualified Text.PrettyPrint

import qualified Ivory.Compile.C.CmdlineFrontend as O
import qualified Ivory.Compile.C.Types as O
Expand Down Expand Up @@ -108,7 +110,12 @@ compileTowerAADLForPlatform fromEnv mkEnv twr' = do

unless (validCIdent appname) $ error $ "appname must be valid c identifier; '"
++ appname ++ "' is not"
cmodules <- O.compileUnits mods copts
(cmodules, errors) <- runWriterT $ O.compileUnits mods copts
hPutStrLn stderr
. Text.PrettyPrint.render
$ Text.PrettyPrint.vcat
errors

let (appMods, libMods) =
partition (\m -> O.unitName m `elem` pkgs) cmodules
O.outputCompiler appMods (as osspecific) (osSpecificOptsApps osspecific cfg copts)
Expand Down
2 changes: 2 additions & 0 deletions tower-aadl/tower-aadl.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ library
, containers
, directory
, filepath
, monadLib >= 3.7
, pretty >= 1.1
, wl-pprint
, ivory >= 0.1.0.2
, ivory-artifact
Expand Down
5 changes: 4 additions & 1 deletion tower-mini/src/Tower/Mini.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ import Data.List (partition)
import MonadLib (forM_, runWriterT, when)
import System.FilePath ((</>))
import System.Exit (exitFailure)
import System.IO (hPutStrLn, stderr)
import Text.PrettyPrint.Mainland ((<+>), putDoc, text)
import Text.PrettyPrint (render, vcat)

import qualified Data.Map as Map

Expand Down Expand Up @@ -241,7 +243,8 @@ compileTowerMini _fromEnv mkEnv comps = do
, outHdrDir = Just (f </> name </> "include")
, outArtDir = Just (f </> name)
}
cmodules <- compileUnits mods copts'
(cmodules, errors) <- runWriterT $ compileUnits mods copts'
hPutStrLn stderr $ render $ vcat errors

let (appMods, libMods) =
partition (\m -> unitName m `elem` packages) cmodules
Expand Down
1 change: 1 addition & 0 deletions tower-mini/tower-mini.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ library
, filepath
, mainland-pretty >= 0.4.0.0
, monadLib
, pretty >= 1.1
, ivory >= 0.1.0.2
, ivory-backend-c
, tower
Expand Down

0 comments on commit b5128b8

Please sign in to comment.