From 0f92773d8dafc7b7cca7f4fc6adca6cd80afeb8b Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sun, 13 Oct 2019 12:59:58 -0400 Subject: hadrian: Add support for bindist compressors other than Xz Fixes #17351. --- hadrian/src/Rules/BinaryDist.hs | 42 ++++++++++++++++++++++++++++++----------- 1 file 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 /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 /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 /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] -- cgit v1.2.1