diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-02-28 15:19:58 +0000 |
---|---|---|
committer | Zubin Duggal <zubin.duggal@gmail.com> | 2022-05-12 11:51:55 +0530 |
commit | 7b3c91b85e6fe6e69af9aaab8b25386e432d51d8 (patch) | |
tree | e501b9e587959141213be6bbf0a6487c1fda95b0 | |
parent | c4d0fd0c0f6557ddd7a01af10169f23f0953ea66 (diff) | |
download | haskell-7b3c91b85e6fe6e69af9aaab8b25386e432d51d8.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`.
(cherry picked from commit c832ae938e4f8cfd8ad2a0b06fa233df726175f6)
-rw-r--r-- | hadrian/src/Hadrian/Haskell/Cabal/Parse.hs | 15 |
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 0c40f770f1..31e3fd70be 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"] |