From 775841b8437adf4f400a21fa939156dc6ef48cc2 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Thu, 27 Feb 2020 10:22:38 -0800 Subject: Enable building a library --- app/Main.hs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/Main.hs b/app/Main.hs index 68cef7c..e1451af 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,5 +1,10 @@ module Main where +import Build ( buildLibrary ) +import Development.Shake ( FilePattern + , () + , getDirectoryFilesIO + ) import Options.Applicative ( Parser , (<**>) , command @@ -19,13 +24,23 @@ 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" + "gfortran" + ["-g", "-Wall", "-Wextra", "-Werror", "-pedantic"] + "library" getArguments :: IO Arguments getArguments = execParser @@ -51,3 +66,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 -- cgit v1.2.3