diff options
Diffstat (limited to 'Setup.hs')
-rw-r--r-- | Setup.hs | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -12,21 +12,28 @@ import System.Environment main :: IO () main = do args <- getArgs let (ghcArgs, args') = extractGhcArgs args - let hooks = defaultUserHooks { + (_, args'') = extractConfigureArgs args' + hooks = defaultUserHooks { buildHook = add_ghc_options ghcArgs $ buildHook defaultUserHooks } - withArgs args' $ defaultMainWithHooks hooks + withArgs args'' $ defaultMainWithHooks hooks extractGhcArgs :: [String] -> ([String], [String]) -extractGhcArgs args +extractGhcArgs = extractPrefixArgs "--ghc-option=" + +extractConfigureArgs :: [String] -> ([String], [String]) +extractConfigureArgs = extractPrefixArgs "--configure-option=" + +extractPrefixArgs :: String -> [String] -> ([String], [String]) +extractPrefixArgs prefix args = let f [] = ([], []) f (x:xs) = case f xs of - (ghcArgs, otherArgs) -> - case removePrefix "--ghc-option=" x of - Just ghcArg -> - (ghcArg:ghcArgs, otherArgs) + (wantedArgs, otherArgs) -> + case removePrefix prefix x of + Just wantedArg -> + (wantedArg:wantedArgs, otherArgs) Nothing -> - (ghcArgs, x:otherArgs) + (wantedArgs, x:otherArgs) in f args removePrefix :: String -> String -> Maybe String |