[commit: ghc] wip/nfs-locking: Implement search for *.hs and *.o files for a given package. (750a43f)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:21:29 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/750a43fcef635a38485a1a2ecc30412e557e44f0/ghc

>---------------------------------------------------------------

commit 750a43fcef635a38485a1a2ecc30412e557e44f0
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Tue Jan 13 02:23:01 2015 +0000

    Implement search for *.hs and *.o files for a given package.


>---------------------------------------------------------------

750a43fcef635a38485a1a2ecc30412e557e44f0
 src/Package/Base.hs | 50 +++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 39 insertions(+), 11 deletions(-)

diff --git a/src/Package/Base.hs b/src/Package/Base.hs
index d9302b7..a8de80d 100644
--- a/src/Package/Base.hs
+++ b/src/Package/Base.hs
@@ -8,7 +8,8 @@ module Package.Base (
     defaultSettings, libraryPackage,
     commonCcArgs, commonLdArgs, commonCppArgs, commonCcWarninigArgs,
     bootPkgConstraints,
-    pathArgs, packageArgs, includeArgs, srcArgs
+    pathArgs, packageArgs, includeArgs, pkgHsSources, 
+    pkgDepObjects, pkgLibObjects
     ) where
 
 import Base
@@ -108,13 +109,40 @@ includeArgs path dist =
     <> arg "-optP-include" -- TODO: Shall we also add -cpp?
     <> concatArgs "-optP" (buildDir </> "autogen/cabal_macros.h")
 
-srcArgs :: FilePath -> FilePath -> Args
-srcArgs path pkgData = do
-    mods <- arg (Modules pkgData)
-    dirs <- arg (SrcDirs pkgData)
-    srcs <- getDirectoryFiles "" $ do
-        dir       <- dirs
-        modPath   <- map (replaceEq '.' pathSeparator) mods
-        extension <- ["hs", "lhs"]
-        return $ path </> dir </> modPath <.> extension
-    arg (map normaliseEx srcs)
+pkgHsSources :: FilePath -> FilePath -> Action [FilePath]
+pkgHsSources path dist = do
+    let pkgData = path </> dist </> "package-data.mk"
+    dirs <- map (path </>) <$> arg (SrcDirs pkgData)
+    findModuleFiles pkgData dirs [".hs", ".lhs"]
+
+-- Find objects we depend on (we don't want to depend on split objects)
+-- TODO: look for non-hs objects too 
+pkgDepObjects :: FilePath -> FilePath -> Way -> Action [FilePath]
+pkgDepObjects path dist way = do
+    let pkgData  = path </> dist </> "package-data.mk"
+        buildDir = path </> dist </> "build"
+        hs2obj   = (buildDir ++) . drop (length path) . (-<.> osuf way)
+    srcs <- pkgHsSources path dist
+    return $ map hs2obj srcs
+
+-- Find objects that go to library
+pkgLibObjects :: FilePath -> FilePath -> Stage -> Way -> Action [FilePath]
+pkgLibObjects path dist stage way = do
+    let pkgData  = path </> dist </> "package-data.mk"
+        buildDir = path </> dist </> "build"
+    split <- splitObjects stage
+    if split
+    then do
+         let suffixes = ["_" ++ osuf way ++ "_split//*"]
+         findModuleFiles pkgData [buildDir] suffixes
+    else pkgDepObjects path dist way
+
+findModuleFiles :: FilePath -> [FilePath] -> [String] -> Action [FilePath]
+findModuleFiles pkgData directories suffixes = do
+    mods  <- arg (Modules pkgData)
+    files <- getDirectoryFiles "" $ do
+        dir     <- directories
+        modPath <- map (replaceEq '.' pathSeparator) mods
+        suffix  <- suffixes
+        return $ dir </> modPath ++ suffix
+    return $ map normaliseEx files



More information about the ghc-commits mailing list