Cabal.hs 1.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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