aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/src/Fpm.hs
diff options
context:
space:
mode:
authorBrad Richardson <everythingfunctional@protonmail.com>2020-11-09 16:40:59 -0600
committerBrad Richardson <everythingfunctional@protonmail.com>2020-11-09 16:40:59 -0600
commit3c6440b42b754ca2a14a746012e3592e26ca7782 (patch)
tree3f4308b536154a90886ae78733ffaf6dad7d5511 /bootstrap/src/Fpm.hs
parentb38b29f1189d8f5c2dda4980e85b4f0b2b413689 (diff)
downloadfpm-3c6440b42b754ca2a14a746012e3592e26ca7782.tar.gz
fpm-3c6440b42b754ca2a14a746012e3592e26ca7782.zip
Refactor flag definition for easier support of other compilers
Diffstat (limited to 'bootstrap/src/Fpm.hs')
-rw-r--r--bootstrap/src/Fpm.hs38
1 files changed, 11 insertions, 27 deletions
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