From b5128b8a76c51a36bf4c894a75aaf969959e979f Mon Sep 17 00:00:00 2001 From: sorki Date: Sun, 17 Dec 2023 16:31:04 +0100 Subject: [PATCH] tower-aadl, tower-mini: runWriteT for compileUnits --- tower-aadl/src/Tower/AADL.hs | 11 +++++++++-- tower-aadl/tower-aadl.cabal | 2 ++ tower-mini/src/Tower/Mini.hs | 5 ++++- tower-mini/tower-mini.cabal | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tower-aadl/src/Tower/AADL.hs b/tower-aadl/src/Tower/AADL.hs index 8584e79a..3cd31ddc 100644 --- a/tower-aadl/src/Tower/AADL.hs +++ b/tower-aadl/src/Tower/AADL.hs @@ -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 @@ -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) diff --git a/tower-aadl/tower-aadl.cabal b/tower-aadl/tower-aadl.cabal index fc6bfa02..29787e58 100644 --- a/tower-aadl/tower-aadl.cabal +++ b/tower-aadl/tower-aadl.cabal @@ -29,6 +29,8 @@ library , containers , directory , filepath + , monadLib >= 3.7 + , pretty >= 1.1 , wl-pprint , ivory >= 0.1.0.2 , ivory-artifact diff --git a/tower-mini/src/Tower/Mini.hs b/tower-mini/src/Tower/Mini.hs index a8725111..8857bd4b 100644 --- a/tower-mini/src/Tower/Mini.hs +++ b/tower-mini/src/Tower/Mini.hs @@ -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 @@ -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 diff --git a/tower-mini/tower-mini.cabal b/tower-mini/tower-mini.cabal index 6d86d473..222a9a80 100644 --- a/tower-mini/tower-mini.cabal +++ b/tower-mini/tower-mini.cabal @@ -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