[commit: ghc] wip/nfs-locking: Add rule 'sdist-ghc' (d4d9c03)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 01:12:15 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/d4d9c03de0be0762f973f106d2d4f4b2000d63f1/ghc

>---------------------------------------------------------------

commit d4d9c03de0be0762f973f106d2d4f4b2000d63f1
Author: Kai Harries <kai.harries at gmail.com>
Date:   Thu Jun 9 21:50:24 2016 +0200

    Add rule 'sdist-ghc'
    
    See #219


>---------------------------------------------------------------

d4d9c03de0be0762f973f106d2d4f4b2000d63f1
 hadrian.cabal           |   1 +
 src/Main.hs             |   2 +
 src/Rules/Clean.hs      |   1 +
 src/Rules/SourceDist.hs | 105 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 109 insertions(+)

diff --git a/hadrian.cabal b/hadrian.cabal
index 3b19557..4d6fbdf 100644
--- a/hadrian.cabal
+++ b/hadrian.cabal
@@ -64,6 +64,7 @@ executable hadrian
                        , Rules.Program
                        , Rules.Register
                        , Rules.Selftest
+                       , Rules.SourceDist
                        , Rules.Test
                        , Rules.Wrappers.Ghc
                        , Rules.Wrappers.GhcPkg
diff --git a/src/Main.hs b/src/Main.hs
index 66f897f..b4c2d42 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -7,6 +7,7 @@ import qualified Environment
 import qualified Rules
 import qualified Rules.Clean
 import qualified Rules.Oracles
+import qualified Rules.SourceDist
 import qualified Rules.Selftest
 import qualified Rules.Test
 import qualified Settings.Paths
@@ -23,6 +24,7 @@ main = shakeArgsWith options CmdLineFlag.cmdFlags $ \cmdLineFlags targets -> do
     rules = do
         Rules.Clean.cleanRules
         Rules.Oracles.oracleRules
+        Rules.SourceDist.sourceDistRules
         Rules.Selftest.selftestRules
         Rules.Test.testRules
         Rules.buildRules
diff --git a/src/Rules/Clean.hs b/src/Rules/Clean.hs
index 4678054..50edd20 100644
--- a/src/Rules/Clean.hs
+++ b/src/Rules/Clean.hs
@@ -16,6 +16,7 @@ cleanRules = do
         removeDirectory generatedPath
         removeDirectory programInplacePath
         removeDirectory "inplace/lib"
+        removeDirectory "sdistprep"
         putBuild $ "| Remove files generated by ghc-cabal..."
         forM_ knownPackages $ \pkg ->
             forM_ [Stage0 ..] $ \stage -> do
diff --git a/src/Rules/SourceDist.hs b/src/Rules/SourceDist.hs
new file mode 100644
index 0000000..a2cc8f4
--- /dev/null
+++ b/src/Rules/SourceDist.hs
@@ -0,0 +1,105 @@
+module Rules.SourceDist (sourceDistRules) where
+
+import Base
+import Builder
+import Oracles.Config.Setting
+import Oracles.DirectoryContent
+import Rules.Actions
+import UserSettings
+
+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 "//dist"
+      , Test "//log"
+      , Test "//stage0"
+      , Test "//stage1"
+      , Test "//stage2"
+      , Test "//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" ]



More information about the ghc-commits mailing list