This repository has been archived by the owner on Aug 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminate 'ghc.mk' from the 'sdist-ghc' rule
- Loading branch information
Showing
3 changed files
with
134 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,129 @@ | ||
module Rules.Sdist (sourceDistRules) where | ||
module Rules.Sdist (buildSourceDist, sourceDistRules) where | ||
|
||
import Base | ||
import Builder | ||
import Context | ||
import GHC | ||
import Oracles.Config.Setting | ||
import Oracles.ModuleFiles | ||
import Package | ||
import Rules.Actions | ||
import Settings | ||
import Stage | ||
|
||
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] | ||
tarName = "ghc-" ++ version ++ "-src.tar.xz" | ||
removeDirectory dest | ||
removeFile $ "sdistprep" -/- tarName | ||
need ["sdist-ghc-" ++ pkgNameString x | x <- packages] | ||
prepareTree dest | ||
runBuilderWith [Cwd "sdistprep/ghc"] Tar ["cJf", ".." -/- tarName, "ghc-" ++ version] | ||
putSuccess "| Done. " | ||
"GIT_COMMIT_ID" %> \fname -> | ||
setting ProjectGitCommitId >>= liftIO . writeFile fname | ||
"VERSION" %> \fname -> | ||
setting ProjectVersion >>= liftIO . writeFile fname | ||
where | ||
packages = [ compiler | ||
, genprimopcode | ||
, hpcBin ] | ||
|
||
|
||
buildSourceDist :: Context -> Rules () | ||
buildSourceDist context@(Context Stage1 pkg _) = do | ||
"sdist-ghc-" ++ pkgNameString pkg ~> do | ||
version <- setting ProjectVersion | ||
let dest = "sdistprep/ghc/ghc-" ++ version | ||
cpFile a = copyFile a (dest -/- a) | ||
srcs <- haskellSources context | ||
forM_ srcs $ \src -> when ("_build/" `isPrefixOf` src) $ do | ||
createDirectory $ dest <//> takeDirectory src | ||
cpFile src | ||
buildSourceDist (Context _ _ _) = return () | ||
|
||
|
||
prepareTree :: FilePath -> Action () | ||
prepareTree dest = do | ||
createDirectory dest | ||
mapM_ cpDir srcDirs | ||
mapM_ cpFile srcFiles | ||
where | ||
cpFile a = copyFile a (dest -/- a) | ||
cpDir a = copyDirectory' test a dest | ||
test a = return $ not $ any (?== a) exclude | ||
exclude = | ||
[ "//.*" | ||
, "//#*" | ||
, "//*-SAVE" | ||
, "//*.orig" | ||
, "//*.rej" | ||
, "//*~" | ||
, "//autom4te*" | ||
, "//log" | ||
, "compiler/stage1" | ||
, "compiler/stage2" | ||
, "compiler/stage3" | ||
, "hadrian/cabal.sandbox.config" | ||
, "hadrian/cfg/system.config" | ||
, "hadrian/dist" | ||
, "hadrian/UserSettings.hs" | ||
, "libraries//*.buildinfo" | ||
, "libraries//GNUmakefile" | ||
, "libraries//config.log" | ||
, "libraries//config.status" | ||
, "libraries//configure" | ||
, "libraries//ghc.mk" | ||
, "libraries//include/Hs*Config.h" | ||
-- In the legacy system the following libraries are excluded. | ||
-- But hadrian fails whithout them when compiling from the | ||
-- source tar ball. | ||
-- TDOD: Must we exclude these libraries? | ||
-- , "libraries/dph" | ||
-- , "libraries/parallel" | ||
-- , "libraries/primitive" | ||
-- , "libraries/random" | ||
-- , "libraries/stm" | ||
-- , "libraries/vector" | ||
, "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" ] |