aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorBrad Richardson <brichardson@structint.com>2020-04-11 13:48:40 -0500
committerBrad Richardson <brichardson@structint.com>2020-04-11 13:48:40 -0500
commite7f04140aea8d05b3ba450841c4ac8c39326ecfb (patch)
treec933444e2067424ee4f2962b6a9b24175d185b67 /app
parentae3ab0973aab3d443c937bf4edab25933e0df931 (diff)
downloadfpm-e7f04140aea8d05b3ba450841c4ac8c39326ecfb.tar.gz
fpm-e7f04140aea8d05b3ba450841c4ac8c39326ecfb.zip
add settings for executables
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs50
1 files changed, 32 insertions, 18 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 9e3f264..c4aee75 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -45,10 +45,16 @@ data AppSettings = AppSettings {
appSettingsCompiler :: !Text
, appSettingsProjectName :: !Text
, appSettingsFlags :: ![Text]
- , appSettingsLibrary :: !(Maybe Library) }
+ , appSettingsLibrary :: !(Maybe Library)
+ , appSettingsExecutables :: ![Executable] }
data Library = Library { librarySourceDir :: !Text }
+data Executable = Executable {
+ executableSourceDir :: !Text
+ , executableMainFile :: !Text
+ , executableName :: !Text }
+
data Command = Run | Test | Build
main :: IO ()
@@ -74,7 +80,8 @@ build settings = do
let compiler = unpack $ appSettingsCompiler settings
let projectName = unpack $ appSettingsProjectName settings
let flags = map unpack $ appSettingsFlags settings
- case appSettingsLibrary settings of
+ let executables = appSettingsExecutables settings
+ executableDepends <- case appSettingsLibrary settings of
Just librarySettings -> do
let librarySourceDir' = unpack $ librarySourceDir librarySettings
buildLibrary librarySourceDir'
@@ -84,23 +91,25 @@ build settings = do
flags
projectName
[]
- buildProgram "app"
- ["build" </> "library"]
- [".f90", ".f", ".F", ".F90", ".f95", ".f03"]
- ("build" </> "app")
- compiler
- flags
- projectName
- "main.f90"
+ return ["build" </> "library"]
Nothing -> do
- buildProgram "app"
- []
- [".f90", ".f", ".F", ".F90", ".f95", ".f03"]
- ("build" </> "app")
- compiler
- flags
- projectName
- "main.f90"
+ return []
+ mapM_
+ (\Executable { executableSourceDir = sourceDir, executableMainFile = mainFile, executableName = name } ->
+ do
+ let sourceDir' = unpack sourceDir
+ let name' = unpack name
+ let mainFile' = unpack mainFile
+ buildProgram sourceDir'
+ executableDepends
+ [".f90", ".f", ".F", ".F90", ".f95", ".f03"]
+ ("build" </> sourceDir')
+ compiler
+ flags
+ name'
+ mainFile'
+ )
+ executables
getArguments :: IO Arguments
getArguments = execParser
@@ -182,6 +191,11 @@ toml2AppSettings tomlSettings release = do
, "-fbacktrace"
]
, appSettingsLibrary = librarySettings
+ , appSettingsExecutables = [ Executable { executableSourceDir = "app"
+ , executableName = "example_project"
+ , executableMainFile = "main.f90"
+ }
+ ]
}
getLibrarySettings :: Maybe Library -> IO (Maybe Library)