Commit 41ecfdc7 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Refactor generated dependencies

Do not proceed with building a package until all its generated dependencies are in place. List generated files in ghcPrim package, see #117.
parent ce8ffdbb
......@@ -6,6 +6,7 @@ import GHC
import Oracles
import Predicates (registerPackage)
import Rules.Actions
import Rules.Generate
import Rules.Resources
import Settings
import Settings.Builders.Common
......@@ -19,6 +20,10 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
dataFile = pkgDataFile stage pkg
dataFile %> \mk -> do
-- The first thing we do with any package is make sure all generated
-- dependencies are in place before proceeding.
orderOnly $ generatedDependencies stage pkg
-- GhcCabal may run the configure script, so we depend on it
-- We don't know who built the configure script from configure.ac
whenM (doesFileExist $ configure <.> "ac") $ need [configure]
......@@ -104,11 +109,11 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
, "includes/ghcplatform.h" ]
build $ fullTarget target HsCpp [rtsConfIn] [rtsConf]
let fixRtsConf = unlines
let fixRtsConf = unlines
. map
( replace "\"\"" ""
. replace "rts/dist/build" "rts/stage1/build" )
. filter (not . null)
. filter (not . null)
. lines
fixFile rtsConf fixRtsConf
......
......@@ -4,7 +4,6 @@ import Base
import Expression
import Oracles
import Rules.Actions
import Rules.Generate
import Rules.Resources
import Settings
import Development.Shake.Util (parseMakefile)
......@@ -18,13 +17,11 @@ buildPackageDependencies _ target @ (PartialTarget stage pkg) =
in do
[ buildPath ++ "//*.c.deps", buildPath ++ "//*.cmm.deps" ] |%> \out -> do
let srcFile = dropBuild . dropExtension $ out
orderOnly $ generatedDependencies stage pkg
need [srcFile]
build $ fullTarget target (GccM stage) [srcFile] [out]
hDepFile %> \out -> do
srcs <- interpretPartial target getPackageSources
orderOnly $ generatedDependencies stage pkg
need srcs
if srcs == []
then writeFileChanged out ""
......
......@@ -35,13 +35,15 @@ includesDependencies = ("includes" -/-) <$>
, "ghcplatform.h"
, "ghcversion.h" ]
integerGmpDependencies :: [FilePath]
integerGmpDependencies = [integerGmpLibraryH]
defaultDependencies :: [FilePath]
defaultDependencies =
includesDependencies ++ libffiDependencies ++ integerGmpDependencies
ghcPrimDependencies :: Stage -> [FilePath]
ghcPrimDependencies stage = ((targetPath stage ghcPrim -/- "build") -/-) <$>
[ "GHC/PrimopWrappers.hs"
, "autogen/GHC/Prim.hs" ]
derivedConstantsDependencies :: [FilePath]
derivedConstantsDependencies = (derivedConstantsPath -/-) <$>
[ "DerivedConstants.h"
......@@ -72,10 +74,11 @@ compilerDependencies stage =
generatedDependencies :: Stage -> Package -> [FilePath]
generatedDependencies stage pkg
| pkg == compiler = compilerDependencies stage
| pkg == rts = derivedConstantsDependencies
| stage == Stage0 = defaultDependencies
| otherwise = []
| pkg == compiler = compilerDependencies stage
| pkg == ghcPrim = ghcPrimDependencies stage
| pkg == rts = derivedConstantsDependencies
| stage == Stage0 = defaultDependencies
| otherwise = []
-- The following generators and corresponding source extensions are supported:
knownGenerators :: [ (Builder, String) ]
......
module Rules.IntegerGmp (integerGmpRules, integerGmpObjects, integerGmpLibraryH) where
module Rules.IntegerGmp (
integerGmpRules, integerGmpObjects, integerGmpLibraryH, integerGmpDependencies
) where
import Base
import Expression
......@@ -28,6 +30,9 @@ integerGmpLibraryH = pkgPath integerGmp -/- "include/ghc-gmp.h"
integerGmpLibraryFakeH :: FilePath
integerGmpLibraryFakeH = integerGmpBase -/- "ghc-gmp.h"
integerGmpDependencies :: [FilePath]
integerGmpDependencies = [integerGmpLibraryH]
-- relative to integerGmpBuild
integerGmpPatch :: FilePath
integerGmpPatch = ".." -/- "tarball" -/- "gmp-5.0.4.patch"
......
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