From 7b3c91b85e6fe6e69af9aaab8b25386e432d51d8 Mon Sep 17 00:00:00 2001 From: Matthew Pickering <matthewtpickering@gmail.com> Date: Mon, 28 Feb 2022 15:19:58 +0000 Subject: [PATCH] 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`. (cherry picked from commit c832ae938e4f8cfd8ad2a0b06fa233df726175f6) --- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs index 0c40f770f180..31e3fd70bed9 100644 --- a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs +++ b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs @@ -213,20 +213,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"] -- GitLab