diff options
author | Ondřej Čertík <ondrej@certik.us> | 2020-02-28 08:16:03 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 08:16:03 -0800 |
commit | 45cc57a901594eaa94535659e2aafe9971a24c00 (patch) | |
tree | 7a18d600760607d7bde2d4cf2045e45e4bd0ff5e /app | |
parent | 5d38dffc1023cef688e055019fa2569618cf1a4d (diff) | |
parent | 8d8b6ace5f0c2d208e5bfccecd70b6082832bc3e (diff) | |
download | fpm-45cc57a901594eaa94535659e2aafe9971a24c00.tar.gz fpm-45cc57a901594eaa94535659e2aafe9971a24c00.zip |
Merge pull request #42 from everythingfunctional/bpr_add_build_system
Bpr add build system
Diffstat (limited to 'app')
-rw-r--r-- | app/Main.hs | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/app/Main.hs b/app/Main.hs index 9d9c5dc..02d54d6 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,6 +1,24 @@ module Main where -import Options.Applicative +import Build ( buildLibrary + , buildPrograms + ) +import Development.Shake ( FilePattern + , (<//>) + , getDirectoryFilesIO + ) +import Development.Shake.FilePath ( (</>) ) +import Options.Applicative ( Parser + , (<**>) + , command + , execParser + , fullDesc + , info + , header + , helper + , progDesc + , subparser + ) newtype Arguments = Arguments { command' :: Command } @@ -9,13 +27,29 @@ data Command = Run | Test | Build main :: IO () main = do args <- getArguments - run args + app args -run :: Arguments -> IO () -run args = case command' args of +app :: Arguments -> IO () +app args = case command' args of Run -> putStrLn "Run" Test -> putStrLn "Test" - Build -> putStrLn "Build" + Build -> build + +build :: IO () +build = do + putStrLn "Building" + buildLibrary "src" + [".f90", ".f", ".F", ".F90", ".f95", ".f03"] + ("build" </> "library") + "gfortran" + ["-g", "-Wall", "-Wextra", "-Werror", "-pedantic"] + "library" + buildPrograms "app" + ["build" </> "library"] + [".f90", ".f", ".F", ".F90", ".f95", ".f03"] + ("build" </> "app") + "gfortran" + ["-g", "-Wall", "-Wextra", "-Werror", "-pedantic"] getArguments :: IO Arguments getArguments = execParser @@ -41,3 +75,9 @@ testArguments = pure $ Arguments Test buildArguments :: Parser Arguments buildArguments = pure $ Arguments Build + +getDirectoriesFiles :: [FilePath] -> [FilePattern] -> IO [FilePath] +getDirectoriesFiles dirs exts = getDirectoryFilesIO "" newPatterns + where + newPatterns = concatMap appendExts dirs + appendExts dir = map ((dir <//> "*") ++) exts |