diff --git a/hadrian.cabal b/hadrian.cabal index 3b1955718d..4d6fbdf7d7 100644 --- a/hadrian.cabal +++ b/hadrian.cabal @@ -64,6 +64,7 @@ executable hadrian , Rules.Program , Rules.Register , Rules.Selftest + , Rules.SourceDist , Rules.Test , Rules.Wrappers.Ghc , Rules.Wrappers.GhcPkg diff --git a/src/Main.hs b/src/Main.hs index 66f897f5a5..b4c2d42df1 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -7,6 +7,7 @@ import qualified Environment import qualified Rules import qualified Rules.Clean import qualified Rules.Oracles +import qualified Rules.SourceDist import qualified Rules.Selftest import qualified Rules.Test import qualified Settings.Paths @@ -23,6 +24,7 @@ main = shakeArgsWith options CmdLineFlag.cmdFlags $ \cmdLineFlags targets -> do rules = do Rules.Clean.cleanRules Rules.Oracles.oracleRules + Rules.SourceDist.sourceDistRules Rules.Selftest.selftestRules Rules.Test.testRules Rules.buildRules diff --git a/src/Rules/Clean.hs b/src/Rules/Clean.hs index 4678054376..50edd20c62 100644 --- a/src/Rules/Clean.hs +++ b/src/Rules/Clean.hs @@ -16,6 +16,7 @@ cleanRules = do removeDirectory generatedPath removeDirectory programInplacePath removeDirectory "inplace/lib" + removeDirectory "sdistprep" putBuild $ "| Remove files generated by ghc-cabal..." forM_ knownPackages $ \pkg -> forM_ [Stage0 ..] $ \stage -> do diff --git a/src/Rules/SourceDist.hs b/src/Rules/SourceDist.hs new file mode 100644 index 0000000000..93b8199b11 --- /dev/null +++ b/src/Rules/SourceDist.hs @@ -0,0 +1,103 @@ +module Rules.SourceDist (sourceDistRules) where + +import Base +import Builder +import Oracles.Config.Setting +import Oracles.DirectoryContent +import Rules.Actions +import UserSettings + +sourceDistRules :: Rules () +sourceDistRules = do + "sdist-ghc" ~> do + version <- setting ProjectVersion + need ["sdistprep/ghc-" ++ version ++ "-src.tar.xz"] + putSuccess "| Done. " + "sdistprep/ghc-*-src.tar.xz" %> \fname -> do + let tarName = takeFileName fname + treePath = "sdistprep/ghc" dropTarXz tarName + prepareTree treePath + runBuilderWith [Cwd "sdistprep/ghc"] Tar ["cJf", ".." tarName, dropTarXz tarName] + "GIT_COMMIT_ID" %> \fname -> + setting ProjectGitCommitId >>= writeFileChanged fname + "VERSION" %> \fname -> + setting ProjectVersion >>= writeFileChanged fname + where + dropTarXz = dropExtension . dropExtension + + +prepareTree :: FilePath -> Action () +prepareTree dest = do + mapM_ cpDir srcDirs + mapM_ cpFile srcFiles + where + cpFile a = copyFile a (dest a) + cpDir a = copyDirectoryContent (Not excluded) a (dest takeFileName a) + excluded = Or + [ Test "//.*" + , Test "//#*" + , Test "//*-SAVE" + , Test "//*.orig" + , Test "//*.rej" + , Test "//*~" + , Test "//autom4te*" + , Test "//log" + , Test "compiler/stage1" + , Test "compiler/stage2" + , Test "compiler/stage3" + , Test "hadrian/cabal.sandbox.config" + , Test "hadrian/cfg/system.config" + , Test "hadrian/dist" + , Test "hadrian/UserSettings.hs" + , Test "libraries//*.buildinfo" + , Test "libraries//GNUmakefile" + , Test "libraries//config.log" + , Test "libraries//config.status" + , Test "libraries//configure" + , Test "libraries//ghc.mk" + , Test "libraries//include/Hs*Config.h" + , Test "libraries/dph" + , Test "libraries/parallel" + , Test "libraries/primitive" + , Test "libraries/random" + , Test "libraries/stm" + , Test "libraries/vector" + , Test "mk/build.mk" ] + srcDirs = + [ "bindisttest" + , "compiler" + , "distrib" + , "docs" + , "docs" + , "driver" + , "ghc" + , "hadrian" + , "includes" + , "iserv" + , "libffi" + , "libffi-tarballs" + , "libraries" + , "mk" + , "rts" + , "rules" + , "utils" ] + srcFiles = + [ "ANNOUNCE" + , "GIT_COMMIT_ID" + , "HACKING.md" + , "INSTALL.md" + , "LICENSE" + , "MAKEHELP.md" + , "Makefile" + , "README.md" + , "VERSION" + , "aclocal.m4" + , "boot" + , "config.guess" + , "config.sub" + , "configure" + , "configure.ac" + , "ghc.mk" + , "install-sh" + , "packages" + , "settings.in" ]