Commit 19ffddc1 authored by Alec Theriault's avatar Alec Theriault Committed by Ben Gamari

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
parent 676f1f2d
......@@ -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
......@@ -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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment