Commit 8e9fe8d6 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Cache computation of boot package constraints in a file.

parent 44ce5719
module Base (
shakeFilesPath, configPath,
shakeFilesPath, configPath, bootPackageConstraints,
module Development.Shake,
module Development.Shake.Util,
module Development.Shake.Config,
......@@ -18,3 +18,6 @@ shakeFilesPath = "_build/"
configPath :: FilePath
configPath = "shake/cfg/"
bootPackageConstraints :: FilePath
bootPackageConstraints = shakeFilesPath ++ "boot-package-constraints"
......@@ -3,6 +3,7 @@ import Rules
main = shakeArgs shakeOptions{shakeFiles = shakeFilesPath} $ do
oracleRules -- see module Rules.Oracles
cabalRules -- see module Rules.Cabal
packageRules -- see module Rules
configRules -- see module Rules.Config
generateTargets -- see module Rules
module Rules (
generateTargets, packageRules, oracleRules,
module Rules.Config,
module Rules.Package,
oracleRules, cabalRules, configRules, packageRules, generateTargets
) where
import Base
import Util
import Stage
import Expression
import Rules.Cabal
import Rules.Config
import Rules.Package
import Rules.Oracles
......
module Rules.Cabal (cabalRules) where
import Base
import Util
import Stage
import Package
import Expression
import Settings.Packages
import Data.List
import Data.Version
import qualified Distribution.Package as D
import qualified Distribution.PackageDescription as D
import qualified Distribution.Verbosity as D
import qualified Distribution.PackageDescription.Parse as D
cabalRules :: Rules ()
cabalRules =
-- Cache boot package constraints (to be used in cabalArgs)
bootPackageConstraints %> \file -> do
pkgs <- interpret (stageTarget Stage0) packages
constraints <- forM (sort pkgs) $ \pkg -> do
let cabal = pkgPath pkg -/- pkgCabal pkg
need [cabal]
descr <- liftIO $ D.readPackageDescription D.silent cabal
let identifier = D.package . D.packageDescription $ descr
version = showVersion . D.pkgVersion $ identifier
D.PackageName name = D.pkgName $ identifier
return $ name ++ " == " ++ version
writeFileChanged file . unlines $ constraints
module Rules.Package (
buildPackage
) where
module Rules.Package (buildPackage) where
import Base
import Expression
......
......@@ -2,12 +2,12 @@ module Settings.Args (
args
) where
import Expression
import Settings.User
import Settings.GhcM
import Settings.GccM
import Settings.GhcPkg
import Settings.GhcCabal
import Expression
args :: Args
args = defaultArgs <> userArgs
......
......@@ -15,12 +15,6 @@ import Oracles.Setting
import Settings.User
import Settings.Ways
import Settings.Util
import Settings.Packages
import Data.Version
import qualified Distribution.Package as D
import qualified Distribution.PackageDescription as D
import qualified Distribution.Verbosity as D
import qualified Distribution.PackageDescription.Parse as D
cabalArgs :: Args
cabalArgs = builder GhcCabal ? do
......@@ -95,18 +89,9 @@ bootPackageDbArgs = do
dllArgs :: Args
dllArgs = arg ""
-- TODO: speed up by caching the result in Shake database?
packageConstraints :: Args
packageConstraints = stage0 ? do
pkgs <- getPackages
constraints <- lift $ forM pkgs $ \pkg -> do
let cabal = pkgPath pkg -/- pkgCabal pkg
need [cabal]
description <- liftIO $ D.readPackageDescription D.silent cabal
let identifier = D.package . D.packageDescription $ description
version = showVersion . D.pkgVersion $ identifier
D.PackageName name = D.pkgName $ identifier
return $ name ++ " == " ++ version
constraints <- lift . readFileLines $ bootPackageConstraints
append . concatMap (\c -> ["--constraint", c]) $ constraints
-- TODO: should be in a different file
......
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