[commit: ghc] wip/nfs-locking: Factor out postProcessPackageData to Util.hs. (c4cc0dc)
git at git.haskell.org
git at git.haskell.org
Thu Oct 26 23:00:30 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/c4cc0dc7ab0465a67f9f81e309fa10eaa210b772/ghc
>---------------------------------------------------------------
commit c4cc0dc7ab0465a67f9f81e309fa10eaa210b772
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date: Tue Dec 30 15:33:06 2014 +0000
Factor out postProcessPackageData to Util.hs.
>---------------------------------------------------------------
c4cc0dc7ab0465a67f9f81e309fa10eaa210b772
src/Package.hs | 6 ++----
src/Util.hs | 12 +++++++++++-
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/Package.hs b/src/Package.hs
index 8488044..24ef85d 100644
--- a/src/Package.hs
+++ b/src/Package.hs
@@ -122,15 +122,13 @@ buildPackageData pkg @ (Package name path _) (stage, dist, settings) =
"inplace-pkg-config",
"setup-config",
"build" </> "autogen" </> "cabal_macros.h",
- "build" </> "autogen" </> ("Paths_" ++ name) <.> "hs" -- TODO: Is this needed? What's up with Paths_cpsa.hs?
+ "build" </> "autogen" </> ("Paths_" ++ name) <.> "hs" -- TODO: Is this needed? Also check out Paths_cpsa.hs.
] &%> \_ -> do
need [path </> name <.> "cabal"]
when (doesFileExist $ path </> "configure.ac") $ need [path </> "configure"]
run GhcCabal cabalArgs
when (registerPackage settings) $ run (GhcPkg stage) ghcPkgArgs
- let pkgDataFile = path </> dist </> "package-data.mk"
- pkgData <- lines <$> liftIO (readFile pkgDataFile)
- length pkgData `seq` writeFileLines pkgDataFile $ map (replaceIf isSlash '_') $ filter ('$' `notElem`) pkgData
+ postProcessPackageData $ path </> dist </> "package-data.mk"
where
cabalArgs, ghcPkgArgs :: Args
cabalArgs = mconcat
diff --git a/src/Util.hs b/src/Util.hs
index 8afd6cb..b8a38f4 100644
--- a/src/Util.hs
+++ b/src/Util.hs
@@ -1,9 +1,11 @@
module Util (
module Data.Char,
isSlash,
- replaceIf, replaceEq
+ replaceIf, replaceEq,
+ postProcessPackageData
) where
+import Base
import Data.Char
isSlash :: Char -> Bool
@@ -14,3 +16,11 @@ replaceIf p to = map (\from -> if p from then to else from)
replaceEq :: Eq a => a -> a -> [a] -> [a]
replaceEq from = replaceIf (== from)
+
+-- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
+-- 1) Drop lines containing '$'
+-- 2) Replace '/' and '\' with '_'
+postProcessPackageData :: FilePath -> Action ()
+postProcessPackageData file = do
+ pkgData <- (filter ('$' `notElem`) . lines) <$> liftIO (readFile file)
+ length pkgData `seq` writeFileLines file $ map (replaceIf isSlash '_') pkgData
More information about the ghc-commits
mailing list