From 3c6440b42b754ca2a14a746012e3592e26ca7782 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Mon, 9 Nov 2020 16:40:59 -0600 Subject: Refactor flag definition for easier support of other compilers --- bootstrap/src/Fpm.hs | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) (limited to 'bootstrap') diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs index de4eafb..db79f5e 100644 --- a/bootstrap/src/Fpm.hs +++ b/bootstrap/src/Fpm.hs @@ -18,6 +18,7 @@ import Control.Monad.Extra ( concatMapM ) import Data.Hashable ( hash ) import Data.List ( intercalate + , isInfixOf , isSuffixOf , find , nub @@ -590,33 +591,7 @@ toml2AppSettings tomlSettings args = do (tomlSettingsExecutables tomlSettings) projectName testSettings <- getTestSettings $ tomlSettingsTests tomlSettings - let flags = if compiler == "gfortran" - 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 + flags <- defineFlags specifiedFlags compiler release buildPrefix <- makeBuildPrefix compiler flags let dependencies = tomlSettingsDependencies tomlSettings let devDependencies = tomlSettingsDevDependencies tomlSettings @@ -631,6 +606,15 @@ toml2AppSettings tomlSettings args = do , appSettingsDevDependencies = devDependencies } +defineFlags :: [String] -> FilePath -> Bool -> IO [String] +defineFlags [] compiler release + | "gfortran" `isInfixOf` compiler = return $ 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"] + | "caf" `isInfixOf` compiler = return $ 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"] + | otherwise = do + putStrLn $ "Sorry, compiler is currently unsupported: " ++ compiler + exitWith (ExitFailure 1) +defineFlags specifiedFlags _ _ = return specifiedFlags + getLibrarySettings :: Maybe Library -> IO (Maybe Library) getLibrarySettings maybeSettings = case maybeSettings of Just settings -> return maybeSettings -- cgit v1.2.3