Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
Add rule 'sdist-ghc'
Browse files Browse the repository at this point in the history
See #219
  • Loading branch information
KaiHa committed Jun 10, 2016
1 parent 920e7bb commit 7f167ab
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
1 change: 1 addition & 0 deletions hadrian.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,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
10 changes: 7 additions & 3 deletions src/Rules/Actions.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Rules.Actions (
build, buildWithCmdOptions, buildWithResources, copyFile, fixFile, moveFile,
removeFile, copyDirectory, createDirectory, moveDirectory, removeDirectory,
applyPatch, runBuilder, makeExecutable, renderProgram, renderLibrary
applyPatch, runBuilder, runBuilderWith, makeExecutable, renderProgram, renderLibrary
) where

import qualified System.Directory as IO
Expand Down Expand Up @@ -152,12 +152,16 @@ applyPatch dir patch = do
quietly $ cmd Shell cmdEcho [Cwd dir] [path, "-p0 <", patch]

runBuilder :: Builder -> [String] -> Action ()
runBuilder builder args = do
runBuilder =
runBuilderWith []

runBuilderWith :: [CmdOption] -> Builder -> [String] -> Action ()
runBuilderWith options builder args = do
needBuilder builder
path <- builderPath builder
let note = if null args then "" else " (" ++ intercalate ", " args ++ ")"
putBuild $ "| Run " ++ show builder ++ note
quietly $ cmd [path] args
quietly $ cmd options [path] args

makeExecutable :: FilePath -> Action ()
makeExecutable file = do
Expand Down
35 changes: 35 additions & 0 deletions src/Rules/Sdist.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Rules.Sdist (sourceDistRules) where

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

sourceDistRules :: Rules ()
sourceDistRules = do
"sdist-ghc" ~> do
version <- setting ProjectVersion
let dest = "sdistprep/ghc/ghc-" ++ version
tarName = "../ghc-" ++ version ++ "-src.tar.xz"
cpFile a = copyFile ("hadrian" -/- a) (dest -/- "hadrian" -/- a)
cpDir a = copyDirectory ("hadrian" -/- a) (dest -/- "hadrian")
runBuilder (Make ".") [ "--no-print-directory", "-f", "ghc.mk"
, "sdist-ghc-prep", "NO_INCLUDE_DEPS=YES"
, "NO_INCLUDE_PKGDATA=YES"]
createDirectory $ dest -/- "hadrian"
cpDir "cfg"
cpDir "doc"
cpDir "src"
cpFile "LICENSE"
cpFile "Makefile"
cpFile "README.md"
cpFile "appveyor.yml"
cpFile "build.bat"
cpFile "build.cabal.sh"
cpFile "build.sh"
cpFile "build.stack.sh"
cpFile "hadrian.cabal"
cpFile "stack.yaml"
runBuilderWith [Cwd "sdistprep/ghc"] Tar ["cJf", tarName, "ghc-" ++ version]
putSuccess "| Done. "

0 comments on commit 7f167ab

Please sign in to comment.