summaryrefslogtreecommitdiff
path: root/hadrian/src/Rules/Generate.hs
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2019-06-20 18:04:30 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-07-09 22:56:18 -0400
commit24782b89907ab36fb5aef3a17584f4c10f1e2690 (patch)
treeb0d55f9b146f33fc901aa10b166a647aeded0c0e /hadrian/src/Rules/Generate.hs
parent0472f0f6a92395d478e9644c0dbd12948518099f (diff)
downloadhaskell-24782b89907ab36fb5aef3a17584f4c10f1e2690.tar.gz
Deduplicate "unique subdir" code between GHC and Cabal
The code, including the generated module with the version, is now in ghc-boot. Config.hs reexports stuff as needed, ghc-pkg doesn't need any tricks at all.
Diffstat (limited to 'hadrian/src/Rules/Generate.hs')
-rw-r--r--hadrian/src/Rules/Generate.hs67
1 files changed, 42 insertions, 25 deletions
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index edf6783055..1949c3bfe2 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -116,8 +116,8 @@ generatePackageCode context@(Context stage pkg _) = do
when (pkg == ghcPrim) $ do
root <//> dir -/- "GHC/Prim.hs" %> genPrimopCode context
root <//> dir -/- "GHC/PrimopWrappers.hs" %> genPrimopCode context
- when (pkg == ghcPkg) $
- root <//> dir -/- "Version.hs" %> go generateVersionHs
+ when (pkg == ghcBoot) $
+ root <//> dir -/- "GHC/Version.hs" %> go generateVersionHs
when (pkg == compiler) $ do
root -/- primopsTxt stage %> \file -> do
@@ -337,42 +337,36 @@ generateConfigHs :: Expr String
generateConfigHs = do
trackGenerateHs
cProjectName <- getSetting ProjectName
- cProjectGitCommitId <- getSetting ProjectGitCommitId
- cProjectVersion <- getSetting ProjectVersion
- cProjectVersionInt <- getSetting ProjectVersionInt
- cProjectPatchLevel <- getSetting ProjectPatchLevel
- cProjectPatchLevel1 <- getSetting ProjectPatchLevel1
- cProjectPatchLevel2 <- getSetting ProjectPatchLevel2
cBooterVersion <- getSetting GhcVersion
return $ unlines
[ "{-# LANGUAGE CPP #-}"
- , "module Config where"
+ , "module Config"
+ , " ( module GHC.Version"
+ , " , cBuildPlatformString"
+ , " , cHostPlatformString"
+ , " , cProjectName"
+ , " , cBooterVersion"
+ , " , cStage"
+ , " ) where"
, ""
, "import GhcPrelude"
, ""
+ , "import GHC.Version"
+ , ""
, "#include \"ghc_boot_platform.h\""
, ""
, "cBuildPlatformString :: String"
, "cBuildPlatformString = BuildPlatform_NAME"
+ , ""
, "cHostPlatformString :: String"
, "cHostPlatformString = HostPlatform_NAME"
, ""
, "cProjectName :: String"
, "cProjectName = " ++ show cProjectName
- , "cProjectGitCommitId :: String"
- , "cProjectGitCommitId = " ++ show cProjectGitCommitId
- , "cProjectVersion :: String"
- , "cProjectVersion = " ++ show cProjectVersion
- , "cProjectVersionInt :: String"
- , "cProjectVersionInt = " ++ show cProjectVersionInt
- , "cProjectPatchLevel :: String"
- , "cProjectPatchLevel = " ++ show cProjectPatchLevel
- , "cProjectPatchLevel1 :: String"
- , "cProjectPatchLevel1 = " ++ show cProjectPatchLevel1
- , "cProjectPatchLevel2 :: String"
- , "cProjectPatchLevel2 = " ++ show cProjectPatchLevel2
+ , ""
, "cBooterVersion :: String"
, "cBooterVersion = " ++ show cBooterVersion
+ , ""
, "cStage :: String"
, "cStage = show (STAGE :: Int)"
]
@@ -492,9 +486,32 @@ generateGhcVersionH = do
generateVersionHs :: Expr String
generateVersionHs = do
trackGenerateHs
- projectVersion <- getSetting ProjectVersion
+ cProjectGitCommitId <- getSetting ProjectGitCommitId
+ cProjectVersion <- getSetting ProjectVersion
+ cProjectVersionInt <- getSetting ProjectVersionInt
+ cProjectPatchLevel <- getSetting ProjectPatchLevel
+ cProjectPatchLevel1 <- getSetting ProjectPatchLevel1
+ cProjectPatchLevel2 <- getSetting ProjectPatchLevel2
return $ unlines
- [ "module Version where"
- , "version :: String"
- , "version = " ++ show projectVersion
+ [ "module GHC.Version where"
+ , ""
+ , "import Prelude -- See Note [Why do we import Prelude here?]"
+ , ""
+ , "cProjectGitCommitId :: String"
+ , "cProjectGitCommitId = " ++ show cProjectGitCommitId
+ , ""
+ , "cProjectVersion :: String"
+ , "cProjectVersion = " ++ show cProjectVersion
+ , ""
+ , "cProjectVersionInt :: String"
+ , "cProjectVersionInt = " ++ show cProjectVersionInt
+ , ""
+ , "cProjectPatchLevel :: String"
+ , "cProjectPatchLevel = " ++ show cProjectPatchLevel
+ , ""
+ , "cProjectPatchLevel1 :: String"
+ , "cProjectPatchLevel1 = " ++ show cProjectPatchLevel1
+ , ""
+ , "cProjectPatchLevel2 :: String"
+ , "cProjectPatchLevel2 = " ++ show cProjectPatchLevel2
]