diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2024-08-08 23:59:07 +0200 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2024-08-08 23:59:07 +0200 |
| commit | ea6a270a481ae9c5ce6d3d2508c61734b8fd137d (patch) | |
| tree | 7431f52229e0c2c19c05dd8131362b3755443947 /protocols/codegen/Main.hs | |
| parent | 539930f228d9dda1fe3462e5a6d913061dc6a652 (diff) | |
parse protocol spec
Diffstat (limited to 'protocols/codegen/Main.hs')
| -rw-r--r-- | protocols/codegen/Main.hs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/protocols/codegen/Main.hs b/protocols/codegen/Main.hs index d3230a6..98e9d62 100644 --- a/protocols/codegen/Main.hs +++ b/protocols/codegen/Main.hs @@ -1,2 +1,25 @@ +import System.Environment (getArgs) +import System.Exit (exitFailure) +import System.Directory (listDirectory) +import System.FilePath ((</>), takeExtension) +import Wayland.CodeGen.Types +import Wayland.CodeGen.Parser + main :: IO () -main = putStrLn "Generating code" +main = do + args <- getArgs + case args of + [dir] -> generate dir + _ -> do putStrLn "Usage: highway-protocols-codegen <protocols-dir>" + exitFailure + +generate :: FilePath -> IO () +generate dir = do + let srcDir = dir </> "src" + protocolSpecs <- filter (\p -> takeExtension p == ".xml") . fmap (srcDir </>) <$> listDirectory srcDir + protocols <- mapM readProtocol protocolSpecs + print protocols + pure () + +readProtocol :: FilePath -> IO (Either String Protocol) +readProtocol path = parseProtocolSpec <$> readFile path |
