Commit 0589a9e4 authored by Zhen Zhang's avatar Zhen Zhang Committed by Andrey Mokhov
Browse files

Compute cabalDeps in GhcCabal build (#320)

parent 8299d146
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Oracles.Dependencies (
fileDependencies, contextDependencies, needContext, dependenciesOracles
fileDependencies, contextDependencies, needContext, dependenciesOracles,
pkgDependencies
) where
import qualified Data.HashMap.Strict as Map
......@@ -47,6 +48,12 @@ contextDependencies context@Context {..} = do
pkgs <- sort <$> interpretInContext (pkgContext package) getPackages
return . map pkgContext $ intersectOrd (compare . pkgNameString) pkgs deps
-- | Given a `Package`, this `Action` looks up its package dependencies
-- 'Settings.Paths.packageDependencies' using 'packageDependenciesOracle'
-- The context will be the vanilla context with stage equal to 1
pkgDependencies :: Package -> Action [Package]
pkgDependencies = fmap (map Context.package) . contextDependencies . vanillaContext Stage1
-- | Coarse-grain 'need': make sure given contexts are fully built.
needContext :: [Context] -> Action ()
needContext cs = do
......
......@@ -5,6 +5,7 @@ import Distribution.PackageDescription.Parse
import Base
import GHC
import Oracles.Config.Setting
import Oracles.Dependencies (pkgDependencies)
import Predicate
import Package (pkgCabalFile)
import Distribution.Verbosity (silent)
......@@ -15,12 +16,8 @@ import qualified Distribution.PackageDescription as DP
ghcCabalPackageArgs :: Args
ghcCabalPackageArgs = stage0 ? package ghcCabal ? builder Ghc ? do
-- Note: We could compute 'cabalDeps' instead of hard-coding it but this
-- seems unnecessary since we plan to drop @ghc-cabal@ altogether, #18.
win <- lift windowsHost
let cabalDeps = [ array, base, bytestring, containers, deepseq, directory
, pretty, process, time, if win then win32 else unix ]
cabalDeps <- lift $ pkgDependencies cabal
lift $ need [pkgCabalFile cabal]
pd <- liftIO . readGenericPackageDescription silent $ pkgCabalFile cabal
let identifier = DP.package . packageDescription $ pd
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment