aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Main.hs13
-rw-r--r--example_project/fpm.toml3
2 files changed, 12 insertions, 4 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 974c7a6..8d07c40 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -25,6 +25,7 @@ import Options.Applicative ( Parser
, progDesc
, subparser
)
+import System.Directory ( doesDirectoryExist )
import Toml ( TomlCodec
, (.=)
)
@@ -147,9 +148,19 @@ libraryCodec = Library <$> Toml.text "source-dir" .= librarySourceDir
toml2AppSettings :: TomlSettings -> IO AppSettings
toml2AppSettings tomlSettings = do
+ librarySettings <- getLibrarySettings $ tomlSettingsLibrary tomlSettings
return AppSettings
{ appSettingsCompiler = tomlSettingsCompiler tomlSettings
, appSettingsProjectName = tomlSettingsProjectName tomlSettings
, appSettingsDebugOptions = tomlSettingsDebugOptions tomlSettings
- , appSettingsLibrary = tomlSettingsLibrary tomlSettings
+ , appSettingsLibrary = librarySettings
}
+
+getLibrarySettings :: Maybe Library -> IO (Maybe Library)
+getLibrarySettings maybeSettings = case maybeSettings of
+ Just settings -> return maybeSettings
+ Nothing -> do
+ defaultExists <- doesDirectoryExist "src"
+ if defaultExists
+ then return (Just (Library { librarySourceDir = "src" }))
+ else return Nothing
diff --git a/example_project/fpm.toml b/example_project/fpm.toml
index a8bded7..fae3512 100644
--- a/example_project/fpm.toml
+++ b/example_project/fpm.toml
@@ -9,9 +9,6 @@ compiler = "gfortran"
debug-options = ["-g", "-Wall", "-Wextra", "-Werror", "-pedantic"]
release-options = ["-O3"]
-[library]
- source-dir = "src"
-
[executables.example_project]
main = "main.f90"
source-dir = "app"