[commit: ghc] wip/nfs-locking: Add Settings/Builders/Common.hs for storing common Args, refactor code. (0c9571a)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:32:39 UTC 2017


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

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

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

commit 0c9571aac4cf2d4f5c84d6d2bcbf9a029e52c2ef
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Tue Dec 29 18:47:48 2015 +0000

    Add Settings/Builders/Common.hs for storing common Args, refactor code.


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

0c9571aac4cf2d4f5c84d6d2bcbf9a029e52c2ef
 src/Rules/Data.hs                        |  6 +++---
 src/Settings/Builders/Ar.hs              |  6 +++---
 src/Settings/Builders/Common.hs          |  9 +++++++++
 src/Settings/Builders/DeriveConstants.hs |  3 ++-
 src/Settings/Builders/GhcCabal.hs        | 10 +++-------
 5 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/Rules/Data.hs b/src/Rules/Data.hs
index 879dc1e..70c8e8a 100644
--- a/src/Rules/Data.hs
+++ b/src/Rules/Data.hs
@@ -8,7 +8,7 @@ import Predicates (registerPackage)
 import Rules.Actions
 import Rules.Resources
 import Settings
-import Settings.Builders.GhcCabal
+import Settings.Builders.Common
 
 -- Build package-data.mk by using GhcCabal to process pkgCabal file
 buildPackageData :: Resources -> PartialTarget -> Rules ()
@@ -42,9 +42,9 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
         postProcessPackageData dataFile
 
     -- TODO: PROGNAME was $(CrossCompilePrefix)hp2ps
-    -- TODO: code duplication around ghcIncludeDirs
     priority 2.0 $ do
         when (pkg == hp2ps) $ dataFile %> \mk -> do
+            includes <- interpretPartial target $ fromDiffExpr includesArgs
             let prefix = "utils_hp2ps_stage" ++ show (fromEnum stage) ++ "_"
                 cSrcs  = [ "AreaBelow.c", "Curves.c", "Error.c", "Main.c"
                          , "Reorder.c", "TopTwenty.c", "AuxFile.c"
@@ -57,7 +57,7 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
                     , "INSTALL = YES"
                     , "INSTALL_INPLACE = YES"
                     , "DEP_EXTRA_LIBS = m"
-                    , "CC_OPTS = " ++ unwords (map ("-I"++) ghcIncludeDirs) ]
+                    , "CC_OPTS = " ++ unwords includes ]
             writeFileChanged mk contents
             putSuccess $ "| Successfully generated '" ++ mk ++ "'."
 
diff --git a/src/Settings/Builders/Ar.hs b/src/Settings/Builders/Ar.hs
index 662d5fe..dae4a82 100644
--- a/src/Settings/Builders/Ar.hs
+++ b/src/Settings/Builders/Ar.hs
@@ -26,15 +26,15 @@ arCmd path argList = do
         fileArgs = drop arFlagsCount argList
     if arSupportsAtFile
     then useAtFile path flagArgs fileArgs
-    else useSuccessiveInvokations path flagArgs fileArgs
+    else useSuccessiveInvocations path flagArgs fileArgs
 
 useAtFile :: FilePath -> [String] -> [String] -> Action ()
 useAtFile path flagArgs fileArgs = withTempFile $ \tmp -> do
     writeFile' tmp $ unwords fileArgs
     cmd [path] flagArgs ('@' : tmp)
 
-useSuccessiveInvokations :: FilePath -> [String] -> [String] -> Action ()
-useSuccessiveInvokations path flagArgs fileArgs = do
+useSuccessiveInvocations :: FilePath -> [String] -> [String] -> Action ()
+useSuccessiveInvocations path flagArgs fileArgs = do
     maxChunk <- cmdLineLengthLimit
     forM_ (chunksOfSize maxChunk fileArgs) $ \argsChunk ->
         unit . cmd [path] $ flagArgs ++ argsChunk
diff --git a/src/Settings/Builders/Common.hs b/src/Settings/Builders/Common.hs
new file mode 100644
index 0000000..fc3ed53
--- /dev/null
+++ b/src/Settings/Builders/Common.hs
@@ -0,0 +1,9 @@
+module Settings.Builders.Common (includesArgs) where
+
+import Expression
+
+includes :: [FilePath]
+includes = [ "includes", "includes/dist-derivedconstants/header" ]
+
+includesArgs :: Args
+includesArgs = append $ map ("-I" ++) includes
diff --git a/src/Settings/Builders/DeriveConstants.hs b/src/Settings/Builders/DeriveConstants.hs
index 1f42243..ee07d34 100644
--- a/src/Settings/Builders/DeriveConstants.hs
+++ b/src/Settings/Builders/DeriveConstants.hs
@@ -7,6 +7,7 @@ import Expression
 import Oracles.Config.Flag
 import Oracles.Config.Setting
 import Predicates (builder, file)
+import Settings.Builders.Common
 import Settings.Builders.GhcCabal
 
 derivedConstantsPath :: FilePath
@@ -39,7 +40,7 @@ includeCcArgs = do
         , ccWarnings
         , append confCcArgs
         , flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
-        , append $ map ("-I" ++) ghcIncludeDirs -- TODO: fix code duplication
+        , includesArgs
         , arg "-Irts"
         , notM ghcWithSMP ? arg "-DNOSMP"
         , arg "-fcommon" ]
diff --git a/src/Settings/Builders/GhcCabal.hs b/src/Settings/Builders/GhcCabal.hs
index bd95cfc..61da725 100644
--- a/src/Settings/Builders/GhcCabal.hs
+++ b/src/Settings/Builders/GhcCabal.hs
@@ -1,5 +1,5 @@
 module Settings.Builders.GhcCabal (
-    cabalArgs, ghcCabalHsColourArgs, ghcIncludeDirs, bootPackageDbArgs,
+    cabalArgs, ghcCabalHsColourArgs, bootPackageDbArgs,
     customPackageArgs, ccArgs, cppArgs, ccWarnings, argStagedSettingList, needDll0
     ) where
 
@@ -14,6 +14,7 @@ import Stage
 import Expression
 import Predicates hiding (stage)
 import Settings
+import Settings.Builders.Common
 
 cabalArgs :: Args
 cabalArgs = builder GhcCabal ? do
@@ -115,13 +116,8 @@ ccWarnings = do
 ldArgs :: Args
 ldArgs = mempty
 
-ghcIncludeDirs :: [FilePath]
-ghcIncludeDirs = [ "includes", "includes/dist"
-                 , "includes/dist-derivedconstants/header"
-                 , "includes/dist-ghcconstants/header" ]
-
 cppArgs :: Args
-cppArgs = append $ map ("-I" ++) ghcIncludeDirs
+cppArgs = includesArgs
 
 -- TODO: Is this needed?
 -- ifeq "$(GMP_PREFER_FRAMEWORK)" "YES"



More information about the ghc-commits mailing list