diff options
author | Brad Richardson <everythingfunctional@protonmail.com> | 2020-10-28 12:49:26 -0500 |
---|---|---|
committer | Brad Richardson <everythingfunctional@protonmail.com> | 2020-10-28 12:49:26 -0500 |
commit | 5d122c2854dbec1470a660bf80cd0544a8806a78 (patch) | |
tree | 22354d18f0200c25222fd1580ffe351414c102c6 /bootstrap/src/Fpm.hs | |
parent | 7b191a773d3a1f91131943a4ed84b285839bdf35 (diff) | |
download | fpm-5d122c2854dbec1470a660bf80cd0544a8806a78.tar.gz fpm-5d122c2854dbec1470a660bf80cd0544a8806a78.zip |
Add command line options to specify compiler flags
Diffstat (limited to 'bootstrap/src/Fpm.hs')
-rw-r--r-- | bootstrap/src/Fpm.hs | 86 |
1 files changed, 60 insertions, 26 deletions
diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs index 49c7ee8..cfb67df 100644 --- a/bootstrap/src/Fpm.hs +++ b/bootstrap/src/Fpm.hs @@ -43,6 +43,7 @@ import Options.Applicative ( Parser , helper , info , long + , many , metavar , optional , progDesc @@ -81,16 +82,19 @@ data Arguments = | Build { buildRelease :: Bool , buildCompiler :: FilePath + , buildFlags :: [String] } | Run { runRelease :: Bool , runCompiler :: FilePath + , runFlags :: [String] , runTarget :: Maybe String , runArgs :: Maybe String } | Test { testRelease :: Bool , testCompiler :: FilePath + , testFlags :: [String] , testTarget :: Maybe String , testArgs :: Maybe String } @@ -384,6 +388,14 @@ buildArguments = <> help "specify the compiler to use" <> showDefault ) + <*> many + (strOption + ( long "flag" + <> metavar "FLAG" + <> help + "specify an addional argument to pass to the compiler (can appear multiple times)" + ) + ) runArguments :: Parser Arguments runArguments = @@ -399,6 +411,14 @@ runArguments = <> help "specify the compiler to use" <> showDefault ) + <*> many + (strOption + ( long "flag" + <> metavar "FLAG" + <> help + "specify an addional argument to pass to the compiler (can appear multiple times)" + ) + ) <*> optional (strArgument (metavar "TARGET" <> help "Name of the executable to run") @@ -420,6 +440,14 @@ testArguments = <> help "specify the compiler to use" <> showDefault ) + <*> many + (strOption + ( long "flag" + <> metavar "FLAG" + <> help + "specify an addional argument to pass to the compiler (can appear multiple times)" + ) + ) <*> optional (strArgument (metavar "TARGET" <> help "Name of the test to run")) <*> optional (strArgument (metavar "ARGS" <> help "Arguments to the test")) @@ -531,38 +559,44 @@ toml2AppSettings tomlSettings args = do let projectName = tomlSettingsProjectName tomlSettings let compiler = case args of Build { buildCompiler = c } -> c - Run { runCompiler = c } -> c - Test { testCompiler = c } -> c + Run { runCompiler = c } -> c + Test { testCompiler = c } -> c + let specifiedFlags = case args of + Build { buildFlags = f } -> f + Run { runFlags = f } -> f + Test { testFlags = f } -> f librarySettings <- getLibrarySettings $ tomlSettingsLibrary tomlSettings executableSettings <- getExecutableSettings (tomlSettingsExecutables tomlSettings) projectName testSettings <- getTestSettings $ tomlSettingsTests tomlSettings let flags = if compiler == "gfortran" - then if release - then - [ "-Wall" - , "-Wextra" - , "-Wimplicit-interface" - , "-fPIC" - , "-fmax-errors=1" - , "-O3" - , "-march=native" - , "-ffast-math" - , "-funroll-loops" - ] - else - [ "-Wall" - , "-Wextra" - , "-Wimplicit-interface" - , "-fPIC" - , "-fmax-errors=1" - , "-g" - , "-fbounds-check" - , "-fcheck-array-temporaries" - , "-fbacktrace" - ] - else [] + then case specifiedFlags of + [] -> if release + then + [ "-Wall" + , "-Wextra" + , "-Wimplicit-interface" + , "-fPIC" + , "-fmax-errors=1" + , "-O3" + , "-march=native" + , "-ffast-math" + , "-funroll-loops" + ] + else + [ "-Wall" + , "-Wextra" + , "-Wimplicit-interface" + , "-fPIC" + , "-fmax-errors=1" + , "-g" + , "-fbounds-check" + , "-fcheck-array-temporaries" + , "-fbacktrace" + ] + flags -> flags + else specifiedFlags buildPrefix <- makeBuildPrefix compiler flags let dependencies = tomlSettingsDependencies tomlSettings let devDependencies = tomlSettingsDevDependencies tomlSettings |