Commit 020d528e authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Implement build rule for GHCI libraries.

parent 85808dd1
......@@ -4,6 +4,7 @@ import Way
import Base
import Util
import Builder
import Package
import Switches
import Expression
import qualified Target
......@@ -12,6 +13,7 @@ import Settings.Util
import Settings.TargetDirectory
import Rules.Actions
import Rules.Resources
import Data.List
import Data.Maybe
buildPackageLibrary :: Resources -> StagePackageTarget -> Rules ()
......@@ -21,6 +23,7 @@ buildPackageLibrary _ target = do
path = targetPath stage pkg
buildPath = path -/- "build"
-- TODO: handle dynamic libraries
matchBuildResult buildPath "a" ?> \a -> do
liftIO $ removeFiles "." [a]
cSrcs <- interpret target $ getPkgDataList CSrcs
......@@ -33,31 +36,27 @@ buildPackageLibrary _ target = do
need $ cObjs ++ hsObjs -- this will create split objects if required
splitObjs <- fmap concat $ forM hsSrcs $ \src -> do
let files = buildPath -/- src ++ "_" ++ osuf way ++ "_split/*"
getDirectoryFiles "" [files]
split <- interpret target splitObjects
let allObjs = if split
then cObjs ++ hsObjs ++ splitObjs
else cObjs ++ hsObjs
build $ fullTarget target allObjs Ar [a]
-- ldRule :: Resources -> StagePackageTarget -> Rules ()
-- ldRule pkg @ (Package name path _ _) todo @ (stage, dist, _) =
-- let pathDist = path </> dist
-- buildDir = pathDist </> "build"
-- in
-- priority 2 $ (buildDir </> "*.o") %> \out -> do
-- cObjs <- pkgCObjects path dist vanilla
-- hObjs <- pkgDepHsObjects path dist vanilla
-- need $ cObjs ++ hObjs
-- run Ld $ ldArgs stage (cObjs ++ hObjs) $ unifyPath out
-- synopsis <- dropWhileEnd isPunctuation <$> showArg (Synopsis pathDist)
-- putColoured Green $ "/--------\n| Successfully built package '"
-- ++ name ++ "' (stage " ++ show stage ++ ")."
-- putColoured Green $ "| Package synopsis: " ++ synopsis ++ "."
-- ++ "\n\\--------"
-- -- Finally, record the argument list
-- need [argListPath argListDir pkg stage]
splitObjs <- if split
then fmap concat $ forM hsSrcs $ \src -> do
let files = buildPath -/- src ++ "_" ++ osuf way ++ "_split/*"
getDirectoryFiles "" [files]
else return []
build $ fullTarget target (cObjs ++ hsObjs ++ splitObjs) Ar [a]
synopsis <- interpret target $ getPkgData Synopsis
putSuccess $ "/--------\n| Successfully built package '"
++ pkgName pkg ++ "' (stage " ++ show stage ++ ")."
putSuccess $ "| Package synopsis: "
++ dropWhileEnd isPunctuation synopsis ++ "." ++ "\n\\--------"
-- TODO: this looks fragile as haskell objects can match this rule if their
-- names start with "HS" and they are on top of the module hierarchy.
(buildPath -/- "HS*.o") %> \o -> do
cSrcs <- interpret target $ getPkgDataList CSrcs
modules <- interpret target $ getPkgDataList Modules
let hsSrcs = map (replaceEq '.' '/') modules
cObjs = [ buildPath -/- src -<.> "o" | src <- cSrcs ]
hsObjs = [ buildPath -/- src <.> "o" | src <- hsSrcs ]
build $ fullTarget target (cObjs ++ hsObjs) Ld [o]
......@@ -39,6 +39,7 @@ cabalArgs = builder GhcCabal ? do
, with Happy ]
-- TODO: Isn't vanilla always built? If yes, some conditions are redundant.
-- TODO: Need compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci?
libraryArgs :: Args
libraryArgs = do
ways <- getWays
......
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