Commit 5b9f6e90 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Allow cmm files in non-custom packages

parent c158014f
......@@ -102,13 +102,16 @@ packageCmmSources pkg
-- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
-- 1) Drop lines containing '$'. For example, get rid of
-- @libraries/Win32_dist-install_CMM_SRCS := $(addprefix cbits/,$(notdir ...@
-- Reason: we don't need them and we can't parse them.
-- and replace it with a tracked call to getDirectoryFiles.
-- 2) Drop path prefixes to individual settings.
-- For example, @libraries/deepseq/dist-install_VERSION = 1.4.0.0@
-- is replaced by @VERSION = 1.4.0.0@.
-- Reason: Shake's built-in makefile parser doesn't recognise slashes
postProcessPackageData :: Context -> FilePath -> Action ()
postProcessPackageData context@Context {..} file = do
top <- topDirectory
top <- topDirectory
cmmSrcs <- getDirectoryFiles (pkgPath package) ["cbits/*.cmm"]
let len = length (pkgPath package) + length (top -/- buildPath context) + 2
fixFile file $ unlines . map (drop len) . filter ('$' `notElem`) . lines
fixFile file $ unlines
. (++ ["CMM_SRCS = " ++ unwords (map unifyPath cmmSrcs) ])
. map (drop len) . filter ('$' `notElem`) . lines
......@@ -23,12 +23,8 @@ buildPackageLibrary context@Context {..} = do
-- TODO: handle dynamic libraries
matchVersionedFilePath libPrefix (waySuffix way <.> "a") ?> \a -> do
removeFile a
asmObjs <- map (objectPath context) <$> pkgDataList (AsmSrcs path)
cObjs <- cObjects context
cmmObjs <- map (objectPath context) <$> pkgDataList (CmmSrcs path)
eObjs <- extraObjects context
hsObjs <- hsObjects context
let noHsObjs = asmObjs ++ cObjs ++ cmmObjs ++ eObjs
hsObjs <- hsObjects context
noHsObjs <- nonHsObjects context
-- This will create split objects if required (we don't track them
-- explicitly as this would needlessly bloat the Shake database).
......@@ -56,10 +52,21 @@ buildPackageGhciLibrary :: Context -> Rules ()
buildPackageGhciLibrary context@Context {..} = priority 2 $ do
let libPrefix = buildPath context -/- "HS" ++ pkgNameString package
matchVersionedFilePath libPrefix (waySuffix way <.> "o") ?> \obj -> do
objs <- concatMapM ($ context) [cObjects, hsObjects, extraObjects]
objs <- allObjects context
need objs
build $ Target context Ld objs [obj]
allObjects :: Context -> Action [FilePath]
allObjects context = (++) <$> nonHsObjects context <*> hsObjects context
nonHsObjects :: Context -> Action [FilePath]
nonHsObjects context = do
let path = buildPath context
cObjs <- cObjects context
cmmObjs <- map (objectPath context) <$> pkgDataList (CmmSrcs path)
eObjs <- extraObjects context
return $ cObjs ++ cmmObjs ++ eObjs
cObjects :: Context -> Action [FilePath]
cObjects context = do
objs <- map (objectPath context) <$> pkgDataList (CSrcs $ buildPath context)
......
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