Skip to content
Snippets Groups Projects
Unverified Commit 7b3c91b8 authored by Matthew Pickering's avatar Matthew Pickering Committed by Zubin
Browse files

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 c832ae93)
parent c4d0fd0c
No related branches found
No related tags found
No related merge requests found
......@@ -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"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment