Commit e04d2072 authored by Andrey Mokhov's avatar Andrey Mokhov

Move Tar builder into the library

See #347
parent f4bbf315
......@@ -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
......
......@@ -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).
......
-----------------------------------------------------------------------------
-- |
-- Module : Hadrian.Builder.Tar
-- Copyright : (c) Andrey Mokhov 2014-2017
-- License : MIT (see the file LICENSE)
-- Maintainer : andrey.mokhov@gmail.com
-- Stability : experimental
--
-- Support for invoking the archiving utility @tar@.
-----------------------------------------------------------------------------
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@.
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 ]
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 ] ]
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment