GhcCabal.hs 1.31 KB
Newer Older
1
2
module Settings.Packages.GhcCabal (ghcCabalPackageArgs) where

3
4
import Distribution.Package (pkgVersion)
import Distribution.PackageDescription (packageDescription)
5
import Distribution.PackageDescription.Parse
6
7
8
import qualified Distribution.PackageDescription as DP
import Distribution.Text (display)
import Distribution.Verbosity (silent)
9

10
import Base
11
import Expression
12
import GHC
13
import Oracles.Dependencies (pkgDependencies)
14
15

ghcCabalPackageArgs :: Args
Andrey Mokhov's avatar
Andrey Mokhov committed
16
ghcCabalPackageArgs = stage0 ? package ghcCabal ? builder Ghc ? do
17
18
19
    cabalDeps <- expr $ pkgDependencies cabal
    expr $ need [pkgCabalFile cabal]
    pd <- exprIO . readGenericPackageDescription silent $ pkgCabalFile cabal
20
21
22
    let identifier   = DP.package . packageDescription $ pd
        cabalVersion = display . pkgVersion $ identifier

23
    mconcat
24
        [ append [ "-package " ++ pkgNameString pkg | pkg <- cabalDeps ]
25
        , arg "--make"
26
        , arg "-j"
27
        , arg ("-DCABAL_VERSION=" ++ replace "." "," cabalVersion)
28
29
30
31
        , arg "-DBOOTSTRAPPING"
        , arg "-DMIN_VERSION_binary_0_8_0"
        , arg "-DGENERICS"
        , arg "-optP-include"
Andrey Mokhov's avatar
Andrey Mokhov committed
32
        , arg $ "-optP" ++ pkgPath ghcCabal -/- "cabal_macros_boot.h"
33
34
35
36
        , arg "-ilibraries/Cabal/Cabal"
        , arg "-ilibraries/binary/src"
        , arg "-ilibraries/filepath"
        , arg "-ilibraries/hpc" ]