summaryrefslogtreecommitdiff
path: root/hadrian/src
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-11-22 11:47:27 -0500
committerBen Gamari <ben@smart-cactus.org>2018-11-22 13:14:01 -0500
commit19ffddc1f479fcd5a0f265330cc1041366e8c43d (patch)
tree1a16b99032731e327219a001aa2cd76c3cf136f8 /hadrian/src
parent676f1f2d2eb39740fe5d88e72f6aa8e89cb0ebc0 (diff)
downloadhaskell-19ffddc1f479fcd5a0f265330cc1041366e8c43d.tar.gz
Hadrian: work around Cabal's/GHC's different Arch/OS strings
The path to the 'include' subdirectory of 'rts' includes a folder that whose name is generated by Cabal and mentiones the architecture and OS. For example: _build/stage1/lib/x86_64-osx-ghc-8.7.20181120/rts-1.0/include Hadrian needs to be aware that Cabal renders architectures and OSes in a slightly different way than GHC. There is already symmetric logic in Cabal (for working with GHC environment files, which follow GHC's naming conventions). Test Plan: ./hadrian/build.sh -c "binary-dist" # on mac Reviewers: snowleopard, alpmestan, bgamari Reviewed By: snowleopard Subscribers: rwbarton, carter GHC Trac Issues: #15922 Differential Revision: https://phabricator.haskell.org/D5361
Diffstat (limited to 'hadrian/src')
-rw-r--r--hadrian/src/Hadrian/Haskell/Cabal.hs20
-rw-r--r--hadrian/src/Rules/BinaryDist.hs6
2 files changed, 22 insertions, 4 deletions
diff --git a/hadrian/src/Hadrian/Haskell/Cabal.hs b/hadrian/src/Hadrian/Haskell/Cabal.hs
index 327e6a0618..91de7b2bb2 100644
--- a/hadrian/src/Hadrian/Haskell/Cabal.hs
+++ b/hadrian/src/Hadrian/Haskell/Cabal.hs
@@ -11,7 +11,8 @@
-----------------------------------------------------------------------------
module Hadrian.Haskell.Cabal (
pkgVersion, pkgIdentifier, pkgSynopsis, pkgDescription, pkgDependencies,
- pkgGenericDescription
+ pkgGenericDescription,
+ cabalArchString, cabalOsString,
) where
import Development.Shake
@@ -54,3 +55,20 @@ pkgDependencies = fmap (map pkgName . packageDependencies) . readPackageData
-- file is tracked.
pkgGenericDescription :: Package -> Action GenericPackageDescription
pkgGenericDescription = fmap genericPackageDescription . readPackageData
+
+-- | Cabal's rendering of an architecture as used in its directory structure.
+--
+-- Inverse of 'Cabal.Distribution.Simple.GHC.ghcArchString'.
+cabalArchString :: String -> String
+cabalArchString "powerpc" = "ppc"
+cabalArchString "powerpc64" = "ppc64"
+cabalArchString other = other
+
+-- | Cabal's rendering of an OS as used in its directory structure.
+--
+-- Inverse of 'Cabal.Distribution.Simple.GHC.ghcOsString'.
+cabalOsString :: String -> String
+cabalOsString "mingw32" = "windows"
+cabalOsString "darwin" = "osx"
+cabalOsString "solaris2" = "solaris"
+cabalOsString other = other
diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs
index f0aeb4b827..667fbf1454 100644
--- a/hadrian/src/Rules/BinaryDist.hs
+++ b/hadrian/src/Rules/BinaryDist.hs
@@ -19,14 +19,14 @@ bindistRules = do
need targets
version <- setting ProjectVersion
targetPlatform <- setting TargetPlatformFull
- hostOs <- setting BuildOs
- hostArch <- setting BuildArch
+ cabalHostOs <- cabalOsString <$> setting BuildOs
+ cabalHostArch <- cabalArchString <$> setting BuildArch
rtsDir <- pkgIdentifier rts
let ghcBuildDir = root -/- stageString Stage1
bindistFilesDir = root -/- "bindist" -/- ghcVersionPretty
ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform
- distDir = hostArch ++ "-" ++ hostOs ++ "-ghc-" ++ version
+ distDir = cabalHostArch ++ "-" ++ cabalHostOs ++ "-ghc-" ++ version
rtsIncludeDir = ghcBuildDir -/- "lib" -/- distDir -/- rtsDir
-/- "include"