[commit: ghc] master: Move Tar builder into the library (e04d207)

git at git.haskell.org git at git.haskell.org
Tue Oct 23 20:10:44 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/e04d2072d105e3ec6131e7d7b4fc7a0f6114f14b/ghc

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

commit e04d2072d105e3ec6131e7d7b4fc7a0f6114f14b
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sun Oct 29 22:21:56 2017 +0000

    Move Tar builder into the library
    
    See #347


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

e04d2072d105e3ec6131e7d7b4fc7a0f6114f14b
 hadrian.cabal                |  2 +-
 src/Builder.hs               |  8 +-------
 src/Hadrian/Builder/Tar.hs   | 40 ++++++++++++++++++++++++++++++++++++++++
 src/Settings/Builders/Tar.hs | 20 --------------------
 src/Settings/Default.hs      |  5 +++--
 5 files changed, 45 insertions(+), 30 deletions(-)

diff --git a/hadrian.cabal b/hadrian.cabal
index 54a0273..568b297 100644
--- a/hadrian.cabal
+++ b/hadrian.cabal
@@ -28,6 +28,7 @@ executable hadrian
                        , GHC
                        , Hadrian.Builder
                        , Hadrian.Builder.Ar
+                       , Hadrian.Builder.Tar
                        , Hadrian.Expression
                        , Hadrian.Haskell.Cabal
                        , Hadrian.Haskell.Cabal.Parse
@@ -77,7 +78,6 @@ executable hadrian
                        , Settings.Builders.Ld
                        , Settings.Builders.Make
                        , Settings.Builders.Sphinx
-                       , Settings.Builders.Tar
                        , Settings.Builders.Xelatex
                        , Settings.Default
                        , Settings.Flavours.Development
diff --git a/src/Builder.hs b/src/Builder.hs
index 8722609..5545d06 100644
--- a/src/Builder.hs
+++ b/src/Builder.hs
@@ -19,6 +19,7 @@ import GHC.Generics
 import qualified Hadrian.Builder as H
 import Hadrian.Builder hiding (Builder)
 import Hadrian.Builder.Ar
+import Hadrian.Builder.Tar
 import Hadrian.Oracles.Path
 import Hadrian.Oracles.TextFile
 import Hadrian.Utilities
@@ -77,13 +78,6 @@ instance Binary   SphinxMode
 instance Hashable SphinxMode
 instance NFData   SphinxMode
 
--- | Tar can be used to create an archive or extract from it.
-data TarMode = Create | Extract deriving (Eq, Generic, Show)
-
-instance Binary TarMode
-instance Hashable TarMode
-instance NFData TarMode
-
 -- | A 'Builder' is an external command invoked in a separate process via 'cmd'.
 -- @Ghc Stage0@ is the bootstrapping compiler.
 -- @Ghc StageN@, N > 0, is the one built in stage (N - 1).
diff --git a/src/Hadrian/Builder/Tar.hs b/src/Hadrian/Builder/Tar.hs
new file mode 100644
index 0000000..d51e3c7
--- /dev/null
+++ b/src/Hadrian/Builder/Tar.hs
@@ -0,0 +1,40 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module     : Hadrian.Builder.Tar
+-- Copyright  : (c) Andrey Mokhov 2014-2017
+-- License    : MIT (see the file LICENSE)
+-- Maintainer : andrey.mokhov at gmail.com
+-- Stability  : experimental
+--
+-- Support for invoking the archiving utility @tar at .
+-----------------------------------------------------------------------------
+module Hadrian.Builder.Tar (TarMode (..), args) where
+
+import Development.Shake
+import Development.Shake.Classes
+import GHC.Generics
+import Hadrian.Expression
+
+-- | Tar can be used to 'Create' an archive or 'Extract' from it.
+data TarMode = Create | Extract deriving (Eq, Generic, Show)
+
+instance Binary   TarMode
+instance Hashable TarMode
+instance NFData   TarMode
+
+-- | Default command line arguments for invoking the archiving utility @tar at .
+args :: (ShakeValue c, ShakeValue b) => TarMode -> Args c b
+args Create = mconcat
+    [ arg "-c"
+    , output "//*.gz"  ? arg "--gzip"
+    , output "//*.bz2" ? arg "--bzip2"
+    , output "//*.xz"  ? arg "--xz"
+    , arg "-f", arg =<< getOutput
+    , getInputs ]
+args Extract = mconcat
+    [ arg "-x"
+    , input "*.gz"  ? arg "--gzip"
+    , input "*.bz2" ? arg "--bzip2"
+    , input "*.xz"  ? arg "--xz"
+    , arg "-f", arg =<< getInput
+    , arg "-C", arg =<< getOutput ]
diff --git a/src/Settings/Builders/Tar.hs b/src/Settings/Builders/Tar.hs
deleted file mode 100644
index 4fb7d97..0000000
--- a/src/Settings/Builders/Tar.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Settings.Builders.Tar (tarBuilderArgs) where
-
-import Settings.Builders.Common
-
-tarBuilderArgs :: Args
-tarBuilderArgs =
-    mconcat [ builder (Tar Create) ? mconcat
-                [ arg "-c"
-                , output "//*.gz" ? arg "--gzip"
-                , output "//*.bz2" ? arg "--bzip2"
-                , output "//*.xz" ? arg "--xz"
-                , arg "-f", arg =<< getOutput
-                , getInputs ]
-            , builder (Tar Extract) ? mconcat
-                [ arg "-x"
-                , input "*.gz"  ? arg "--gzip"
-                , input "*.bz2" ? arg "--bzip2"
-                , input "*.xz" ? arg "--xz"
-                , arg "-f", arg =<< getInput
-                , arg "-C", arg =<< getOutput ] ]
diff --git a/src/Settings/Default.hs b/src/Settings/Default.hs
index cf0047f..18e0d43 100644
--- a/src/Settings/Default.hs
+++ b/src/Settings/Default.hs
@@ -5,6 +5,7 @@ module Settings.Default (
     ) where
 
 import qualified Hadrian.Builder.Ar
+import qualified Hadrian.Builder.Tar
 
 import CommandLine
 import Expression
@@ -28,7 +29,6 @@ import Settings.Builders.HsCpp
 import Settings.Builders.Ld
 import Settings.Builders.Make
 import Settings.Builders.Sphinx
-import Settings.Builders.Tar
 import Settings.Builders.Xelatex
 import Settings.Packages.Base
 import Settings.Packages.Cabal
@@ -159,7 +159,8 @@ defaultBuilderArgs = mconcat
     , ldBuilderArgs
     , makeBuilderArgs
     , sphinxBuilderArgs
-    , tarBuilderArgs
+    , builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
+    , builder (Tar Extract) ? Hadrian.Builder.Tar.args Extract
     , xelatexBuilderArgs ]
 
 -- TODO: Disable warnings for Windows specifics.



More information about the ghc-commits mailing list