Skip to content

Commit

Permalink
Add rule 'sdist-ghc'
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiHa committed Jul 5, 2016
1 parent df3ad6d commit b89ea6d
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions hadrian.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ executable hadrian
, Rules.Program
, Rules.Register
, Rules.Selftest
, Rules.Sdist
, Rules.Test
, Rules.Wrappers.Ghc
, Rules.Wrappers.GhcPkg
Expand Down
2 changes: 2 additions & 0 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import qualified Environment
import qualified Rules
import qualified Rules.Clean
import qualified Rules.Oracles
import qualified Rules.Sdist
import qualified Rules.Selftest
import qualified Rules.Test
import qualified Settings.Paths
Expand All @@ -23,6 +24,7 @@ main = shakeArgsWith options CmdLineFlag.cmdFlags $ \cmdLineFlags targets -> do
rules = do
Rules.Clean.cleanRules
Rules.Oracles.oracleRules
Rules.Sdist.sourceDistRules
Rules.Selftest.selftestRules
Rules.Test.testRules
Rules.buildRules
Expand Down
1 change: 1 addition & 0 deletions src/Rules/Clean.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cleanRules = do
forM_ [Stage0 ..] $ removeDirectory . (buildRootPath -/-) . stageString
removeDirectory programInplacePath
removeDirectory "inplace/lib"
removeDirectory "sdistprep"
removeDirectory derivedConstantsPath
forM_ includesDependencies removeFile
putBuild $ "| Remove files generated by ghc-cabal..."
Expand Down
103 changes: 103 additions & 0 deletions src/Rules/Sdist.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
module Rules.Sdist (sourceDistRules) where

import Base
import Builder
import Oracles.Config.Setting
import Oracles.DirectoryContent
import Rules.Actions
import Settings

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" ]

0 comments on commit b89ea6d

Please sign in to comment.