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

Build deriveConstants utility.

parent 6b143638
module GHC (
array, base, binPackageDb, binary, bytestring, cabal, compiler, containers,
compareSizes, deepseq, directory, dllSplit, filepath, ghc, ghcCabal, ghcPkg, ghcPrim,
compareSizes, deepseq, deriveConstants, directory, dllSplit, filepath, 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,7 +21,7 @@ import Stage
defaultKnownPackages :: [Package]
defaultKnownPackages =
[ array, base, binPackageDb, binary, bytestring, cabal, compiler
, containers, compareSizes, deepseq, directory, dllSplit, filepath, ghc
, containers, compareSizes, deepseq, deriveConstants, directory, dllSplit, filepath, ghc
, ghcCabal, ghcPkg, ghcPrim
, ghcPwd, ghcTags, haddock, haskeline, hsc2hs, hoopl, hpc, hpcBin, integerGmp, integerSimple
, mkUserGuidePart, parallel, pretty, primitive, process, runghc, stm, templateHaskell, terminfo
......@@ -29,7 +29,7 @@ defaultKnownPackages =
-- Package definitions
array, base, binPackageDb, binary, bytestring, cabal, compiler, containers,
compareSizes, deepseq, directory, dllSplit, filepath, ghc, ghcCabal, ghcPkg,
compareSizes, deepseq, deriveConstants, directory, dllSplit, filepath, ghc, ghcCabal, ghcPkg,
ghcPrim, ghcPwd,
ghcTags, haddock, haskeline, hsc2hs, hoopl, hpc, hpcBin, integerGmp, integerSimple,
mkUserGuidePart, parallel, pretty,
......@@ -46,6 +46,7 @@ compiler = topLevel "ghc" `setPath` "compiler"
containers = library "containers"
compareSizes = utility "compareSizes" `setPath` "utils/compare_sizes"
deepseq = library "deepseq"
deriveConstants = utility "deriveConstants"
directory = library "directory"
dllSplit = utility "dll-split"
filepath = library "filepath"
......@@ -78,7 +79,7 @@ unix = library "unix"
win32 = library "Win32"
xhtml = library "xhtml"
-- TODO: deriveConstants, genapply, genprimocode, hp2ps
-- TODO: genapply, 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,
......@@ -104,6 +105,7 @@ defaultTargetDirectory stage pkg
defaultProgramPath :: Stage -> Package -> Maybe FilePath
defaultProgramPath stage pkg
| pkg == compareSizes = program $ pkgName pkg
| pkg == deriveConstants = program $ pkgName pkg
| pkg == dllSplit = program $ pkgName pkg
| pkg == ghc = program $ "ghc-stage" ++ show (fromEnum stage + 1)
| pkg == ghcCabal = program $ pkgName pkg
......
......@@ -48,8 +48,9 @@ askPackageData path key = do
file = path -/- "package-data.mk"
maybeValue <- askOracle $ PackageDataKey (file, fullKey)
case maybeValue of
Nothing -> putError $ "No key '" ++ key ++ "' in " ++ file ++ "."
Nothing -> return ""
Just value -> return value
-- Nothing -> putError $ "No key '" ++ key ++ "' in " ++ file ++ "."
pkgData :: PackageData -> Action String
pkgData packageData = case packageData of
......
......@@ -3,7 +3,7 @@ module Predicates (
module Oracles.Config.Flag,
module Oracles.Config.Setting,
stage, package, builder, stagedBuilder, file, way,
stage0, stage1, stage2, notStage0, registerPackage, splitObjects
stage0, stage1, stage2, notStage0, notPackage, registerPackage, splitObjects
) where
import Expression
......@@ -45,6 +45,9 @@ stage2 = stage Stage2
notStage0 :: Predicate
notStage0 = notM stage0
notPackage :: Package -> Predicate
notPackage = notM . package
-- TODO: Actually, we don't register compiler in some circumstances -- fix.
registerPackage :: Predicate
registerPackage = return True
......
......@@ -7,8 +7,8 @@ import Rules.Resources
import Settings
compilePackage :: Resources -> PartialTarget -> Rules ()
compilePackage _ target @ (PartialTarget stage package) = do
let path = targetPath stage package
compilePackage _ target @ (PartialTarget stage pkg) = do
let path = targetPath stage pkg
buildPath = path -/- "build"
matchBuildResult buildPath "hi" ?> \hi ->
......@@ -27,6 +27,12 @@ compilePackage _ target @ (PartialTarget stage package) = do
let way = detectWay obj
build $ fullTargetWithWay target (Ghc stage) way [src] [obj]
-- TODO: get rid of this special case
priority 2.0 $ buildPath -/- "DeriveConstants.o" %> \obj -> do
let src = pkgPath pkg -/- "DeriveConstants.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
......
......@@ -45,6 +45,17 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
postProcessPackageData $ path -/- "package-data.mk"
-- 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
let contents = unlines
[ "utils_deriveConstants_dist-boot_MODULES = DeriveConstants"
, "utils_deriveConstants_dist-boot_PROGNAME = deriveConstants"
, "utils_deriveConstants_dist-boot_HS_SRC_DIRS = ."
, "utils_deriveConstants_dist-boot_INSTALL_INPLACE = YES"
, "utils_deriveConstants_dist-boot_HC_OPTS = -package process -package containers" ]
writeFileChanged mk contents
-- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
-- 1) Drop lines containing '$'
-- For example, get rid of
......
......@@ -5,7 +5,7 @@ module Settings.Builders.Ghc (
import Expression
import Oracles
import GHC
import Predicates (package, file, stagedBuilder, splitObjects, stage0, notStage0)
import Predicates hiding (way, stage)
import Settings
-- TODO: add support for -dyno
......@@ -50,7 +50,7 @@ ghcMArgs = stagedBuilder GhcM ? do
, append $ concat [ ["-dep-suffix", wayPrefix w] | w <- ways ]
, append =<< getInputs ]
-- This is included into ghcArgs, ghcMArgs and haddockArgs.
-- This is included into ghcArgs, ghcMArgs and haddockArgs
commonGhcArgs :: Args
commonGhcArgs = do
way <- getWay
......@@ -87,6 +87,7 @@ wayGhcArgs = do
, (way == debug || way == debugDynamic) ?
append ["-ticky", "-DTICKY_TICKY"] ]
-- TODO: Improve handling of "-hide-all-packages"
packageGhcArgs :: Args
packageGhcArgs = do
stage <- getStage
......@@ -95,7 +96,7 @@ packageGhcArgs = do
pkgKey <- getPkgData PackageKey
pkgDepIds <- getPkgDataList DepIds
mconcat
[ arg "-hide-all-packages"
[ (pkg /= deriveConstants) ? arg "-hide-all-packages"
, arg "-no-user-package-db"
, stage0 ? arg "-package-db libraries/bootstrapping.conf"
, isLibrary pkg ?
......
......@@ -19,6 +19,7 @@ packagesStage0 :: Packages
packagesStage0 = mconcat
[ append [ binPackageDb, binary, cabal, compiler, ghc, ghcCabal, ghcPkg
, hsc2hs, hoopl, hpc, templateHaskell, transformers ]
, stage0 ? append [deriveConstants] -- TODO: simplify
, notM windowsHost ? notM (anyHostOs ["ios"]) ? append [terminfo] ]
-- TODO: what do we do with parallel, stm, random, primitive, vector and dph?
......
Supports Markdown
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