aboutsummaryrefslogtreecommitdiff
path: root/Distribution
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2015-09-23 11:10:27 +0200
committerDaniel Gröber <dxld@darkboxed.org>2015-09-23 11:10:27 +0200
commit7c549ba0c4e6e4a99e443eea259d81216459a89f (patch)
tree5f95d96b81be03fbe39e7f6350308f169815d808 /Distribution
parent3484965e347f39e976e0e850a5620354dbffabfc (diff)
Add support for querying flags
Diffstat (limited to 'Distribution')
-rw-r--r--Distribution/Helper.hs39
1 files changed, 36 insertions, 3 deletions
diff --git a/Distribution/Helper.hs b/Distribution/Helper.hs
index d2093ca..279ef42 100644
--- a/Distribution/Helper.hs
+++ b/Distribution/Helper.hs
@@ -44,6 +44,10 @@ module Distribution.Helper (
, ghcMergedPkgOptions
, ghcLangOptions
, pkgLicenses
+ , packageId
+ , flags
+ , configFlags
+ , nonDefaultConfigFlags
-- * Result types
, ChModuleName(..)
@@ -147,7 +151,11 @@ data SomeLocalBuildInfo = SomeLocalBuildInfo {
slbiGhcPkgOptions :: [(ChComponentName, [String])],
slbiGhcMergedPkgOptions :: [String],
slbiGhcLangOptions :: [(ChComponentName, [String])],
- slbiPkgLicenses :: [(String, [(String, Version)])]
+ slbiPkgLicenses :: [(String, [(String, Version)])],
+ slbiPackageId :: (String, Version),
+ slbiFlags :: [(String, Bool)],
+ slbiConfigFlags :: [(String, Bool)],
+ slbiNonDefaultConfigFlags :: [(String, Bool)]
} deriving (Eq, Ord, Read, Show)
-- | Caches helper executable result so it doesn't have to be run more than once
@@ -212,6 +220,20 @@ ghcLangOptions :: MonadIO m => Query m [(ChComponentName, [String])]
-- | Get the licenses of the packages the current project is linking against.
pkgLicenses :: MonadIO m => Query m [(String, [(String, Version)])]
+-- | Package identifier, i.e. package name and version
+packageId :: MonadIO m => Query m (String, Version)
+
+-- | Flag definitions from cabal file
+flags :: MonadIO m => Query m [(String, Bool)]
+
+-- | Flag assignments from setup-config
+configFlags :: MonadIO m => Query m [(String, Bool)]
+
+-- | Flag assignments from setup-config which differ from the default
+-- setting. This can also include flags which cabal decided to modify,
+-- i.e. don't rely on these being the flags set by the user directly.
+nonDefaultConfigFlags :: MonadIO m => Query m [(String, Bool)]
+
packageDbStack = Query $ slbiPackageDbStack `liftM` getSlbi
entrypoints = Query $ slbiEntrypoints `liftM` getSlbi
sourceDirs = Query $ slbiSourceDirs `liftM` getSlbi
@@ -221,6 +243,10 @@ ghcPkgOptions = Query $ slbiGhcPkgOptions `liftM` getSlbi
ghcMergedPkgOptions = Query $ slbiGhcMergedPkgOptions `liftM` getSlbi
ghcLangOptions = Query $ slbiGhcLangOptions `liftM` getSlbi
pkgLicenses = Query $ slbiPkgLicenses `liftM` getSlbi
+packageId = Query $ slbiPackageId `liftM` getSlbi
+flags = Query $ slbiFlags `liftM` getSlbi
+configFlags = Query $ slbiConfigFlags `liftM` getSlbi
+nonDefaultConfigFlags = Query $ slbiNonDefaultConfigFlags `liftM` getSlbi
-- | Run @cabal configure@
reconfigure :: MonadIO m
@@ -260,6 +286,9 @@ getSomeConfigState = ask >>= \QueryEnv {..} -> do
, "ghc-merged-pkg-options"
, "ghc-lang-options"
, "licenses"
+ , "flags"
+ , "config-flags"
+ , "non-default-config-flags"
]
res <- liftIO $ do
@@ -278,11 +307,15 @@ getSomeConfigState = ask >>= \QueryEnv {..} -> do
Just (ChResponseCompList ghcPkgOpts),
Just (ChResponseList ghcMergedPkgOpts),
Just (ChResponseCompList ghcLangOpts),
- Just (ChResponseLicenses pkgLics)
+ Just (ChResponseLicenses pkgLics),
+ Just (ChResponseVersion pkgName pkgVer),
+ Just (ChResponseFlags fls),
+ Just (ChResponseFlags cfls),
+ Just (ChResponseFlags ndcfls)
] = res
return $ SomeLocalBuildInfo
- pkgDbs eps srcDirs ghcOpts ghcSrcOpts ghcPkgOpts ghcMergedPkgOpts ghcLangOpts pkgLics
+ pkgDbs eps srcDirs ghcOpts ghcSrcOpts ghcPkgOpts ghcMergedPkgOpts ghcLangOpts pkgLics (pkgName, pkgVer) fls cfls ndcfls
-- | Make sure the appropriate helper executable for the given project is
-- installed and ready to run queries.