SourceDist.hs 3.31 KB
Newer Older
kaiha's avatar
kaiha committed
1 2
module Rules.SourceDist (sourceDistRules) where

3 4
import Hadrian.Oracles.DirectoryContents

kaiha's avatar
kaiha committed
5
import Base
6
import Builder
7
import Oracles.Setting
8
import Rules.Clean
kaiha's avatar
kaiha committed
9 10 11

sourceDistRules :: Rules ()
sourceDistRules = do
12
    "source-dist" ~> do
13 14
        -- We clean the source tree first.
        -- See https://github.com/snowleopard/hadrian/issues/384.
Andrey Mokhov's avatar
Andrey Mokhov committed
15 16
        -- TODO: Do we still need to clean the tree?
        cleanSourceTree
kaiha's avatar
kaiha committed
17 18
        version <- setting ProjectVersion
        need ["sdistprep/ghc-" ++ version ++ "-src.tar.xz"]
19
        putSuccess "| Done"
kaiha's avatar
kaiha committed
20
    "sdistprep/ghc-*-src.tar.xz" %> \fname -> do
21 22 23
        let tarName   = takeFileName fname
            dropTarXz = dropExtension . dropExtension
            treePath  = "sdistprep/ghc" -/- dropTarXz tarName
kaiha's avatar
kaiha committed
24
        prepareTree treePath
25
        runBuilderWithCmdOptions [Cwd "sdistprep/ghc"] (Tar Create)
26 27
            ["cJf", ".." -/- tarName,  dropTarXz tarName]
            ["cJf", ".." -/- tarName] [dropTarXz tarName]
kaiha's avatar
kaiha committed
28
    "GIT_COMMIT_ID" %> \fname ->
29
        writeFileChanged fname =<< setting ProjectGitCommitId
kaiha's avatar
kaiha committed
30
    "VERSION" %> \fname ->
31
        writeFileChanged fname =<< setting ProjectVersion
kaiha's avatar
kaiha committed
32 33 34 35 36 37

prepareTree :: FilePath -> Action ()
prepareTree dest = do
    mapM_ cpDir  srcDirs
    mapM_ cpFile srcFiles
  where
Andrey Mokhov's avatar
Andrey Mokhov committed
38
    cpFile a = copyFile a (dest -/- a)
39
    cpDir  a = copyDirectoryContents (Not excluded) a (dest -/- a)
kaiha's avatar
kaiha committed
40
    excluded = Or
41 42 43 44 45 46 47 48
        [ Test "//.*"
        , Test "//#*"
        , Test "//*-SAVE"
        , Test "//*.orig"
        , Test "//*.rej"
        , Test "//*~"
        , Test "//autom4te*"
        , Test "//dist"
49
        , Test "//dist-install"
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
        , Test "//log"
        , Test "//stage0"
        , Test "//stage1"
        , Test "//stage2"
        , Test "//stage3"
        , Test "hadrian/.cabal-sandbox"
        , Test "hadrian/.stack-work"
        , Test "hadrian/UserSettings.hs"
        , Test "hadrian/cabal.sandbox.config"
        , Test "hadrian/cfg/system.config"
        , Test "hadrian/bin"
        , Test "hadrian/dist"
        , Test "hadrian/dist-newstyle"
        , 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"
76
        , Test "rts/rts.cabal"
77
        , Test "mk/build.mk" ]
kaiha's avatar
kaiha committed
78
    srcDirs =
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
        [ "bindisttest"
        , "compiler"
        , "distrib"
        , "docs"
        , "docs"
        , "driver"
        , "ghc"
        , "hadrian"
        , "includes"
        , "iserv"
        , "libffi"
        , "libffi-tarballs"
        , "libraries"
        , "mk"
        , "rts"
        , "rules"
        , "utils" ]
kaiha's avatar
kaiha committed
96
    srcFiles =
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
        [ "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" ]