Skip to content

Commit

Permalink
tower-aadl: generate kconfig, kbuild, etc.
Browse files Browse the repository at this point in the history
Also decompose Makefiles.
  • Loading branch information
leepike committed Apr 15, 2015
1 parent 59d141e commit 2011b6f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 6 deletions.
10 changes: 8 additions & 2 deletions tower-aadl/src/Tower/AADL.hs
Expand Up @@ -62,9 +62,15 @@ runCompileAADL opts' t = do
outputAADLDeps (dir </> "AADL_FILES")
(tyPkg ++ thdNames ++ [configSystemName c])
genIvoryCode (ivoryOpts dir) code deps sigs
writeFile (dir </> "Makefile") (makefile (configOpts opts'))
writeFile (dir </> (addExtension "build" "sh")) buildScript
wrFile ramsesMakefileName
(ramsesMakefile (configOpts opts'))
wrFile buildScriptName buildScript
wrFile kbuildName (kbuild dir)
wrFile kconfigName (kconfig dir dir)
wrFile kconfigName (kconfig dir dir)
wrFile makefileName makefile
where
wrFile fName = writeFile (dir </> fName)
go d = outputAADL dir (docName d) r
where r = renderDocPkg (aTypesPkg docs) thdNames d

Expand Down
74 changes: 70 additions & 4 deletions tower-aadl/src/Tower/AADL/Build.hs
Expand Up @@ -5,8 +5,12 @@

module Tower.AADL.Build where

import Data.Char
import Tower.AADL.Config (Config(..))

--------------------------------------------------------------------------------
-- Ramses build

buildScript :: String
buildScript = unlines
[
Expand All @@ -24,12 +28,15 @@ buildScript = unlines
, "java -jar $RAMSES_PATH/ramses.jar -g rtos -i $AADL2RTOS_CONFIG_DIR -o . -l trace -s sys.impl -m SMACCM_SYS.aadl,$AADL_LIST"
]

makefile :: Config -> String
makefile c = unlines
buildScriptName :: String
buildScriptName = "ramses-build.sh"

ramsesMakefile :: Config -> String
ramsesMakefile c = unlines
[
".PHONY: ramses"
, "ramses:"
, tab "sh build.sh"
, tab "sh " ++ buildScriptName
, ""
, ".PHONY: tower-clean"
, "tower-clean:"
Expand All @@ -40,4 +47,63 @@ makefile c = unlines
, tab "-rm -rf " ++ configSrcsDir c
, tab "-rm -rf " ++ configHdrDir c
]
where tab = ('\t' :)

ramsesMakefileName :: String
ramsesMakefileName = "ramses.mk"

--------------------------------------------------------------------------------
-- Kbuild, Kconfig

kbuild :: String -> String
kbuild dir = unlines
[ "apps-$(CONFIG_APP_" ++ shellVar dir ++ ") += " ++ dir
, dir ++ ": libsel4 libmuslc libsel4platsupport libsel4muslccamkes libsel4camkes libsel4sync libsel4debug libsel4bench"
]

kbuildName :: String
kbuildName = "Kbuild"

kconfig :: String -> String -> String
kconfig prog dir = unlines
[ "config APP_" ++ shellVar dir
, " bool \"Generated code for " ++ prog ++ " .\""
, " default n"
, " select APP_CAMKES_EXECUTIVE"
, " help"
, " Generated AADL from " ++ prog
]

kconfigName :: String
kconfigName = "Kconfig"

camkesMakefileName :: String
camkesMakefileName = "camkesmakefile.mk"

otherCamkesTargets :: String
otherCamkesTargets = "othercamkestargets.mk"

makefile :: String
makefile = unlines
[
incl ramsesMakefileName
, incl camkesMakefileName
, incl otherCamkesTargets
, ""
, "camkesMakefileName: " ++ mkTp
, tab $ unwords ["cp ", mkTp, camkesMakefileName]
]
where
mkTp = "make_template/Makefile"
incl = ("-include " ++)

makefileName :: String
makefileName = "Makefile"

--------------------------------------------------------------------------------
-- Helpers

tab :: String -> String
tab = ('\t' :)

shellVar :: String -> String
shellVar = map toUpper

0 comments on commit 2011b6f

Please sign in to comment.