diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2024-08-10 02:45:20 +0200 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2024-08-10 02:45:20 +0200 |
| commit | 68aa2b10c8ad9782a61a6699262751ec5cb93709 (patch) | |
| tree | 8d940e0f884064371c43a1633d44f1a788d5f840 /protocols/codegen/Wayland/CodeGen/BuildGen.hs | |
| parent | ea6a270a481ae9c5ce6d3d2508c61734b8fd137d (diff) | |
wip codegen
Diffstat (limited to 'protocols/codegen/Wayland/CodeGen/BuildGen.hs')
| -rw-r--r-- | protocols/codegen/Wayland/CodeGen/BuildGen.hs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/protocols/codegen/Wayland/CodeGen/BuildGen.hs b/protocols/codegen/Wayland/CodeGen/BuildGen.hs new file mode 100644 index 0000000..42d4b1d --- /dev/null +++ b/protocols/codegen/Wayland/CodeGen/BuildGen.hs @@ -0,0 +1,46 @@ +module Wayland.CodeGen.BuildGen + ( generateBuild + ) where + +import Wayland.CodeGen.Types +import Wayland.CodeGen.Utils + +data ModuleInfo + = ModuleInfo { modProtocol :: !Protocol + , modInterface :: !InterfaceDesc + } + +generateBuild :: [Protocol] -> String +generateBuild protocols = unlines ([ "cabal-version: 3.0" + , "name: highway-protocols" + , "version: 1.0.0" + , "synopsis: Generated bindings for some Wayland protocols." + , "build-type: Simple" + , "" + , "common warnings" + , " ghc-options: -Wall -Wno-unused-imports -Wno-dodgy-exports" + , "" + , "library" + , " import: warnings" + , " build-depends: base," + , " hashable," + , " bytestring," + , " highway-wayland" + , " default-language: Haskell2010" ] + ++ exposedModules (collectModules protocols)) + where exposedModules [] = [] + exposedModules [m] = [" exposed-modules: " ++ formatModule m] + exposedModules (m:ms) = (" exposed-modules: " ++ formatModule m ++ ",") : exposedModules' ms + exposedModules' [m] = [" " ++ formatModule m] + exposedModules' (m:ms) = (" " ++ formatModule m ++ ",") : exposedModules' ms + exposedModules' [] = [] + +formatModule :: ModuleInfo -> String +formatModule m = fullModule (modProtocol m) (modInterface m) + +collectModules :: [Protocol] -> [ModuleInfo] +collectModules = concatMap singleProtocol + where singleProtocol p = fmap (singleInterface p) (protInterfaces p) + singleInterface p i = ModuleInfo { modProtocol = p + , modInterface = i + } |
