[commit: ghc] wip/nfs-locking: Move integerLibrary to flavour (6b35c2c)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:47:42 UTC 2017


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

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

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

commit 6b35c2c39cc41a548582483476c84e68798687b8
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sun Jan 8 01:28:06 2017 +0000

    Move integerLibrary to flavour
    
    See #179


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

6b35c2c39cc41a548582483476c84e68798687b8
 src/Flavour.hs                   |  1 +
 src/Rules/Generators/ConfigHs.hs | 11 +++++------
 src/Settings.hs                  |  6 +++++-
 src/Settings/Default.hs          |  4 ++--
 src/Settings/Packages/Base.hs    |  5 ++---
 src/UserSettings.hs              |  7 +------
 6 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/src/Flavour.hs b/src/Flavour.hs
index ad658c4..b195767 100644
--- a/src/Flavour.hs
+++ b/src/Flavour.hs
@@ -8,6 +8,7 @@ data Flavour = Flavour
     { name               :: String    -- ^ Flavour name, to set from command line.
     , args               :: Args      -- ^ Use these command line arguments.
     , packages           :: Packages  -- ^ Build these packages.
+    , integerLibrary     :: Package   -- ^ Either 'integerGmp' or 'integerSimple'.
     , libraryWays        :: Ways      -- ^ Build libraries these ways.
     , rtsWays            :: Ways      -- ^ Build RTS these ways.
     , splitObjects       :: Predicate -- ^ Build split objects.
diff --git a/src/Rules/Generators/ConfigHs.hs b/src/Rules/Generators/ConfigHs.hs
index c5ad0cc..ffe0cfc 100644
--- a/src/Rules/Generators/ConfigHs.hs
+++ b/src/Rules/Generators/ConfigHs.hs
@@ -8,7 +8,6 @@ import Oracles.Config.Flag
 import Oracles.Config.Setting
 import Rules.Generators.Common
 import Settings
-import UserSettings
 
 generateConfigHs :: Expr String
 generateConfigHs = do
@@ -21,10 +20,10 @@ generateConfigHs = do
     cProjectPatchLevel1 <- getSetting ProjectPatchLevel1
     cProjectPatchLevel2 <- getSetting ProjectPatchLevel2
     cBooterVersion      <- getSetting GhcVersion
-    let cIntegerLibraryType | integerLibrary == integerGmp    = "IntegerGMP"
-                            | integerLibrary == integerSimple = "IntegerSimple"
-                            | otherwise = error $ "Unknown integer library: "
-                                          ++ show integerLibrary ++ "."
+    let cIntegerLibraryType
+            | integerLibrary flavour == integerGmp    = "IntegerGMP"
+            | integerLibrary flavour == integerSimple = "IntegerSimple"
+            | otherwise = error $ "Unknown integer library: " ++ integerLibraryName
     cSupportsSplitObjs         <- yesNo supportsSplitObjects
     cGhcWithInterpreter        <- yesNo ghcWithInterpreter
     cGhcWithNativeCodeGen      <- yesNo ghcWithNativeCodeGen
@@ -72,7 +71,7 @@ generateConfigHs = do
         , "cStage                :: String"
         , "cStage                = show (STAGE :: Int)"
         , "cIntegerLibrary       :: String"
-        , "cIntegerLibrary       = " ++ show (pkgNameString integerLibrary)
+        , "cIntegerLibrary       = " ++ show integerLibraryName
         , "cIntegerLibraryType   :: IntegerLibrary"
         , "cIntegerLibraryType   = " ++ cIntegerLibraryType
         , "cSupportsSplitObjs    :: String"
diff --git a/src/Settings.hs b/src/Settings.hs
index c455e0b..09b58f8 100644
--- a/src/Settings.hs
+++ b/src/Settings.hs
@@ -2,7 +2,8 @@ module Settings (
     getArgs, getPackages, getLibraryWays, getRtsWays, flavour, knownPackages,
     findKnownPackage, getPkgData, getPkgDataList, isLibrary, getPackagePath,
     getContextDirectory, getBuildPath, stagePackages, builderPath,
-    getBuilderPath, isSpecified, latestBuildStage, programPath, programContext
+    getBuilderPath, isSpecified, latestBuildStage, programPath, programContext,
+    integerLibraryName
     ) where
 
 import Base
@@ -62,6 +63,9 @@ flavour = fromMaybe unknownFlavour $ find ((== flavourName) . name) flavours
     flavours       = hadrianFlavours ++ userFlavours
     flavourName    = fromMaybe "default" cmdFlavour
 
+integerLibraryName :: String
+integerLibraryName = pkgNameString $ integerLibrary flavour
+
 programContext :: Stage -> Package -> Context
 programContext stage pkg
     | pkg == ghc && ghcProfiled flavour = Context stage pkg profiling
diff --git a/src/Settings/Default.hs b/src/Settings/Default.hs
index 92089ab..103c432 100644
--- a/src/Settings/Default.hs
+++ b/src/Settings/Default.hs
@@ -37,7 +37,6 @@ import Settings.Packages.Haddock
 import Settings.Packages.IntegerGmp
 import Settings.Packages.Rts
 import Settings.Packages.RunGhc
-import UserSettings
 
 -- | All default command line arguments.
 defaultArgs :: Args
@@ -100,7 +99,7 @@ stage1Packages = do
                        , haskeline
                        , hpcBin
                        , hsc2hs
-                       , integerLibrary
+                       , integerLibrary flavour
                        , pretty
                        , process
                        , rts
@@ -147,6 +146,7 @@ defaultFlavour = Flavour
     { name               = "default"
     , args               = defaultArgs
     , packages           = defaultPackages
+    , integerLibrary     = integerGmp
     , libraryWays        = defaultLibraryWays
     , rtsWays            = defaultRtsWays
     , splitObjects       = defaultSplitObjects
diff --git a/src/Settings/Packages/Base.hs b/src/Settings/Packages/Base.hs
index dce49e7..219c9d4 100644
--- a/src/Settings/Packages/Base.hs
+++ b/src/Settings/Packages/Base.hs
@@ -1,11 +1,10 @@
 module Settings.Packages.Base (basePackageArgs) where
 
-import Base
 import GHC
 import Predicate
-import UserSettings
+import Settings
 
 basePackageArgs :: Args
 basePackageArgs = package base ? mconcat
-    [ builder GhcCabal ? arg ("--flags=" ++ takeFileName (pkgPath integerLibrary))
+    [ builder GhcCabal ? arg ("--flags=" ++ integerLibraryName)
     , builder Cc ? arg "-O2" ] -- Fix the 'unknown symbol stat' issue, see #259.
diff --git a/src/UserSettings.hs b/src/UserSettings.hs
index b952363..e16cf49 100644
--- a/src/UserSettings.hs
+++ b/src/UserSettings.hs
@@ -3,7 +3,7 @@
 -- If you don't copy the file your changes will be tracked by git and you can
 -- accidentally commit them.
 module UserSettings (
-    buildRootPath, userFlavours, userKnownPackages, integerLibrary, validating,
+    buildRootPath, userFlavours, userKnownPackages, validating,
     turnWarningsIntoErrors, verboseCommands, putBuild, putSuccess
     ) where
 
@@ -11,7 +11,6 @@ import System.Console.ANSI
 
 import Base
 import Flavour
-import GHC
 import Predicate
 
 -- See doc/user-settings.md for instructions.
@@ -30,10 +29,6 @@ userFlavours = []
 userKnownPackages :: [Package]
 userKnownPackages = []
 
--- | Choose the integer library: 'integerGmp' or 'integerSimple'.
-integerLibrary :: Package
-integerLibrary = integerGmp
-
 -- | User defined flags. Note the following type semantics:
 -- * @Bool@: a plain Boolean flag whose value is known at compile time.
 -- * @Action Bool@: a flag whose value can depend on the build environment.



More information about the ghc-commits mailing list