| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | module Gidl.Backend.Tower whereimport Data.List (intercalate)import Ivory.Artifactimport Ivory.Artifact.Templateimport qualified Paths_gidl as Pimport Gidl.Typesimport Gidl.Interfaceimport Gidl.Schemaimport Gidl.Backend.Cabalimport Gidl.Backend.Ivory (dotwords, ivorySources)import Gidl.Backend.Tower.InterfacetowerBackend :: TypeEnv -> InterfaceEnv -> String -> String -> [Artifact]towerBackend te ie pkgname namespace_raw =  [ cabalFileArtifact cf  , makefile  , defaultconf  , artifactPath "tests" (codegenTest namespace)  ] ++ map (artifactPath "src") sources  where  namespace = dotwords namespace_raw  sources = isources ++ tsources  tsources = towerSources ie (namespace ++ ["Tower"])  isources = ivorySources te ie (namespace ++ ["Ivory"])  cf = (defaultCabalFile pkgname cabalmods deps) { executables = [ cg_exe ] }  cabalmods = map (filePathToPackage . artifactFileName) sources  deps = words "ivory ivory-stdlib ivory-serialize tower"  cg_exe = defaultCabalExe (pkgname ++ "-gen") "CodeGen.hs"            (deps ++ (words "tower-config tower-freertos-stm32") ++ [pkgname])towerSources :: InterfaceEnv -> [String] -> [Artifact]towerSources (InterfaceEnv ie) namespace = towerInterfaces  where  towerInterfaces = concat    [ [ interfaceModule (namespace ++ ["Tower", "Interface"]) i (producerSchema i)      , interfaceModule (namespace ++ ["Tower", "Interface"]) i (consumerSchema i) ]    | (_iname, i) <- ie ]makefile :: Artifactmakefile = artifactCabalFile P.getDataDir "support/tower/Makefile"defaultconf :: Artifactdefaultconf = artifactCabalFile P.getDataDir "support/tower/default.conf"codegenTest :: [String] -> ArtifactcodegenTest modulepath =  artifactCabalFileTemplate P.getDataDir fname    [("module_path", intercalate "." modulepath )]  where  fname = "support/tower/CodeGen.hs.template"
 |