aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Main.hs44
-rw-r--r--example_project/fpm.toml7
2 files changed, 37 insertions, 14 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 3ad22d1..a6f3ea2 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -32,7 +32,13 @@ import qualified Toml
newtype Arguments = Arguments { command' :: Command }
-data Settings = Settings { compiler :: !Text }
+data Settings = Settings {
+ settingsCompiler :: !Text
+ , settingsProjectName :: !Text
+ , settingsDebugOptions :: ![Text]
+ , settingsLibrary :: !Library }
+
+data Library = Library { librarySourceDir :: !Text }
data Command = Run | Test | Build
@@ -43,7 +49,8 @@ main = do
let settings = Toml.decode settingsCodec fpmContents
case settings of
Left err -> print err
- Right settings -> app args settings
+ Right settings -> do
+ app args settings
app :: Arguments -> Settings -> IO ()
app args settings = case command' args of
@@ -54,20 +61,25 @@ app args settings = case command' args of
build :: Settings -> IO ()
build settings = do
putStrLn "Building"
- buildLibrary "src"
+ let compiler = unpack $ settingsCompiler settings
+ let projectName = unpack $ settingsProjectName settings
+ let flags = map unpack $ settingsDebugOptions settings
+ let librarySettings = settingsLibrary settings
+ let librarySourceDir' = unpack $ librarySourceDir librarySettings
+ buildLibrary librarySourceDir'
[".f90", ".f", ".F", ".F90", ".f95", ".f03"]
("build" </> "library")
- (unpack $ compiler settings)
- ["-g", "-Wall", "-Wextra", "-Werror", "-pedantic"]
- "library"
+ compiler
+ flags
+ projectName
[]
buildProgram "app"
["build" </> "library"]
[".f90", ".f", ".F", ".F90", ".f95", ".f03"]
("build" </> "app")
- (unpack $ compiler settings)
- ["-g", "-Wall", "-Wextra", "-Werror", "-pedantic"]
- "example_project"
+ compiler
+ flags
+ projectName
"main.f90"
getArguments :: IO Arguments
@@ -102,4 +114,16 @@ getDirectoriesFiles dirs exts = getDirectoryFilesIO "" newPatterns
appendExts dir = map ((dir <//> "*") ++) exts
settingsCodec :: TomlCodec Settings
-settingsCodec = Settings <$> Toml.text "compiler" .= compiler
+settingsCodec =
+ Settings
+ <$> Toml.text "compiler"
+ .= settingsCompiler
+ <*> Toml.text "name"
+ .= settingsProjectName
+ <*> Toml.arrayOf Toml._Text "debug-options"
+ .= settingsDebugOptions
+ <*> Toml.table libraryCodec "library"
+ .= settingsLibrary
+
+libraryCodec :: TomlCodec Library
+libraryCodec = Library <$> Toml.text "source-dir" .= librarySourceDir
diff --git a/example_project/fpm.toml b/example_project/fpm.toml
index 5ad7e97..a8bded7 100644
--- a/example_project/fpm.toml
+++ b/example_project/fpm.toml
@@ -6,14 +6,13 @@ maintainer = "example@example.com"
copyright = "2020 Author"
dependencies = []
compiler = "gfortran"
-devel-options = ["-g", "-Wall", "-Wextra", "-Werror", "-pedantic"]
+debug-options = ["-g", "-Wall", "-Wextra", "-Werror", "-pedantic"]
release-options = ["-O3"]
[library]
-source-dirs = "src"
+ source-dir = "src"
[executables.example_project]
main = "main.f90"
-source-dirs = "app"
-linker-options = ["-O3"]
+source-dir = "app"
dependencies = []