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

Refactor Settings.Paths, add pkgConfFile.

See #200.
parent 8424eb5e
......@@ -4,7 +4,6 @@ import Base
import Data.Foldable
import Expression
import GHC
import Oracles.PackageData
import qualified Rules.Generate
import Rules.Package
import Rules.Resources
......@@ -22,8 +21,8 @@ topLevelTargets = do
-- TODO: do we want libffiLibrary to be a top-level target?
action $ do -- TODO: Add support for all rtsWays
rtsLib <- pkgLibraryFile Stage1 rts "rts" vanilla
rtsThrLib <- pkgLibraryFile Stage1 rts "rts" threaded
rtsLib <- pkgLibraryFile Stage1 rts vanilla
rtsThrLib <- pkgLibraryFile Stage1 rts threaded
need [ rtsLib, rtsThrLib ]
for_ allStages $ \stage ->
......@@ -34,8 +33,7 @@ topLevelTargets = do
if isLibrary pkg
then do -- build a library
ways <- interpretPartial target getLibraryWays
compId <- interpretPartial target $ getPkgData ComponentId
libs <- traverse (pkgLibraryFile stage pkg compId) ways
libs <- traverse (pkgLibraryFile stage pkg) ways
haddock <- interpretPartial target buildHaddock
need $ libs ++ [ pkgHaddockFile pkg | haddock && stage == Stage1 ]
else do -- otherwise build a program
......
......@@ -86,14 +86,13 @@ buildBinary target @ (PartialTarget stage pkg) bin = do
let deps = matchPackageNames (sort pkgs) (map PackageName $ sort depNames)
ghci = ghciFlag == "YES" && stage == Stage1
libs <- fmap concat . forM deps $ \dep -> do
let depTarget = PartialTarget libStage dep
compId <- interpretPartial depTarget $ getPkgData ComponentId
libFiles <- fmap concat . forM ways $ \way -> do
libFile <- pkgLibraryFile libStage dep compId way
lib0File <- pkgLibraryFile libStage dep (compId ++ "-0") way
libFile <- pkgLibraryFile libStage dep way
lib0File <- pkgLibraryFile0 libStage dep way
dll0 <- needDll0 libStage dep
return $ libFile : [ lib0File | dll0 ]
return $ libFiles ++ [ pkgGhciLibraryFile libStage dep compId | ghci ]
ghciLib <- pkgGhciLibraryFile libStage dep
return $ libFiles ++ [ ghciLib | ghci ]
let binDeps = if pkg == ghcCabal && stage == Stage0
then [ pkgPath pkg -/- src <.> "hs" | src <- hSrcs ]
else objs
......
module Settings.Paths (
targetDirectory, targetPath, pkgDataFile, pkgHaddockFile, pkgLibraryFile,
pkgGhciLibraryFile, gmpBuildPath, gmpLibNameCache, packageDbDirectory
pkgLibraryFile0, pkgGhciLibraryFile, gmpBuildPath, gmpLibNameCache,
packageDbDirectory, pkgConfFile
) where
import Base
import Expression
import GHC
import Oracles.PackageData
import Settings.User
-- Path to the target directory from GHC source root
......@@ -24,18 +26,26 @@ pkgHaddockFile pkg =
-- Relative path to a package library file, e.g.:
-- "libraries/array/stage2/build/libHSarray-0.5.1.0.a"
-- TODO: remove code duplication for computing buildPath
pkgLibraryFile :: Stage -> Package -> String -> Way -> Action FilePath
pkgLibraryFile stage pkg componentId way = do
pkgLibraryFile :: Stage -> Package -> Way -> Action FilePath
pkgLibraryFile stage pkg way = do
extension <- libsuf way
let buildPath = targetPath stage pkg -/- "build"
return $ buildPath -/- "libHS" ++ componentId ++ extension
pkgFile stage pkg "build/libHS" extension
pkgLibraryFile0 :: Stage -> Package -> Way -> Action FilePath
pkgLibraryFile0 stage pkg way = do
extension <- libsuf way
pkgFile stage pkg "build/libHS" ("-0" ++ extension)
-- Relative path to a package ghci library file, e.g.:
-- "libraries/array/dist-install/build/HSarray-0.5.1.0.o"
pkgGhciLibraryFile :: Stage -> Package -> String -> FilePath
pkgGhciLibraryFile stage pkg componentId =
targetPath stage pkg -/- "build" -/- "HS" ++ componentId <.> "o"
pkgGhciLibraryFile :: Stage -> Package -> Action FilePath
pkgGhciLibraryFile stage pkg = pkgFile stage pkg "build/HS" ".o"
pkgFile :: Stage -> Package -> String -> String -> Action FilePath
pkgFile stage pkg prefix suffix = do
let path = targetPath stage pkg
componentId <- pkgData $ ComponentId path
return $ path -/- prefix ++ componentId ++ suffix
-- This is the build directory for in-tree GMP library
gmpBuildPath :: FilePath
......@@ -50,3 +60,8 @@ gmpLibNameCache = gmpBuildPath -/- "gmp-lib-names"
packageDbDirectory :: Stage -> FilePath
packageDbDirectory Stage0 = buildRootPath -/- "stage0/bootstrapping.conf"
packageDbDirectory _ = "inplace/lib/package.conf.d"
pkgConfFile :: Stage -> Package -> Action FilePath
pkgConfFile stage pkg = do
componentId <- pkgData . ComponentId $ targetPath stage pkg
return $ packageDbDirectory stage -/- componentId <.> "conf"
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