Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Use Cabal directly in place of ghc-cabal + make build root configurable #531

Merged
merged 28 commits into from
Mar 30, 2018
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
df9ffa8
Use Cabal directly in place of ghc-cabal; make build root configurable.
alpmestan Feb 23, 2018
8298dad
fix documentation rules
alpmestan Mar 19, 2018
42f5b6f
remove some leftover unrelated, commented-out code
alpmestan Mar 19, 2018
0f85e35
more documentation fixes, address some feedback
alpmestan Mar 20, 2018
e23a3d9
cleanup
alpmestan Mar 21, 2018
c99df2c
more cleanup
alpmestan Mar 21, 2018
edb7fa9
boot and configure explicitly in travis CI scripts
alpmestan Mar 21, 2018
e8daefc
update cabal/ghc versions in .travis.yml (8.0.x not supported anymore)
alpmestan Mar 21, 2018
cab4c6d
temporarily disable dynamic ways in Settings.Default
alpmestan Mar 22, 2018
6c29fe2
update appveyor script
alpmestan Mar 22, 2018
e4204f1
travis: when booting with 8.2.2, build a complete stage2 compiler
alpmestan Mar 22, 2018
3c5da99
Fix CI?
angerman Mar 23, 2018
6052655
Update Quickest.hs
angerman Mar 23, 2018
7764235
Update .travis.yml
angerman Mar 23, 2018
9451654
Update .travis.yml
angerman Mar 23, 2018
81c736d
[travis] os x: test the freshly built ghc
alpmestan Mar 23, 2018
a89b21f
Get rid of two unused GhcCabalMode constructors
alpmestan Mar 26, 2018
7f5753c
fix ghc-split rule, get rid of Install/Wrappers rules
alpmestan Mar 27, 2018
6df0c57
address more feedback
alpmestan Mar 28, 2018
65de601
ConfiguredCabal -> PackageData, more comments, more feedback addressed
alpmestan Mar 28, 2018
cb4fbc7
make the complete stage 2 build the default
alpmestan Mar 28, 2018
7818701
use a dummy package instead of base in Rules.hs
alpmestan Mar 28, 2018
a736fde
update CI scripts
alpmestan Mar 28, 2018
75c6aac
attempt at fixing hadrian's -c option
alpmestan Mar 28, 2018
894a197
.travis.yml: use -c everywhere again
alpmestan Mar 29, 2018
03eda8a
travis: back to explicit './boot && ./configure'
alpmestan Mar 29, 2018
770be1c
update README.md and doc/user-settings.md to reflect configurable bui…
alpmestan Mar 30, 2018
c569957
some more feedback
alpmestan Mar 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ConfiguredCabal -> PackageData, more comments, more feedback addressed
alpmestan committed Mar 28, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 65de6012c1f76a6850bc84c9f856e2ab97328e10
2 changes: 1 addition & 1 deletion hadrian.cabal
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ executable hadrian
, Hadrian.Builder.Tar
, Hadrian.Expression
, Hadrian.Haskell.Cabal
, Hadrian.Haskell.Cabal.Configured
, Hadrian.Haskell.Cabal.PackageData
, Hadrian.Haskell.Cabal.Parse
, Hadrian.Haskell.Cabal.Type
, Hadrian.Oracles.ArgsHash
17 changes: 8 additions & 9 deletions src/Builder.hs
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@ module Builder (
ArMode (..), CcMode (..), GhcCabalMode (..), GhcMode (..), GhcPkgMode (..), HaddockMode (..),
SphinxMode (..), TarMode (..), Builder (..),

builderPath',

-- * Builder properties
builderProvenance, systemBuilderPath, builderPath, isSpecified, needBuilder,
runBuilder, runBuilderWith, runBuilderWithCmdOptions, getBuilderPath,
@@ -55,7 +53,7 @@ instance Binary GhcMode
instance Hashable GhcMode
instance NFData GhcMode

-- | GHC cabal mode. Can configure, copy and register pacakges.
-- | GHC cabal mode. Can configure, copy and register packages.
data GhcCabalMode = Conf | HsColour | Check | Sdist
deriving (Eq, Generic, Show)

@@ -167,9 +165,6 @@ builderProvenance = \case
where
context s p = Just $ vanillaContext s p

builderPath' :: Builder -> Action FilePath
builderPath' = builderPath

instance H.Builder Builder where
builderPath :: Builder -> Action FilePath
builderPath builder = case builderProvenance builder of
@@ -199,7 +194,7 @@ instance H.Builder Builder where
-- query the builder for some information.
-- contrast this with runBuilderWith, which returns @Action ()@
-- this returns the @stdout@ from running the builder.
-- For now this only implements asking @ghc-pkg@ about pacakge
-- For now this only implements asking @ghc-pkg@ about package
-- dependencies.
askBuilderWith :: Builder -> BuildInfo -> Action String
askBuilderWith builder BuildInfo {..} = case builder of
@@ -262,8 +257,12 @@ instance H.Builder Builder where
unit $ cmd [Cwd output] [path] buildArgs

GhcPkg Clone _ -> do
-- input is "virtual" here. it's essentially a package name
Stdout pkgDesc <- cmd [path] ["--expand-pkgroot", "--no-user-package-db", "describe", input ]
Stdout pkgDesc <- cmd [path]
[ "--expand-pkgroot"
, "--no-user-package-db"
, "describe"
, input -- the package name
]
cmd (Stdin pkgDesc) [path] (buildArgs ++ ["-"])

_ -> cmd echo [path] buildArgs
3 changes: 0 additions & 3 deletions src/Builder.hs-boot
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import Stage
import Hadrian.Builder.Ar
import Hadrian.Builder.Sphinx
import Hadrian.Builder.Tar
import Development.Shake

data CcMode = CompileC | FindCDependencies
data GhcMode = CompileHs | CompileCWithGhc | FindHsDependencies | LinkHs
@@ -45,5 +44,3 @@ data Builder = Alex

instance Eq Builder
instance Show Builder

builderPath' :: Builder -> Action FilePath
2 changes: 1 addition & 1 deletion src/Context/Paths.hs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ buildDir context = contextDir context -/- "build"

-- | Path to the directory containing build artifacts of a given 'Context'.
buildPath :: Context -> Action FilePath
buildPath context = buildRoot <&> (-/- (buildDir context))
buildPath context = buildRoot <&> (-/- buildDir context)

-- | Get the build path of the current 'Context'.
getBuildPath :: Expr Context b FilePath
12 changes: 6 additions & 6 deletions src/Expression.hs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ module Expression (

-- * Convenient accessors
getBuildRoot, getContext, getOutputs, getInputs,
getInput, getOutput, getConfiguredCabalData,
getInput, getOutput, getPackageData,

-- * Re-exports
module Base,
@@ -27,14 +27,14 @@ import {-# SOURCE #-} Builder
import Context hiding (stage, package, way)
import Expression.Type
import Hadrian.Expression hiding (Expr, Predicate, Args)
import Hadrian.Haskell.Cabal.Configured (ConfiguredCabal)
import Hadrian.Oracles.TextFile (readConfiguredCabalFile)
import Hadrian.Haskell.Cabal.PackageData (PackageData)
import Hadrian.Oracles.TextFile (readPackageDataFile)

-- | Get values from a configured cabal stage.
getConfiguredCabalData :: (ConfiguredCabal -> a) -> Expr a
getConfiguredCabalData key = do
getPackageData :: (PackageData -> a) -> Expr a
getPackageData key = do
ctx <- getContext
Just cabal <- expr (readConfiguredCabalFile ctx)
Just cabal <- expr (readPackageDataFile ctx)
return $ key cabal

-- | Is the build currently in the provided stage?
9 changes: 5 additions & 4 deletions src/Hadrian/Haskell/Cabal.hs
Original file line number Diff line number Diff line change
@@ -13,11 +13,12 @@ module Hadrian.Haskell.Cabal (
pkgVersion, pkgIdentifier, pkgDependencies, pkgSynopsis
) where

import Data.Maybe
import Development.Shake

import Context.Type
import Hadrian.Haskell.Cabal.Type as C
import Hadrian.Haskell.Cabal.Configured as CC
import Hadrian.Haskell.Cabal.Type as C
import Hadrian.Haskell.Cabal.PackageData as PD
import Hadrian.Package
import Hadrian.Oracles.TextFile

@@ -29,7 +30,7 @@ pkgVersion = fmap (fmap C.version) . readCabalFile
-- The Cabal file is tracked.
pkgIdentifier :: Context -> Action String
pkgIdentifier ctx = do
Just cabal <- readCabalFile ctx
cabal <- fromMaybe (error "Cabal file could not be read") <$> readCabalFile ctx
return $ if null (C.version cabal)
then C.name cabal
else C.name cabal ++ "-" ++ C.version cabal
@@ -39,7 +40,7 @@ pkgIdentifier ctx = do
-- returns a crude overapproximation of actual dependencies. The Cabal file is
-- tracked.
pkgDependencies :: Context -> Action (Maybe [PackageName])
pkgDependencies = fmap (fmap CC.dependencies) . readConfiguredCabalFile
pkgDependencies = fmap (fmap PD.dependencies) . readPackageDataFile

-- | Read a Cabal file and return the package synopsis. The Cabal file is tracked.
pkgSynopsis :: Context -> Action (Maybe String)
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module Hadrian.Haskell.Cabal.Configured where
module Hadrian.Haskell.Cabal.PackageData where

import Development.Shake.Classes
import Hadrian.Package.Type
import GHC.Generics

data ConfiguredCabal = ConfiguredCabal
data PackageData = PackageData
{ dependencies :: [PackageName]
, name :: PackageName
, version :: String
-- , packageDesc :: C.PackageDescription
-- * used to be pkg Data
, componentId :: String
, modules :: [String]
@@ -22,7 +21,7 @@ data ConfiguredCabal = ConfiguredCabal
, depCompIds :: [String]
, includeDirs :: [String]
, includes :: [String]
, installIncludes :: [String] -- TODO: do we need this one?
, installIncludes :: [String]
, extraLibs :: [String]
, extraLibDirs :: [String]
, asmSrcs :: [String]
@@ -41,7 +40,7 @@ data ConfiguredCabal = ConfiguredCabal
, buildGhciLib :: Bool
} deriving (Eq, Read, Show, Typeable, Generic)

instance Binary ConfiguredCabal
instance Binary PackageData

instance Hashable ConfiguredCabal
instance NFData ConfiguredCabal
instance Hashable PackageData
instance NFData PackageData
37 changes: 27 additions & 10 deletions src/Hadrian/Haskell/Cabal/Parse.hs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
-- Extracting Haskell package metadata stored in Cabal files.
-----------------------------------------------------------------------------
module Hadrian.Haskell.Cabal.Parse
( ConfiguredCabal (..), parseCabal, parseConfiguredCabal
( PackageData (..), parseCabal, parsePackageData
, parseCabalPkgId
, configurePackage, copyPackage, registerPackage
) where
@@ -42,17 +42,19 @@ import qualified Distribution.Verbosity as C

import Base
import Builder hiding (Builder)
import Context -- .Type
import Context
import Flavour (args)
import GHC.Packages (rts)
import Hadrian.Expression
import Hadrian.Haskell.Cabal.PackageData
import Hadrian.Haskell.Cabal.Type ( Cabal( Cabal ) )
import Hadrian.Haskell.Cabal.Configured
import Hadrian.Oracles.TextFile
import Hadrian.Target
import Settings
import Oracles.Setting

-- | Parse the Cabal package identifier from the .cabal file at the given
-- filepath.
parseCabalPkgId :: FilePath -> IO String
parseCabalPkgId file = C.display . C.package . C.packageDescription <$> C.readGenericPackageDescription C.silent file

@@ -75,6 +77,12 @@ biModules pd = go [ comp | comp@(bi,_) <- (map libBiModules . maybeToList $ C.li
go _ = error "can not handle more than one buildinfo yet!"
isHaskell fp = takeExtension fp `elem` [".hs", ".lhs"]

-- | Parse the cabal file of the package from the given 'Context'.
--
-- This function reads the cabal file, gets some information about the compiler
-- to be used corresponding to the stage it gets from the 'Context', and finalizes
-- the package description it got from the cabal file with the additional information
-- it got (e.g platform, compiler version conditionals, package flags).
parseCabal :: Context -> Action Cabal
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments to all exported functions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in an upcoming commit.

parseCabal context@Context {..} = do
let (Just file) = pkgCabalFile package
@@ -83,7 +91,7 @@ parseCabal context@Context {..} = do
gpd <- liftIO $ C.readGenericPackageDescription C.verbose file

-- configure the package with the ghc compiler for this stage.
hcPath <- builderPath' (Ghc CompileHs stage)
hcPath <- builderPath (Ghc CompileHs stage)
(compiler, Just platform, _pgdb) <- liftIO $ GHC.configure C.silent (Just hcPath) Nothing Db.emptyProgramDb


@@ -109,6 +117,12 @@ parseCabal context@Context {..} = do
pd
depPkgs

-- | This function runs the equivalent of @cabal configure@ using the Cabal library
-- directly, collecting all the configuration options and flags to be passed to Cabal
-- before invoking it.
--
-- It of course also 'need's package database entries for the dependencies of
-- the package the 'Context' points to.
configurePackage :: Context -> Action ()
configurePackage context@Context {..} = do
Just (Cabal _ _ _ gpd _pd depPkgs) <- readCabalFile context
@@ -148,7 +162,9 @@ configurePackage context@Context {..} = do
liftIO $ do
Hooks.defaultMainWithHooksNoReadArgs hooks gpd (argList ++ ["--flags=" ++ unwords flagList])

-- XXX: move this somewhere else. This is logic from ghc-cabal
-- | Copies a built package (that the 'Context' points to) into a package
-- database (the one for the ghc corresponding to the stage the 'Context'
-- points to).
copyPackage :: Context -> Action ()
copyPackage context@Context {..} = do
-- original invocation
@@ -164,6 +180,8 @@ copyPackage context@Context {..} = do

liftIO $ Hooks.defaultMainWithHooksNoReadArgs hooks gpd ["copy", "--builddir", ctxPath, "--target-package-db", pkgDbPath]

-- | Registers a built package (the one the 'Context' points to)
-- into the package database.
registerPackage :: Context -> Action ()
registerPackage context@Context {..} = do
top <- topDirectory
@@ -175,9 +193,9 @@ registerPackage context@Context {..} = do
liftIO $
Hooks.defaultMainWithHooksNoReadArgs regHooks gpd ["register", "--builddir", ctxPath]

-- | Parse a ConfiguredCabal file.
parseConfiguredCabal :: Context -> Action ConfiguredCabal
parseConfiguredCabal context@Context {..} = do
-- | Parses the 'PackageData' for a package (the one in the 'Context').
parsePackageData :: Context -> Action PackageData
parsePackageData context@Context {..} = do
-- XXX: This is conceptually wrong!
-- We should use the gpd, and
-- the flagAssignment and compiler, hostPlatform, ... information
@@ -240,11 +258,10 @@ parseConfiguredCabal context@Context {..} = do
-- the RTS's library-dirs here.
_ -> error "No (or multiple) ghc rts package is registered!!"

in return $ ConfiguredCabal
in return $ PackageData
{ dependencies = deps
, name = C.unPackageName . C.pkgName . C.package $ pd'
, version = C.display . C.pkgVersion . C.package $ pd'
-- , packageDesc = pd
, componentId = C.localCompatPackageKey lbi'
, modules = map C.display . snd . biModules $ pd'
, otherModules = map C.display . C.otherModules . fst . biModules $ pd'
4 changes: 2 additions & 2 deletions src/Hadrian/Haskell/Cabal/Parse.hs-boot
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ module Hadrian.Haskell.Cabal.Parse where

import Context.Type (Context)
import Development.Shake (Action)
import Hadrian.Haskell.Cabal.PackageData (PackageData)
import Hadrian.Haskell.Cabal.Type (Cabal)
import Hadrian.Haskell.Cabal.Configured (ConfiguredCabal)

parseCabal :: Context -> Action Cabal
parseConfiguredCabal :: Context -> Action ConfiguredCabal
parsePackageData :: Context -> Action PackageData
18 changes: 9 additions & 9 deletions src/Hadrian/Oracles/TextFile.hs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
module Hadrian.Oracles.TextFile (
readTextFile, lookupValue, lookupValueOrEmpty, lookupValueOrError,
lookupValues, lookupValuesOrEmpty, lookupValuesOrError, lookupDependencies,
readCabalFile, readConfiguredCabalFile, textFileOracle
readCabalFile, readPackageDataFile, textFileOracle
) where

import Control.Monad
@@ -24,8 +24,8 @@ import Development.Shake.Classes
import Development.Shake.Config

import Context.Type
import Hadrian.Haskell.Cabal.PackageData
import Hadrian.Haskell.Cabal.Type
import Hadrian.Haskell.Cabal.Configured
import {-# SOURCE #-} Hadrian.Haskell.Cabal.Parse
import Hadrian.Package
import Hadrian.Utilities
@@ -39,9 +39,9 @@ newtype CabalFile = CabalFile Context
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult CabalFile = Maybe Cabal

newtype ConfiguredCabalFile = ConfiguredCabalFile Context
newtype PackageDataFile = PackageDataFile Context
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult ConfiguredCabalFile = Maybe ConfiguredCabal
type instance RuleResult PackageDataFile = Maybe PackageData

newtype KeyValue = KeyValue (FilePath, String)
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
@@ -102,8 +102,8 @@ lookupDependencies depFile file = do
readCabalFile :: Context -> Action (Maybe Cabal)
readCabalFile = askOracle . CabalFile

readConfiguredCabalFile :: Context -> Action (Maybe ConfiguredCabal)
readConfiguredCabalFile = askOracle . ConfiguredCabalFile
readPackageDataFile :: Context -> Action (Maybe PackageData)
readPackageDataFile = askOracle . PackageDataFile

-- | This oracle reads and parses text files to answer 'readTextFile' and
-- 'lookupValue' queries, as well as their derivatives, tracking the results.
@@ -142,8 +142,8 @@ textFileOracle = do
case pkgCabalFile package of
Just file -> do
need [file]
putLoud $ "| ConfiguredCabalFile oracle: reading " ++ quote file ++ " (Stage: " ++ stageString stage ++ ")..."
Just <$> parseConfiguredCabal ctx
putLoud $ "| PackageDataFile oracle: reading " ++ quote file ++ " (Stage: " ++ stageString stage ++ ")..."
Just <$> parsePackageData ctx
Nothing -> return Nothing

void $ addOracle $ \(ConfiguredCabalFile ctx) -> confCabal ctx
void $ addOracle $ \(PackageDataFile ctx) -> confCabal ctx
4 changes: 4 additions & 0 deletions src/Hadrian/Package.hs
Original file line number Diff line number Diff line change
@@ -63,6 +63,10 @@ isCPackage _ = False
-- | Is this a Haskell package?
isHsPackage :: Package -> Bool
isHsPackage (Package Haskell _ _ _) = True
-- we consider the RTS as a haskell package because we
-- use information from its Cabal file to build it,
-- and we e.g want 'pkgCabalFile' to point us to
-- 'rts/rts.cabal' when passed the rts package as argument.
isHsPackage (Package _ _ "rts" _) = True
Copy link
Owner

@snowleopard snowleopard Mar 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite confusing, since rts is defined as cTop "rts", i.e. as a C package. How can it be a Haskell package? This at least deserves an explanation in a comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in an upcoming commit.

isHsPackage _ = False

10 changes: 5 additions & 5 deletions src/Oracles/ModuleFiles.hs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import Builder
import Context
import Expression
import GHC
import Hadrian.Haskell.Cabal.Configured as ConfCabal
import Hadrian.Haskell.Cabal.PackageData as PD

newtype ModuleFiles = ModuleFiles (Stage, Package)
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
@@ -89,7 +89,7 @@ hsSources context = do
-- the build directory regardless of whether they are generated or not.
hsObjects :: Context -> Action [FilePath]
hsObjects context = do
modules <- interpretInContext context (getConfiguredCabalData ConfCabal.modules)
modules <- interpretInContext context (getPackageData PD.modules)
mapM (objectPath context . moduleSource) modules

-- | Generated module files live in the 'Context' specific build directory.
@@ -105,7 +105,7 @@ moduleSource moduleName = replaceEq '.' '/' moduleName <.> "hs"
contextFiles :: Context -> Action [(String, Maybe FilePath)]
contextFiles context@Context {..} = do
modules <- fmap sort . interpretInContext context $
getConfiguredCabalData ConfCabal.modules
getPackageData PD.modules
zip modules <$> askOracle (ModuleFiles (stage, package))

-- | This is an important oracle whose role is to find and cache module source
@@ -123,8 +123,8 @@ moduleFilesOracle :: Rules ()
moduleFilesOracle = void $ do
void . addOracle $ \(ModuleFiles (stage, package)) -> do
let context = vanillaContext stage package
srcDirs <- interpretInContext context (getConfiguredCabalData ConfCabal.srcDirs)
modules <- fmap sort $ interpretInContext context (getConfiguredCabalData ConfCabal.modules)
srcDirs <- interpretInContext context (getPackageData PD.srcDirs)
modules <- fmap sort $ interpretInContext context (getPackageData PD.modules)
autogen <- autogenPath context
let dirs = autogen : map (pkgPath package -/-) srcDirs
modDirFiles = groupSort $ map decodeModule modules
10 changes: 5 additions & 5 deletions src/Rules/Documentation.hs
Original file line number Diff line number Diff line change
@@ -8,15 +8,15 @@ module Rules.Documentation (

import Base
import Context
import Expression (getConfiguredCabalData, interpretInContext)
import Expression (getPackageData, interpretInContext)
import Flavour
import GHC
import Oracles.ModuleFiles
import Settings
import Target
import Utilities

import qualified Hadrian.Haskell.Cabal.Configured as ConfCabal
import qualified Hadrian.Haskell.Cabal.PackageData as PD

-- | Build all documentation
documentationRules :: Rules ()
@@ -139,7 +139,7 @@ haddockHtmlLib = "docs/html/haddock-bundle.min.js"
-- | Find the haddock files for the dependencies of the current library
haddockDependencies :: Context -> Action [FilePath]
haddockDependencies context = do
depNames <- interpretInContext context (getConfiguredCabalData ConfCabal.depNames)
depNames <- interpretInContext context (getPackageData PD.depNames)
sequence [ pkgHaddockFile $ vanillaContext Stage1 depPkg
| Just depPkg <- map findPackageByName depNames, depPkg /= rts ]

@@ -153,8 +153,8 @@ buildPackageDocumentation context@Context {..} = when (stage == Stage1 && packag
-- Per-package haddocks
root -/- htmlRoot -/- "libraries" -/- pkgName package -/- "haddock-prologue.txt" %> \file -> do
-- this is how ghc-cabal produces "haddock-prologue.txt" files
(syn, desc) <- interpretInContext context . getConfiguredCabalData $ \p ->
(ConfCabal.synopsis p, ConfCabal.description p)
(syn, desc) <- interpretInContext context . getPackageData $ \p ->
(PD.synopsis p, PD.description p)
let prologue = if null desc
then syn
else desc
6 changes: 3 additions & 3 deletions src/Rules/Library.hs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ module Rules.Library (
) where

import Hadrian.Haskell.Cabal
import Hadrian.Haskell.Cabal.Configured as ConfCabal
import Hadrian.Haskell.Cabal.PackageData as PD
import Hadrian.Haskell.Cabal.Parse (parseCabalPkgId)

import Base
@@ -122,14 +122,14 @@ allObjects context = (++) <$> nonHsObjects context <*> hsObjects context
nonHsObjects :: Context -> Action [FilePath]
nonHsObjects context = do
cObjs <- cObjects context
cmmSrcs <- interpretInContext context (getConfiguredCabalData ConfCabal.cmmSrcs)
cmmSrcs <- interpretInContext context (getPackageData PD.cmmSrcs)
cmmObjs <- mapM (objectPath context) cmmSrcs
eObjs <- extraObjects context
return $ cObjs ++ cmmObjs ++ eObjs

cObjects :: Context -> Action [FilePath]
cObjects context = do
srcs <- interpretInContext context (getConfiguredCabalData ConfCabal.cSrcs)
srcs <- interpretInContext context (getPackageData PD.cSrcs)
objs <- mapM (objectPath context) srcs
return $ if way context == threaded
then objs
4 changes: 2 additions & 2 deletions src/Rules/Program.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Rules.Program (buildProgram) where

import Hadrian.Haskell.Cabal
import Hadrian.Haskell.Cabal.Configured as ConfCabal
import Hadrian.Haskell.Cabal.PackageData as PD

import Base
import Context
@@ -64,7 +64,7 @@ buildBinary rs bin context@Context {..} = do
when (stage > Stage0) $ do
ways <- interpretInContext context (getLibraryWays <> getRtsWays)
needLibrary [ rtsContext { way = w } | w <- ways ]
cSrcs <- interpretInContext context (getConfiguredCabalData ConfCabal.cSrcs)
cSrcs <- interpretInContext context (getPackageData PD.cSrcs)
cObjs <- mapM (objectPath context) cSrcs
hsObjs <- hsObjects context
return $ cObjs ++ hsObjs
4 changes: 2 additions & 2 deletions src/Settings/Builders/Cc.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module Settings.Builders.Cc (ccBuilderArgs) where

import Hadrian.Haskell.Cabal.Configured as ConfCabal
import Hadrian.Haskell.Cabal.PackageData as PD
import Settings.Builders.Common

ccBuilderArgs :: Args
ccBuilderArgs = do
way <- getWay
builder Cc ? mconcat
[ getConfiguredCabalData ConfCabal.ccOpts
[ getPackageData PD.ccOpts
, getStagedSettingList ConfCcArgs

, builder (Cc CompileC) ? mconcat
6 changes: 3 additions & 3 deletions src/Settings/Builders/Common.hs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ module Settings.Builders.Common (
import Base
import Expression
import GHC.Packages
import Hadrian.Haskell.Cabal.Configured as ConfCabal
import Hadrian.Haskell.Cabal.PackageData as PD
import Oracles.Flag
import Oracles.Setting
import Settings
@@ -23,8 +23,8 @@ cIncludeArgs = do
pkg <- getPackage
root <- getBuildRoot
path <- getBuildPath
incDirs <- getConfiguredCabalData ConfCabal.includeDirs
depDirs <- getConfiguredCabalData ConfCabal.depIncludeDirs
incDirs <- getPackageData PD.includeDirs
depDirs <- getPackageData PD.depIncludeDirs
iconvIncludeDir <- getSetting IconvIncludeDir
gmpIncludeDir <- getSetting GmpIncludeDir
ffiIncludeDir <- getSetting FfiIncludeDir
12 changes: 6 additions & 6 deletions src/Settings/Builders/Ghc.hs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import Settings.Builders.Common
import Settings.Warnings

import Hadrian.Haskell.Cabal
import Hadrian.Haskell.Cabal.Configured as ConfCabal
import Hadrian.Haskell.Cabal.PackageData as PD

ghcBuilderArgs :: Args
ghcBuilderArgs = mconcat [compileAndLinkHs, compileC, findHsDependencies]
@@ -25,7 +25,7 @@ compileAndLinkHs = (builder (Ghc CompileHs) ||^ builder (Ghc LinkHs)) ? do
compileC :: Args
compileC = builder (Ghc CompileCWithGhc) ? do
way <- getWay
let ccArgs = [ getConfiguredCabalData ConfCabal.ccOpts
let ccArgs = [ getPackageData PD.ccOpts
, getStagedSettingList ConfCcArgs
, cIncludeArgs
, Dynamic `wayUnit` way ? pure [ "-fPIC", "-DDYNAMIC" ] ]
@@ -65,7 +65,7 @@ findHsDependencies = builder (Ghc FindHsDependencies) ? do
, getInputs ]

haddockGhcArgs :: Args
haddockGhcArgs = mconcat [ commonGhcArgs, getConfiguredCabalData ConfCabal.hcOpts ]
haddockGhcArgs = mconcat [ commonGhcArgs, getPackageData PD.hcOpts ]

-- Used in ghcBuilderArgs, ghcCBuilderArgs, ghcMBuilderArgs and haddockGhcArgs.
commonGhcArgs :: Args
@@ -90,7 +90,7 @@ commonGhcArgs = do
, (pkg == rts) ? notStage0 ? arg ("-ghcversion-file=" ++ ghcVersion)
, map ("-optc" ++) <$> getStagedSettingList ConfCcArgs
, map ("-optP" ++) <$> getStagedSettingList ConfCppArgs
, map ("-optP" ++) <$> getConfiguredCabalData ConfCabal.cppOpts
, map ("-optP" ++) <$> getPackageData PD.cppOpts
, arg "-odir" , arg path
, arg "-hidir" , arg path
, arg "-stubdir" , arg path ]
@@ -116,15 +116,15 @@ packageGhcArgs = withHsPackage $ \ctx -> do
, arg "-no-user-package-db"
, packageDatabaseArgs
, libraryPackage ? arg ("-this-unit-id " ++ pkgId)
, map ("-package-id " ++) <$> getConfiguredCabalData ConfCabal.depIpIds ]
, map ("-package-id " ++) <$> getPackageData PD.depIpIds ]

includeGhcArgs :: Args
includeGhcArgs = do
pkg <- getPackage
path <- getBuildPath
root <- getBuildRoot
context <- getContext
srcDirs <- getConfiguredCabalData ConfCabal.srcDirs
srcDirs <- getPackageData PD.srcDirs
autogen <- expr $ autogenPath context
mconcat [ arg "-i"
, arg $ "-i" ++ path
6 changes: 3 additions & 3 deletions src/Settings/Builders/Haddock.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Settings.Builders.Haddock (haddockBuilderArgs) where

import Hadrian.Haskell.Cabal
import Hadrian.Haskell.Cabal.Configured as ConfCabal
import Hadrian.Haskell.Cabal.PackageData as PD
import Hadrian.Utilities
import Rules.Documentation
import Settings.Builders.Common
@@ -36,7 +36,7 @@ haddockBuilderArgs = withHsPackage $ \ctx -> mconcat
path <- getBuildPath
Just version <- expr $ pkgVersion ctx
Just synopsis <- expr $ pkgSynopsis ctx
deps <- getConfiguredCabalData ConfCabal.depNames
deps <- getPackageData PD.depNames
haddocks <- expr . haddockDependencies =<< getContext
Just hVersion <- expr $ pkgVersion ctx
ghcOpts <- haddockGhcArgs
@@ -56,7 +56,7 @@ haddockBuilderArgs = withHsPackage $ \ctx -> mconcat
, arg $ "--prologue=" ++ takeDirectory output -/- "haddock-prologue.txt"
, arg $ "--optghc=-D__HADDOCK_VERSION__="
++ show (versionToInt hVersion)
, map ("--hide=" ++) <$> getConfiguredCabalData ConfCabal.otherModules
, map ("--hide=" ++) <$> getPackageData PD.otherModules
, pure [ "--read-interface=../" ++ dep
++ ",../" ++ dep ++ "/src/%{MODULE}.html#%{NAME},"
++ haddock | (dep, haddock) <- zip deps haddocks ]
14 changes: 7 additions & 7 deletions src/Settings/Builders/Hsc2Hs.hs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ module Settings.Builders.Hsc2Hs (hsc2hsBuilderArgs) where
import Builder ()
import GHC (autogenPath)
import Hadrian.Builder (getBuilderPath)
import Hadrian.Haskell.Cabal.Configured as ConfCabal
import Hadrian.Haskell.Cabal.PackageData as PD
import Settings.Builders.Common

hsc2hsBuilderArgs :: Args
@@ -43,16 +43,16 @@ getCFlags = do
mconcat [ remove ["-O"] (cArgs <> getStagedSettingList ConfCcArgs)
, getStagedSettingList ConfCppArgs
, cIncludeArgs
, getConfiguredCabalData ConfCabal.ccOpts
-- XXX: is cppOpts correct here?
, getConfiguredCabalData ConfCabal.cppOpts
, getConfiguredCabalData ConfCabal.depCcOpts
, getPackageData PD.ccOpts
-- we might be able to leave out cppOpts, to be investigated.
, getPackageData PD.cppOpts
, getPackageData PD.depCcOpts
, cWarnings
, arg "-include", arg $ autogen -/- "cabal_macros.h" ]

getLFlags :: Expr [String]
getLFlags =
mconcat [ getStagedSettingList ConfGccLinkerArgs
, ldArgs
, getConfiguredCabalData ConfCabal.ldOpts
, getConfiguredCabalData ConfCabal.depLdOpts ]
, getPackageData PD.ldOpts
, getPackageData PD.depLdOpts ]
4 changes: 2 additions & 2 deletions src/Settings/Default.hs
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ import GHC.Packages
import qualified Hadrian.Builder.Ar
import qualified Hadrian.Builder.Sphinx
import qualified Hadrian.Builder.Tar
import Hadrian.Haskell.Cabal.Configured as ConfCabal
import Hadrian.Haskell.Cabal.PackageData as PD

-- TODO: Move C source arguments here
-- | Default and package-specific source arguments.
@@ -49,7 +49,7 @@ data SourceArgs = SourceArgs
sourceArgs :: SourceArgs -> Args
sourceArgs SourceArgs {..} = builder Ghc ? mconcat
[ hsDefault
, getConfiguredCabalData ConfCabal.hcOpts
, getPackageData PD.hcOpts
, libraryPackage ? hsLibrary
, package compiler ? hsCompiler
, package ghc ? hsGhc ]
6 changes: 3 additions & 3 deletions src/Utilities.hs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ module Utilities (

import qualified Hadrian.Builder as H
import Hadrian.Haskell.Cabal
import Hadrian.Haskell.Cabal.Configured as ConfCabal
import Hadrian.Haskell.Cabal.PackageData as PD
import Hadrian.Utilities

import Context
@@ -55,7 +55,7 @@ contextDependencies ctx@Context {..} = do

cabalDependencies :: Context -> Action [String]
cabalDependencies ctx = interpretInContext ctx $
getConfiguredCabalData ConfCabal.depIpIds
getPackageData PD.depIpIds

-- | Lookup dependencies of a 'Package' in the vanilla Stage1 context.
stage1Dependencies :: Package -> Action [Package]
@@ -71,7 +71,7 @@ libraryTargets includeGhciLib context = do
lib0 <- buildDll0 context
ghciLib <- pkgGhciLibraryFile context
ghci <- if includeGhciLib
then interpretInContext context $ getConfiguredCabalData ConfCabal.buildGhciLib
then interpretInContext context $ getPackageData PD.buildGhciLib
else return False
return $ [ libFile ] ++ [ lib0File | lib0 ] ++ [ ghciLib | ghci ]