[commit: ghc] wip/nfs-locking: Drop stringly-typed configuration keys. (4512f27)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:30:48 UTC 2017


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

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

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

commit 4512f2736c3fec57c6e067c760a229915abff307
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Fri Jul 24 00:21:19 2015 +0100

    Drop stringly-typed configuration keys.


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

4512f2736c3fec57c6e067c760a229915abff307
 src/Settings/GhcCabal.hs | 21 ++++++++++-----------
 src/Settings/Util.hs     | 29 ++++++++---------------------
 src/Switches.hs          | 11 +++++++----
 3 files changed, 25 insertions(+), 36 deletions(-)

diff --git a/src/Settings/GhcCabal.hs b/src/Settings/GhcCabal.hs
index 0e4db8f..05ec1fc 100644
--- a/src/Settings/GhcCabal.hs
+++ b/src/Settings/GhcCabal.hs
@@ -3,7 +3,6 @@ module Settings.GhcCabal (
     ) where
 
 import Way
-import Stage
 import Builder
 import Package
 import Util
@@ -36,7 +35,7 @@ cabalArgs = builder GhcCabal ? do
             , configureArgs
             , stage0 ? packageConstraints
             , with $ Gcc stage
-            , notStage Stage0 ? with Ld
+            , notStage0 ? with Ld
             , with Ar
             , with Alex
             , with Happy ]
@@ -65,25 +64,25 @@ configureArgs = do
     let conf key = appendSubD $ "--configure-option=" ++ key
         cFlags   = mconcat [ ccArgs
                            , remove ["-Werror"]
-                           , argStagedConfig "conf-cc-args" ]
-        ldFlags  = ldArgs <> argStagedConfig "conf-gcc-linker-args"
-        cppFlags = cppArgs <> argStagedConfig "conf-cpp-args"
+                           , argSettingList $ ConfCcArgs stage ]
+        ldFlags  = ldArgs <> (argSettingList $ ConfGccLinkerArgs stage)
+        cppFlags = cppArgs <> (argSettingList $ ConfCppArgs stage)
     mconcat
         [ conf "CFLAGS"   cFlags
         , conf "LDFLAGS"  ldFlags
         , conf "CPPFLAGS" cppFlags
         , appendSubD "--gcc-options" $ cFlags <> ldFlags
-        , conf "--with-iconv-includes"  $ argConfig "iconv-include-dirs"
-        , conf "--with-iconv-libraries" $ argConfig "iconv-lib-dirs"
-        , conf "--with-gmp-includes"    $ argConfig "gmp-include-dirs"
-        , conf "--with-gmp-libraries"   $ argConfig "gmp-lib-dirs"
+        , conf "--with-iconv-includes"  $ argSettingList IconvIncludeDirs
+        , conf "--with-iconv-libraries" $ argSettingList IconvLibDirs
+        , conf "--with-gmp-includes"    $ argSettingList GmpIncludeDirs
+        , conf "--with-gmp-libraries"   $ argSettingList GmpLibDirs
         -- TODO: why TargetPlatformFull and not host?
-        , crossCompiling ? (conf "--host" $ argConfig "target-platform-full")
+        , crossCompiling ? (conf "--host" $ argSetting TargetPlatformFull)
         , conf "--with-cc" . argM . builderPath $ Gcc stage ]
 
 bootPackageDbArgs :: Args
 bootPackageDbArgs = do
-    sourcePath <- lift $ askConfig "ghc-source-path"
+    sourcePath <- lift . setting $ GhcSourcePath
     arg $ "--package-db=" ++ sourcePath </> "libraries/bootstrapping.conf"
 
 -- This is a positional argument, hence:
diff --git a/src/Settings/Util.hs b/src/Settings/Util.hs
index 82be349..5f0d035 100644
--- a/src/Settings/Util.hs
+++ b/src/Settings/Util.hs
@@ -1,7 +1,7 @@
 module Settings.Util (
     -- Primitive settings elements
     arg, argPath, argM,
-    argConfig, argStagedConfig, argConfigList, argStagedConfigList,
+    argSetting, argSettingList,
     appendCcArgs,
     needBuilder
     -- argBuilderPath, argStagedBuilderPath,
@@ -13,11 +13,11 @@ module Settings.Util (
     ) where
 
 import Util
-import Stage
 import Builder
-import Settings.User
-import Oracles.Base
 import Expression
+import Oracles.Base
+import Oracles.Setting
+import Settings.User
 
 -- A single argument.
 arg :: String -> Args
@@ -30,24 +30,11 @@ argPath = append . return . unifyPath
 argM :: Action String -> Args
 argM = appendM . fmap return
 
-argConfig :: String -> Args
-argConfig = appendM . fmap return . askConfig
-
-argConfigList :: String -> Args
-argConfigList = appendM . fmap words . askConfig
+argSetting :: Setting -> Args
+argSetting = argM . setting
 
-stagedKey :: Stage -> String -> String
-stagedKey stage key = key ++ "-stage" ++ show stage
-
-argStagedConfig :: String -> Args
-argStagedConfig key = do
-    stage <- asks getStage
-    argConfig (stagedKey stage key)
-
-argStagedConfigList :: String -> Args
-argStagedConfigList key = do
-    stage <- asks getStage
-    argConfigList (stagedKey stage key)
+argSettingList :: SettingList -> Args
+argSettingList = appendM . settingList
 
 -- Pass arguments to Gcc and corresponding lists of sub-arguments of GhcCabal
 appendCcArgs :: [String] -> Args
diff --git a/src/Switches.hs b/src/Switches.hs
index 8d5e124..3a56a5a 100644
--- a/src/Switches.hs
+++ b/src/Switches.hs
@@ -1,5 +1,5 @@
 module Switches (
-    notStage, stage0, stage1, stage2,
+    stage0, stage1, stage2, notStage, notStage0,
     registerPackage, splitObjects
     ) where
 
@@ -9,9 +9,6 @@ import Oracles.Setting
 import Expression
 
 -- Derived predicates
-notStage :: Stage -> Predicate
-notStage = notP . stage
-
 stage0 :: Predicate
 stage0 = stage Stage0
 
@@ -21,6 +18,12 @@ stage1 = stage Stage1
 stage2 :: Predicate
 stage2 = stage Stage2
 
+notStage :: Stage -> Predicate
+notStage = notP . stage
+
+notStage0 :: Predicate
+notStage0 = notP stage0
+
 -- TODO: Actually, we don't register compiler in some circumstances -- fix.
 registerPackage :: Predicate
 registerPackage = return True



More information about the ghc-commits mailing list