diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-02-28 15:19:58 +0000 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2022-03-23 11:49:38 +0000 |
commit | 37e8b4c83843d1a7283668180fd4f7955b853c3c (patch) | |
tree | b82303c276a56db880da9fd15540e47f2589cadd | |
parent | 52ffd38c610f418ee1d1a549cfdfdaa11794ea40 (diff) | |
download | haskell-37e8b4c83843d1a7283668180fd4f7955b853c3c.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.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 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"] |