summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-13 12:59:58 -0400
committerBen Gamari <ben@smart-cactus.org>2019-10-14 21:10:24 -0400
commit0f92773d8dafc7b7cca7f4fc6adca6cd80afeb8b (patch)
treeab83840f34414372b74d088f0d8ac72666341cca
parentd584e3f08cfee6e28b70bf53c573d86e44f326f8 (diff)
downloadhaskell-wip/hadrian-compressors.tar.gz
hadrian: Add support for bindist compressors other than Xzwip/hadrian-compressors
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]