Commit e99bd28a authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Build genapply utility.

parent bbdaa7ea
module GHC (
array, base, binPackageDb, binary, bytestring, cabal, compiler, containers,
compareSizes, deepseq, deriveConstants, directory, dllSplit, filepath, ghc, ghcCabal, ghcPkg, ghcPrim,
compareSizes, deepseq, deriveConstants, directory, dllSplit, filepath,
genapply, ghc, ghcCabal, ghcPkg, ghcPrim,
ghcPwd, ghcTags, haddock, haskeline, hsc2hs, hoopl, hpc, hpcBin, integerGmp, integerSimple,
mkUserGuidePart, parallel, pretty,
primitive, process, runghc, stm, templateHaskell, terminfo, time, transformers,
......@@ -21,16 +22,16 @@ import Stage
defaultKnownPackages :: [Package]
defaultKnownPackages =
[ array, base, binPackageDb, binary, bytestring, cabal, compiler
, containers, compareSizes, deepseq, deriveConstants, directory, dllSplit, filepath, ghc
, ghcCabal, ghcPkg, ghcPrim
, containers, compareSizes, deepseq, deriveConstants, directory, dllSplit
, filepath, genapply, ghc, ghcCabal, ghcPkg, ghcPrim
, ghcPwd, ghcTags, haddock, haskeline, hsc2hs, hoopl, hpc, hpcBin, integerGmp, integerSimple
, mkUserGuidePart, parallel, pretty, primitive, process, runghc, stm, templateHaskell, terminfo
, time, transformers, unix, win32, xhtml ]
-- Package definitions
array, base, binPackageDb, binary, bytestring, cabal, compiler, containers,
compareSizes, deepseq, deriveConstants, directory, dllSplit, filepath, ghc, ghcCabal, ghcPkg,
ghcPrim, ghcPwd,
compareSizes, deepseq, deriveConstants, directory, dllSplit, filepath,
genapply, ghc, ghcCabal, ghcPkg, ghcPrim, ghcPwd,
ghcTags, haddock, haskeline, hsc2hs, hoopl, hpc, hpcBin, integerGmp, integerSimple,
mkUserGuidePart, parallel, pretty,
primitive, process, runghc, stm, templateHaskell, terminfo, time, transformers,
......@@ -50,6 +51,7 @@ deriveConstants = utility "deriveConstants"
directory = library "directory"
dllSplit = utility "dll-split"
filepath = library "filepath"
genapply = utility "genapply"
ghc = topLevel "ghc-bin" `setPath` "ghc"
ghcCabal = utility "ghc-cabal"
ghcPkg = utility "ghc-pkg"
......@@ -79,7 +81,7 @@ unix = library "unix"
win32 = library "Win32"
xhtml = library "xhtml"
-- TODO: genapply, genprimocode, hp2ps
-- TODO: genprimocode, hp2ps
-- TODO: The following utils are not included into the build system because
-- they seem to be unused or unrelated to the build process: chechUniques,
......@@ -107,6 +109,7 @@ defaultProgramPath stage pkg
| pkg == compareSizes = program $ pkgName pkg
| pkg == deriveConstants = program $ pkgName pkg
| pkg == dllSplit = program $ pkgName pkg
| pkg == genapply = program $ pkgName pkg
| pkg == ghc = program $ "ghc-stage" ++ show (fromEnum stage + 1)
| pkg == ghcCabal = program $ pkgName pkg
| pkg == ghcPkg = program $ pkgName pkg
......
......@@ -27,12 +27,17 @@ compilePackage _ target @ (PartialTarget stage pkg) = do
let way = detectWay obj
build $ fullTargetWithWay target (Ghc stage) way [src] [obj]
-- TODO: get rid of this special case
-- TODO: get rid of these special cases
priority 2.0 $ buildPath -/- "DeriveConstants.o" %> \obj -> do
let src = pkgPath pkg -/- "DeriveConstants.hs"
need [src]
build $ fullTargetWithWay target (Ghc stage) vanilla [src] [obj]
priority 2.0 $ buildPath -/- "GenApply.o" %> \obj -> do
let src = pkgPath pkg -/- "GenApply.hs"
need [src]
build $ fullTargetWithWay target (Ghc stage) vanilla [src] [obj]
matchBuildResult buildPath "o-boot" ?> \obj -> do
(src, deps) <- dependencies buildPath obj
need $ src : deps
......
module Rules.Data (buildPackageData) where
import Expression
import GHC (deriveConstants, genapply)
import Oracles
import Predicates (registerPackage)
import Rules.Actions
......@@ -47,7 +48,8 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
-- TODO: Track dependency on this generated file
-- TODO: Use a cabal file instead of manual hacks?
priority 2.0 $ path -/- "package-data.mk" %> \mk -> do
priority 2.0 $
when (pkg == deriveConstants) $ path -/- "package-data.mk" %> \mk -> do
let contents = unlines
[ "utils_deriveConstants_dist-boot_MODULES = DeriveConstants"
, "utils_deriveConstants_dist-boot_PROGNAME = deriveConstants"
......@@ -56,6 +58,18 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
, "utils_deriveConstants_dist-boot_HC_OPTS = -package process -package containers" ]
writeFileChanged mk contents
priority 2.0 $
when (pkg == genapply) $ path -/- "package-data.mk" %> \mk -> do
ghcUnreg <- flag GhcUnregisterised
let hcOpts = "-package pretty" ++ if ghcUnreg then " -DNO_REGS" else ""
contents = unlines
[ "utils_genapply_dist-boot_MODULES = GenApply"
, "utils_genapply_dist-boot_PROGNAME = genapply"
, "utils_genapply_dist-boot_HS_SRC_DIRS = ."
, "utils_genapply_dist-boot_INSTALL_INPLACE = YES"
, "utils_genapply_dist-boot_HC_OPTS = " ++ hcOpts ]
writeFileChanged mk contents
-- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
-- 1) Drop lines containing '$'
-- For example, get rid of
......
......@@ -96,7 +96,8 @@ packageGhcArgs = do
pkgKey <- getPkgData PackageKey
pkgDepIds <- getPkgDataList DepIds
mconcat
[ (pkg /= deriveConstants) ? arg "-hide-all-packages"
[ not (pkg == deriveConstants || pkg == genapply) ?
arg "-hide-all-packages"
, arg "-no-user-package-db"
, stage0 ? arg "-package-db libraries/bootstrapping.conf"
, isLibrary pkg ?
......@@ -105,6 +106,7 @@ packageGhcArgs = do
else arg $ "-package-name " ++ pkgKey
, append $ map ("-package-id " ++) pkgDepIds ]
-- TODO: Improve handling of "cabal_macros.h"
includeGhcArgs :: Args
includeGhcArgs = do
pkg <- getPackage
......@@ -120,8 +122,9 @@ includeGhcArgs = do
, arg $ "-I" ++ autogenPath
, append [ "-i" ++ pkgPath pkg -/- dir | dir <- srcDirs ]
, append [ "-I" ++ pkgPath pkg -/- dir | dir <- incDirs ]
, arg "-optP-include"
, arg $ "-optP" ++ autogenPath -/- "cabal_macros.h" ]
, not (pkg == deriveConstants || pkg == genapply) ?
append [ "-optP-include"
, "-optP" ++ autogenPath -/- "cabal_macros.h" ] ]
-- TODO: see ghc.mk
-- # And then we strip it out again before building the package:
......
......@@ -19,7 +19,7 @@ packagesStage0 :: Packages
packagesStage0 = mconcat
[ append [ binPackageDb, binary, cabal, compiler, ghc, ghcCabal, ghcPkg
, hsc2hs, hoopl, hpc, templateHaskell, transformers ]
, stage0 ? append [deriveConstants] -- TODO: simplify
, stage0 ? append [deriveConstants, genapply] -- TODO: simplify
, notM windowsHost ? notM (anyHostOs ["ios"]) ? append [terminfo] ]
-- TODO: what do we do with parallel, stm, random, primitive, vector and dph?
......
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