summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-13 12:59:58 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-15 18:41:54 -0400
commit9c11f8171a9aebec4b4d19e5eac4140f40c28542 (patch)
tree9404072e09fb8b920f026a5763673c84fe4abed4
parenta55b8a65e3975c1227a78ab50e1db141adc294e8 (diff)
downloadhaskell-9c11f8171a9aebec4b4d19e5eac4140f40c28542.tar.gz
hadrian: Add support for bindist compressors other than Xz
Fixes #17351.
-rw-r--r--hadrian/src/Rules/BinaryDist.hs42
1 files changed, 31 insertions, 11 deletions
diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs
index fb7fa47c84..42efb95420 100644
--- a/hadrian/src/Rules/BinaryDist.hs
+++ b/hadrian/src/Rules/BinaryDist.hs
@@ -152,21 +152,26 @@ bindistRules = do
, "runghc"]
- phony "binary-dist" $ do
+ let buildBinDist :: Compressor -> Action ()
+ buildBinDist compressor = do
+ need ["binary-dist-dir"]
- need ["binary-dist-dir"]
+ version <- setting ProjectVersion
+ targetPlatform <- setting TargetPlatformFull
- version <- setting ProjectVersion
- targetPlatform <- setting TargetPlatformFull
+ let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform
- let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform
+ -- Finally, we create the archive <root>/bindist/ghc-X.Y.Z-platform.tar.xz
+ tarPath <- builderPath (Tar Create)
+ cmd [Cwd $ root -/- "bindist"] tarPath
+ [ "-c", compressorTarFlag compressor, "-f"
+ , ghcVersionPretty <.> "tar" <.> compressorExtension compressor
+ , ghcVersionPretty ]
- -- Finally, we create the archive <root>/bindist/ghc-X.Y.Z-platform.tar.xz
- tarPath <- builderPath (Tar Create)
- cmd [Cwd $ root -/- "bindist"] tarPath
- [ "-c", "--xz", "-f"
- , ghcVersionPretty <.> "tar.xz"
- , ghcVersionPretty ]
+ phony "binary-dist" $ buildBinDist Xz
+ phony "binary-dist-gzip" $ buildBinDist Gzip
+ phony "binary-dist-bzip2" $ buildBinDist Bzip2
+ phony "binary-dist-xz" $ buildBinDist Xz
-- Prepare binary distribution configure script
-- (generated under <ghc root>/distrib/configure by 'autoreconf')
@@ -201,6 +206,21 @@ bindistRules = do
fixup f | f `elem` ["INSTALL", "README"] = "distrib" -/- f
| otherwise = f
+data Compressor = Gzip | Bzip2 | Xz
+ deriving (Eq, Ord, Show)
+
+-- | Flag to pass to tar to use the given 'Compressor'.
+compressorTarFlag :: Compressor -> String
+compressorTarFlag Gzip = "--gzip"
+compressorTarFlag Xz = "--xz"
+compressorTarFlag Bzip2 = "--bzip"
+
+-- | File extension to use for archives compressed with the given 'Compressor'.
+compressorExtension :: Compressor -> String
+compressorExtension Gzip = "gz"
+compressorExtension Xz = "xz"
+compressorExtension Bzip2 = "bz2"
+
-- | A list of files that allow us to support a simple
-- @./configure [...] && make install@ workflow.
bindistInstallFiles :: [FilePath]