Occurrrence analysis improvements for NOINLINE functions
[ghc.git] / hadrian / src / Rules / SourceDist.hs
1 module Rules.SourceDist (sourceDistRules) where
2
3 import Hadrian.Oracles.DirectoryContents
4
5 import Base
6 import Builder
7 import Oracles.Setting
8 import Rules.Clean
9
10 sourceDistRules :: Rules ()
11 sourceDistRules = do
12 "sdist-ghc" ~> do
13 -- We clean the source tree first.
14 -- See https://github.com/snowleopard/hadrian/issues/384.
15 cleanSourceTree
16 version <- setting ProjectVersion
17 need ["sdistprep/ghc-" ++ version ++ "-src.tar.xz"]
18 putSuccess "| Done"
19 "sdistprep/ghc-*-src.tar.xz" %> \fname -> do
20 let tarName = takeFileName fname
21 dropTarXz = dropExtension . dropExtension
22 treePath = "sdistprep/ghc" -/- dropTarXz tarName
23 prepareTree treePath
24 runBuilderWithCmdOptions [Cwd "sdistprep/ghc"] (Tar Create)
25 ["cJf", ".." -/- tarName, dropTarXz tarName]
26 ["cJf", ".." -/- tarName] [dropTarXz tarName]
27 "GIT_COMMIT_ID" %> \fname ->
28 writeFileChanged fname =<< setting ProjectGitCommitId
29 "VERSION" %> \fname ->
30 writeFileChanged fname =<< setting ProjectVersion
31
32 prepareTree :: FilePath -> Action ()
33 prepareTree dest = do
34 mapM_ cpDir srcDirs
35 mapM_ cpFile srcFiles
36 where
37 cpFile a = copyFile a (dest -/- a)
38 cpDir a = copyDirectoryContents (Not excluded) a (dest -/- a)
39 excluded = Or
40 [ Test "//.*"
41 , Test "//#*"
42 , Test "//*-SAVE"
43 , Test "//*.orig"
44 , Test "//*.rej"
45 , Test "//*~"
46 , Test "//autom4te*"
47 , Test "//dist"
48 , Test "//dist-install"
49 , Test "//log"
50 , Test "//stage0"
51 , Test "//stage1"
52 , Test "//stage2"
53 , Test "//stage3"
54 , Test "hadrian/.cabal-sandbox"
55 , Test "hadrian/.stack-work"
56 , Test "hadrian/UserSettings.hs"
57 , Test "hadrian/cabal.sandbox.config"
58 , Test "hadrian/cfg/system.config"
59 , Test "hadrian/bin"
60 , Test "hadrian/dist"
61 , Test "hadrian/dist-newstyle"
62 , Test "libraries//*.buildinfo"
63 , Test "libraries//GNUmakefile"
64 , Test "libraries//config.log"
65 , Test "libraries//config.status"
66 , Test "libraries//configure"
67 , Test "libraries//ghc.mk"
68 , Test "libraries//include/Hs*Config.h"
69 , Test "libraries/dph"
70 , Test "libraries/parallel"
71 , Test "libraries/primitive"
72 , Test "libraries/random"
73 , Test "libraries/stm"
74 , Test "libraries/vector"
75 , Test "mk/build.mk" ]
76 srcDirs =
77 [ "bindisttest"
78 , "compiler"
79 , "distrib"
80 , "docs"
81 , "docs"
82 , "driver"
83 , "ghc"
84 , "hadrian"
85 , "includes"
86 , "iserv"
87 , "libffi"
88 , "libffi-tarballs"
89 , "libraries"
90 , "mk"
91 , "rts"
92 , "rules"
93 , "utils" ]
94 srcFiles =
95 [ "ANNOUNCE"
96 , "GIT_COMMIT_ID"
97 , "HACKING.md"
98 , "INSTALL.md"
99 , "LICENSE"
100 , "MAKEHELP.md"
101 , "Makefile"
102 , "README.md"
103 , "VERSION"
104 , "aclocal.m4"
105 , "boot"
106 , "config.guess"
107 , "config.sub"
108 , "configure"
109 , "configure.ac"
110 , "ghc.mk"
111 , "install-sh"
112 , "packages"
113 , "settings.in" ]