summaryrefslogtreecommitdiff
path: root/hadrian/src
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2017-11-22 08:50:45 -0500
committerBen Gamari <ben@smart-cactus.org>2017-11-22 08:50:45 -0500
commitabdb5559b74af003a6d85f32695c034ff739f508 (patch)
tree1d3df93568e0db2c00acfa14a89f52db6b8df5f2 /hadrian/src
parentc11f145cf6a32337c005b0f9185e228c9ade0a64 (diff)
parent360d7404809b3fa54541f7f932a6864294f75a4a (diff)
downloadhaskell-abdb5559b74af003a6d85f32695c034ff739f508.tar.gz
Update Hadrian
Diffstat (limited to 'hadrian/src')
-rw-r--r--hadrian/src/Rules/Compile.hs2
-rw-r--r--hadrian/src/Rules/Dependencies.hs4
-rw-r--r--hadrian/src/Rules/Program.hs3
-rw-r--r--hadrian/src/Settings/Builders/Ghc.hs8
-rw-r--r--hadrian/src/Settings/Packages/GhcCabal.hs5
-rw-r--r--hadrian/src/Utilities.hs30
6 files changed, 28 insertions, 24 deletions
diff --git a/hadrian/src/Rules/Compile.hs b/hadrian/src/Rules/Compile.hs
index a4b1278660..b7f3bc8447 100644
--- a/hadrian/src/Rules/Compile.hs
+++ b/hadrian/src/Rules/Compile.hs
@@ -22,8 +22,6 @@ compilePackage rs context@Context {..} = do
path <- buildPath context
(src, deps) <- lookupDependencies (path -/- ".dependencies") obj
need $ src : deps
- when (isLibrary package) $ need =<< return <$> pkgConfFile context
- needLibrary =<< contextDependencies context
buildWithResources rs $ target context (Ghc CompileHs stage) [src] [obj]
priority 2.0 $ do
diff --git a/hadrian/src/Rules/Dependencies.hs b/hadrian/src/Rules/Dependencies.hs
index f27ef0d912..f9d17e93d8 100644
--- a/hadrian/src/Rules/Dependencies.hs
+++ b/hadrian/src/Rules/Dependencies.hs
@@ -19,11 +19,11 @@ buildPackageDependencies rs context@Context {..} =
orderOnly =<< interpretInContext context generatedDependencies
let mk = deps <.> "mk"
if null srcs
- then writeFileChanged mk ""
+ then writeFile' mk ""
else buildWithResources rs $
target context (Ghc FindHsDependencies stage) srcs [mk]
removeFile $ mk <.> "bak"
- mkDeps <- readFile' mk
+ mkDeps <- liftIO $ readFile mk
writeFileChanged deps . unlines
. map (\(src, deps) -> unwords $ src : deps)
. map (bimap unifyPath (map unifyPath))
diff --git a/hadrian/src/Rules/Program.hs b/hadrian/src/Rules/Program.hs
index ba4dab0442..dca177f879 100644
--- a/hadrian/src/Rules/Program.hs
+++ b/hadrian/src/Rules/Program.hs
@@ -92,7 +92,6 @@ buildWrapper context@Context {..} wrapper wrapperPath wrapped = do
putSuccess $ "| Successfully created wrapper for " ++
quote (pkgName package) ++ " (" ++ show stage ++ ")."
--- TODO: Get rid of the Paths_hsc2hs.o hack.
buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action ()
buildBinary rs bin context@Context {..} = do
binDeps <- if stage == Stage0 && package == ghcCabal
@@ -107,8 +106,6 @@ buildBinary rs bin context@Context {..} = do
cObjs <- mapM (objectPath context) cSrcs
hsObjs <- hsObjects context
return $ cObjs ++ hsObjs
- ++ [ path -/- "Paths_hsc2hs.o" | package == hsc2hs ]
- ++ [ path -/- "Paths_haddock.o" | package == haddock ]
need binDeps
buildWithResources rs $ target context (Ghc LinkHs stage) binDeps [bin]
synopsis <- traverse pkgSynopsis (pkgCabalFile package)
diff --git a/hadrian/src/Settings/Builders/Ghc.hs b/hadrian/src/Settings/Builders/Ghc.hs
index a975e7e799..af78b74637 100644
--- a/hadrian/src/Settings/Builders/Ghc.hs
+++ b/hadrian/src/Settings/Builders/Ghc.hs
@@ -87,10 +87,10 @@ haddockGhcArgs = mconcat [ commonGhcArgs, getPkgDataList HsArgs ]
-- Used in ghcBuilderArgs, ghcCBuilderArgs, ghcMBuilderArgs and haddockGhcArgs.
commonGhcArgs :: Args
commonGhcArgs = do
- way <- getWay
- path <- getBuildPath
- pkg <- getPackage
- when (isLibrary pkg) $ do
+ way <- getWay
+ path <- getBuildPath
+ pkg <- getPackage
+ when (pkg == rts) $ do
context <- getContext
conf <- expr $ pkgConfFile context
expr $ need [conf]
diff --git a/hadrian/src/Settings/Packages/GhcCabal.hs b/hadrian/src/Settings/Packages/GhcCabal.hs
index 0e915b3ea6..c88617b97f 100644
--- a/hadrian/src/Settings/Packages/GhcCabal.hs
+++ b/hadrian/src/Settings/Packages/GhcCabal.hs
@@ -8,10 +8,11 @@ import Utilities
ghcCabalPackageArgs :: Args
ghcCabalPackageArgs = stage0 ? package ghcCabal ? builder Ghc ? do
- cabalDeps <- expr $ stage1Dependencies cabal
+ cabalDeps <- expr $ stage1Dependencies cabal
+ let bootDeps = cabalDeps \\ [integerGmp, integerSimple, mtl, parsec, text]
cabalVersion <- expr $ pkgVersion (unsafePkgCabalFile cabal) -- TODO: improve
mconcat
- [ pure [ "-package " ++ pkgName pkg | pkg <- cabalDeps \\ [parsec, mtl] ]
+ [ pure [ "-package " ++ pkgName pkg | pkg <- bootDeps ]
, arg "--make"
, arg "-j"
, pure ["-Wall", "-fno-warn-unused-imports", "-fno-warn-warnings-deprecations"]
diff --git a/hadrian/src/Utilities.hs b/hadrian/src/Utilities.hs
index 3c61daecfd..fc898c35b9 100644
--- a/hadrian/src/Utilities.hs
+++ b/hadrian/src/Utilities.hs
@@ -24,21 +24,29 @@ buildWithResources rs target = H.buildWithResources rs target getArgs
buildWithCmdOptions :: [CmdOption] -> Target -> Action ()
buildWithCmdOptions opts target = H.buildWithCmdOptions opts target getArgs
--- | Given a 'Context' this 'Action' look up the package dependencies and wrap
+-- TODO: Cache the computation.
+-- | Given a 'Context' this 'Action' looks up the package dependencies and wraps
-- the results in appropriate contexts. The only subtlety here is that we never
-- depend on packages built in 'Stage2' or later, therefore the stage of the
-- resulting dependencies is bounded from above at 'Stage1'. To compute package
--- dependencies we scan package @.cabal@ files, see 'pkgDependencies' defined
--- in "Hadrian.Haskell.Cabal".
+-- dependencies we transitively scan @.cabal@ files using 'pkgDependencies'
+-- defined in "Hadrian.Haskell.Cabal".
contextDependencies :: Context -> Action [Context]
-contextDependencies Context {..} = case pkgCabalFile package of
- Nothing -> return [] -- Non-Cabal packages have no dependencies.
- Just cabalFile -> do
- let depStage = min stage Stage1
- depContext = \pkg -> Context depStage pkg way
- deps <- pkgDependencies cabalFile
- pkgs <- sort <$> stagePackages depStage
- return . map depContext $ intersectOrd (compare . pkgName) pkgs deps
+contextDependencies Context {..} = do
+ depPkgs <- go [package]
+ return [ Context depStage pkg way | pkg <- depPkgs, pkg /= package ]
+ where
+ depStage = min stage Stage1
+ go pkgs = do
+ deps <- concatMapM step pkgs
+ let newPkgs = nubOrd $ sort (deps ++ pkgs)
+ if pkgs == newPkgs then return pkgs else go newPkgs
+ step pkg = case pkgCabalFile pkg of
+ Nothing -> return [] -- Non-Cabal packages have no dependencies.
+ Just cabalFile -> do
+ deps <- pkgDependencies cabalFile
+ active <- sort <$> stagePackages depStage
+ return $ intersectOrd (compare . pkgName) active deps
-- | Lookup dependencies of a 'Package' in the vanilla Stage1 context.
stage1Dependencies :: Package -> Action [Package]