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

Factor out buildPackageGhciLibrary from buildPackageLibrary and make it more robust.

See #207.
parent 89c79cdb
......@@ -61,6 +61,7 @@ packageRules = do
let readPackageDb = [(packageDb, 1)]
writePackageDb = [(packageDb, maxConcurrentReaders)]
-- TODO: not all build rules make sense for all stage/package combinations
let contexts = liftM3 Context allStages knownPackages allWays
vanillaContexts = liftM2 vanillaContext allStages knownPackages
......@@ -72,6 +73,7 @@ packageRules = do
[ buildPackageData
, buildPackageDependencies readPackageDb
, buildPackageDocumentation
, buildPackageGhciLibrary
, generatePackageCode
, buildProgram
, registerPackage writePackageDb ]
......
{-# LANGUAGE RecordWildCards #-}
module Rules.Library (buildPackageLibrary, cSources, hSources) where
module Rules.Library (
buildPackageLibrary, buildPackageGhciLibrary, cSources, hSources
) where
import Data.Char
import qualified System.Directory as IO
......@@ -17,10 +19,10 @@ import Target
buildPackageLibrary :: Context -> Rules ()
buildPackageLibrary context @ (Context {..}) = do
let buildPath = targetPath stage package -/- "build"
libHs = buildPath -/- "libHS" ++ pkgNameString package
libPrefix = buildPath -/- "libHS" ++ pkgNameString package
-- TODO: handle dynamic libraries
matchVersionedFilePath libHs (waySuffix way <.> "a") ?> \a -> do
matchVersionedFilePath libPrefix (waySuffix way <.> "a") ?> \a -> do
removeFileIfExists a
cSrcs <- cSources context
hSrcs <- hSources context
......@@ -58,12 +60,13 @@ buildPackageLibrary context @ (Context {..}) = do
a
(dropWhileEnd isPunctuation synopsis)
buildPackageGhciLibrary :: Context -> Rules ()
buildPackageGhciLibrary context @ (Context {..}) = priority 2 $ do
let buildPath = targetPath stage package -/- "build"
libPrefix = buildPath -/- "HS" ++ pkgNameString package
-- TODO: simplify handling of AutoApply.cmm
-- 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.
-- This happens with hsc2hs, which has top-level file HSCParser.hs.
priority 2 $ when (package /= hsc2hs && way == vanilla) $
(buildPath -/- "HS*.o") %> \obj -> do
matchVersionedFilePath libPrefix (waySuffix way <.> "o") ?> \obj -> do
cSrcs <- cSources context
hSrcs <- hSources context
let cObjs = [ buildPath -/- src -<.> "o" | src <- cSrcs
......
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