Created
February 6, 2014 02:46
-
-
Save lpsmith/8837629 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Distribution.Simple | |
import Distribution.Simple.Setup | |
import Distribution.Simple.LocalBuildInfo | |
import Distribution.PackageDescription | |
import Distribution.Version | |
import Text.Groom | |
-- This checks the direct dependency of the bytestring package being | |
-- compiled against to set the bytestring_has_itoa_c and | |
-- bytestring_has_builder flags accordingly. | |
main = defaultMainWithHooks simpleUserHooks { | |
confHook = \pkg flags -> do | |
putStr "pkg:\n\n" | |
putStr (groom pkg) | |
putStr "\n\n\nflags:\n\n" | |
putStr (groom flags) | |
if null (configConstraints flags) | |
then do | |
lbi <- confHook simpleUserHooks pkg flags | |
putStr "\n\n\nlbi:\n\n" | |
putStr (groom lbi) | |
putStr "\n" | |
return lbi | |
else do | |
let bytestring_version = | |
case [ versionBranch v | |
| (Dependency pkg ver) <- configConstraints flags | |
, pkg == PackageName "bytestring" | |
, (Just v) <- [isSpecificVersion ver] ] | |
of | |
[v] -> v | |
vs -> error ("error detecting bytestring version " ++ show vs) | |
putStr "\n\n\nbytestring_version: " | |
putStr (groom bytestring_version) | |
let has_itoa_c = ( FlagName "bytestring_has_itoa_c" | |
, bytestring_version >= [0,10] ) | |
let has_builder = ( FlagName "bytestring_has_builder" | |
, bytestring_version >= [0,10,4] ) | |
let update fs gs = | |
fs ++ [ g | g <- gs, not $ any (\f -> fst f == fst g) fs] | |
let flags' = flags { configConfigurationsFlags = | |
update [has_itoa_c, has_builder] | |
(configConfigurationsFlags flags) } | |
putStr "\n\nconfigConfigurationsFlags flags':\n\n" | |
putStr (groom (configConfigurationsFlags flags')) | |
putStr "\n\n" | |
lbi' <- confHook simpleUserHooks pkg flags' | |
putStr "\n\nlbi':\n\n" | |
putStr (groom lbi') | |
putStr "\n" | |
return lbi' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment