summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-02-28 15:19:58 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-03-28 01:16:38 -0400
commitc832ae938e4f8cfd8ad2a0b06fa233df726175f6 (patch)
tree17c8d13c07b016190c360827446c62fc876e6a02
parent25101813905a78010e25ecc3a5f392e2403ae487 (diff)
downloadhaskell-c832ae938e4f8cfd8ad2a0b06fa233df726175f6.tar.gz
hadrian: Flag cabal flag handling
This patch basically deletes some ad-hoc handling of Cabal Flags and replaces it with a correct query of the LocalBuildInfo. The flags in the local build info can be modified by users by passing hadrian options For example (!4331) ``` *.genapply.cabal.configure.opts += --flags=unregisterised ``` And all the flags specified by the `Cabal Flags` builder were already passed to configure properly using `--flags`.
-rw-r--r--hadrian/src/Hadrian/Haskell/Cabal/Parse.hs15
1 files changed, 5 insertions, 10 deletions
diff --git a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
index cee83164a3..2aad4d5de0 100644
--- a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
+++ b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
@@ -216,20 +216,15 @@ resolveContextData context@Context {..} = do
-- Configure the package with the GHC for this stage
(compiler, platform) <- configurePackageGHC package stage
- flagList <- interpret (target context (Cabal Flags stage) [] []) =<< args <$> flavour
- let flags = foldr addFlag mempty flagList
- where
- addFlag :: String -> C.FlagAssignment -> C.FlagAssignment
- addFlag ('-':name) = C.insertFlagAssignment (C.mkFlagName name) False
- addFlag ('+':name) = C.insertFlagAssignment (C.mkFlagName name) True
- addFlag name = C.insertFlagAssignment (C.mkFlagName name) True
-
- let (Right (pd,_)) = C.finalizePD flags C.defaultComponentRequestedSpec
- (const True) platform (C.compilerInfo compiler) [] gpd
cPath <- Context.contextPath context
lbi <- liftIO $ C.getPersistBuildConfig cPath
+ let flags = C.flagAssignment lbi
+
+ (Right (pd,_)) = C.finalizePD flags C.defaultComponentRequestedSpec
+ (const True) platform (C.compilerInfo compiler) [] gpd
+
-- Note: the @cPath@ is ignored. The path that's used is the 'buildDir' path
-- from the local build info @lbi@.
pdi <- liftIO $ getHookedBuildInfo [pkgPath package, cPath -/- "build"]