diff options
-rw-r--r-- | bootstrap/src/Fpm.hs | 86 | ||||
-rw-r--r-- | bootstrap/test/Spec.hs | 7 |
2 files changed, 67 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 diff --git a/bootstrap/test/Spec.hs b/bootstrap/test/Spec.hs index ac72b07..dfa73df 100644 --- a/bootstrap/test/Spec.hs +++ b/bootstrap/test/Spec.hs @@ -21,6 +21,7 @@ testHelloWorld = withCurrentDirectory (example_path </> "hello_world") $ start $ Run { runRelease = False , runCompiler = "gfortran" + , runFlags = [] , runTarget = Nothing , runArgs = Nothing } @@ -30,6 +31,7 @@ testHelloComplex = withCurrentDirectory (example_path </> "hello_complex") $ start $ Test { testRelease = False , testCompiler = "gfortran" + , testFlags = [] , testTarget = Nothing , testArgs = Nothing } @@ -39,6 +41,7 @@ testHelloFpm = withCurrentDirectory (example_path </> "hello_fpm") $ start $ Run { runRelease = False , runCompiler = "gfortran" + , runFlags = [] , runTarget = Nothing , runArgs = Nothing } @@ -48,6 +51,7 @@ testCircular = withCurrentDirectory (example_path </> "circular_example") $ start $ Test { testRelease = False , testCompiler = "gfortran" + , testFlags = [] , testTarget = Nothing , testArgs = Nothing } @@ -57,6 +61,7 @@ testWithMakefile = withCurrentDirectory (example_path </> "with_makefile") $ start $ Build { buildRelease = False , buildCompiler = "gfortran" + , buildFlags = [] } testMakefileComplex :: IO () @@ -64,6 +69,7 @@ testMakefileComplex = withCurrentDirectory (example_path </> "makefile_complex") $ start $ Run { runRelease = False , runCompiler = "gfortran" + , runFlags = [] , runTarget = Nothing , runArgs = Nothing } @@ -73,4 +79,5 @@ testSubmodule = withCurrentDirectory (example_path </> "submodules") $ start $ Build { buildRelease = False , buildCompiler = "gfortran" + , buildFlags = [] } |