aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorBrad Richardson <brichardson@structint.com>2020-03-31 15:00:49 -0500
committerBrad Richardson <brichardson@structint.com>2020-03-31 15:00:49 -0500
commitcff70a2c97d26e64c65c391ec2121df90196b6cd (patch)
tree997d391599bee37693575748c6456d0e8b0588c3 /app
parent8b5aebc74fde829c7c22203b96d592f8e67b9272 (diff)
downloadfpm-cff70a2c97d26e64c65c391ec2121df90196b6cd.tar.gz
fpm-cff70a2c97d26e64c65c391ec2121df90196b6cd.zip
Make library settings optional
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs56
1 files changed, 33 insertions, 23 deletions
diff --git a/app/Main.hs b/app/Main.hs
index a80e8f7..974c7a6 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -36,13 +36,13 @@ data TomlSettings = TomlSettings {
tomlSettingsCompiler :: !Text
, tomlSettingsProjectName :: !Text
, tomlSettingsDebugOptions :: ![Text]
- , tomlSettingsLibrary :: !Library }
+ , tomlSettingsLibrary :: !(Maybe Library) }
data AppSettings = AppSettings {
appSettingsCompiler :: !Text
, appSettingsProjectName :: !Text
, appSettingsDebugOptions :: ![Text]
- , appSettingsLibrary :: !Library }
+ , appSettingsLibrary :: !(Maybe Library) }
data Library = Library { librarySourceDir :: !Text }
@@ -68,26 +68,36 @@ app args settings = case command' args of
build :: AppSettings -> IO ()
build settings = do
putStrLn "Building"
- let compiler = unpack $ appSettingsCompiler settings
- let projectName = unpack $ appSettingsProjectName settings
- let flags = map unpack $ appSettingsDebugOptions settings
- let librarySettings = appSettingsLibrary settings
- let librarySourceDir' = unpack $ librarySourceDir librarySettings
- buildLibrary librarySourceDir'
- [".f90", ".f", ".F", ".F90", ".f95", ".f03"]
- ("build" </> "library")
- compiler
- flags
- projectName
- []
- buildProgram "app"
- ["build" </> "library"]
- [".f90", ".f", ".F", ".F90", ".f95", ".f03"]
- ("build" </> "app")
- compiler
- flags
- projectName
- "main.f90"
+ let compiler = unpack $ appSettingsCompiler settings
+ let projectName = unpack $ appSettingsProjectName settings
+ let flags = map unpack $ appSettingsDebugOptions settings
+ case appSettingsLibrary settings of
+ Just librarySettings -> do
+ let librarySourceDir' = unpack $ librarySourceDir librarySettings
+ buildLibrary librarySourceDir'
+ [".f90", ".f", ".F", ".F90", ".f95", ".f03"]
+ ("build" </> "library")
+ compiler
+ flags
+ projectName
+ []
+ buildProgram "app"
+ ["build" </> "library"]
+ [".f90", ".f", ".F", ".F90", ".f95", ".f03"]
+ ("build" </> "app")
+ compiler
+ flags
+ projectName
+ "main.f90"
+ Nothing -> do
+ buildProgram "app"
+ []
+ [".f90", ".f", ".F", ".F90", ".f95", ".f03"]
+ ("build" </> "app")
+ compiler
+ flags
+ projectName
+ "main.f90"
getArguments :: IO Arguments
getArguments = execParser
@@ -129,7 +139,7 @@ settingsCodec =
.= tomlSettingsProjectName
<*> Toml.arrayOf Toml._Text "debug-options"
.= tomlSettingsDebugOptions
- <*> Toml.table libraryCodec "library"
+ <*> Toml.dioptional (Toml.table libraryCodec "library")
.= tomlSettingsLibrary
libraryCodec :: TomlCodec Library