[commit: ghc] master: Move Sphinx builder into the library (e6e95fc)
git at git.haskell.org
git at git.haskell.org
Tue Oct 23 20:10:48 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/e6e95fc2d8b157f35e4f8fddb5a9bebd5e2d6e28/ghc
>---------------------------------------------------------------
commit e6e95fc2d8b157f35e4f8fddb5a9bebd5e2d6e28
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date: Mon Oct 30 02:03:32 2017 +0000
Move Sphinx builder into the library
See #347
>---------------------------------------------------------------
e6e95fc2d8b157f35e4f8fddb5a9bebd5e2d6e28
hadrian.cabal | 2 +-
src/Builder.hs | 11 +----------
src/Hadrian/Builder/Sphinx.hs | 39 +++++++++++++++++++++++++++++++++++++++
src/Settings/Builders/Sphinx.hs | 22 ----------------------
src/Settings/Default.hs | 20 ++++++++++++--------
5 files changed, 53 insertions(+), 41 deletions(-)
diff --git a/hadrian.cabal b/hadrian.cabal
index 568b297..7bb249e 100644
--- a/hadrian.cabal
+++ b/hadrian.cabal
@@ -28,6 +28,7 @@ executable hadrian
, GHC
, Hadrian.Builder
, Hadrian.Builder.Ar
+ , Hadrian.Builder.Sphinx
, Hadrian.Builder.Tar
, Hadrian.Expression
, Hadrian.Haskell.Cabal
@@ -77,7 +78,6 @@ executable hadrian
, Settings.Builders.HsCpp
, Settings.Builders.Ld
, Settings.Builders.Make
- , Settings.Builders.Sphinx
, Settings.Builders.Xelatex
, Settings.Default
, Settings.Flavours.Development
diff --git a/src/Builder.hs b/src/Builder.hs
index 5545d06..2b99c03 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.Sphinx
import Hadrian.Builder.Tar
import Hadrian.Oracles.Path
import Hadrian.Oracles.TextFile
@@ -68,16 +69,6 @@ instance Binary HaddockMode
instance Hashable HaddockMode
instance NFData HaddockMode
--- | Sphinx can be used in three different modes:
--- * Convert RST to HTML
--- * Convert RST to LaTeX
--- * Convert RST to Man pages
-data SphinxMode = Html | Latex | Man deriving (Eq, Generic, Show)
-
-instance Binary SphinxMode
-instance Hashable SphinxMode
-instance NFData SphinxMode
-
-- | 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/Sphinx.hs b/src/Hadrian/Builder/Sphinx.hs
new file mode 100644
index 0000000..44b522c
--- /dev/null
+++ b/src/Hadrian/Builder/Sphinx.hs
@@ -0,0 +1,39 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : Hadrian.Builder.Sphinx
+-- Copyright : (c) Andrey Mokhov 2014-2017
+-- License : MIT (see the file LICENSE)
+-- Maintainer : andrey.mokhov at gmail.com
+-- Stability : experimental
+--
+-- Support for invoking the documentation utility Sphinx.
+-----------------------------------------------------------------------------
+module Hadrian.Builder.Sphinx (SphinxMode (..), args) where
+
+import Development.Shake
+import Development.Shake.Classes
+import GHC.Generics
+import Hadrian.Expression
+import Hadrian.Utilities
+
+-- | Sphinx can be used in three different modes to convert reStructuredText
+-- documents into HTML, LaTeX or Man pages.
+data SphinxMode = Html | Latex | Man deriving (Eq, Generic, Show)
+
+instance Binary SphinxMode
+instance Hashable SphinxMode
+instance NFData SphinxMode
+
+-- | Default command line arguments for invoking the archiving utility @tar at .
+args :: (ShakeValue c, ShakeValue b) => SphinxMode -> Args c b
+args mode = do
+ outPath <- getOutput
+ mconcat [ arg "-b", arg modeString
+ , arg "-d", arg $ outPath -/- (".doctrees-" ++ modeString)
+ , arg =<< getInput
+ , arg outPath ]
+ where
+ modeString = case mode of
+ Html -> "html"
+ Latex -> "latex"
+ Man -> "man"
diff --git a/src/Settings/Builders/Sphinx.hs b/src/Settings/Builders/Sphinx.hs
deleted file mode 100644
index 2338cfc..0000000
--- a/src/Settings/Builders/Sphinx.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module Settings.Builders.Sphinx (sphinxBuilderArgs) where
-
-import Settings.Builders.Common
-
-sphinxBuilderArgs :: Args
-sphinxBuilderArgs = do
- outPath <- getOutput
- mconcat [ builder (Sphinx Html) ? mconcat
- [ arg "-b", arg "html"
- , arg "-d", arg $ outPath -/- ".doctrees-html"
- , arg =<< getInput
- , arg outPath ]
- , builder (Sphinx Latex) ? mconcat
- [ arg "-b", arg "latex"
- , arg "-d", arg $ outPath -/- ".doctrees-latex"
- , arg =<< getInput
- , arg outPath ]
- , builder (Sphinx Man) ? mconcat
- [ arg "-b", arg "man"
- , arg "-d", arg $ outPath -/- ".doctrees-man"
- , arg =<< getInput
- , arg outPath ] ]
diff --git a/src/Settings/Default.hs b/src/Settings/Default.hs
index 18e0d43..cb42d66 100644
--- a/src/Settings/Default.hs
+++ b/src/Settings/Default.hs
@@ -6,6 +6,7 @@ module Settings.Default (
import qualified Hadrian.Builder.Ar
import qualified Hadrian.Builder.Tar
+import qualified Hadrian.Builder.Sphinx
import CommandLine
import Expression
@@ -28,7 +29,6 @@ import Settings.Builders.Hsc2Hs
import Settings.Builders.HsCpp
import Settings.Builders.Ld
import Settings.Builders.Make
-import Settings.Builders.Sphinx
import Settings.Builders.Xelatex
import Settings.Packages.Base
import Settings.Packages.Cabal
@@ -39,7 +39,7 @@ import Settings.Packages.Ghci
import Settings.Packages.GhcPkg
import Settings.Packages.GhcPrim
import Settings.Packages.Haddock
-import Settings.Packages.Haskeline (haskelinePackageArgs)
+import Settings.Packages.Haskeline
import Settings.Packages.IntegerGmp
import Settings.Packages.Rts
import Settings.Packages.RunGhc
@@ -140,9 +140,8 @@ defaultSplitObjects = do
-- | All 'Builder'-dependent command line arguments.
defaultBuilderArgs :: Args
defaultBuilderArgs = mconcat
+ -- GHC-specific builders:
[ alexBuilderArgs
- , builder (Ar Pack ) ? Hadrian.Builder.Ar.args Pack
- , builder (Ar Unpack) ? Hadrian.Builder.Ar.args Unpack
, ccBuilderArgs
, configureBuilderArgs
, deriveConstantsBuilderArgs
@@ -158,10 +157,15 @@ defaultBuilderArgs = mconcat
, hsCppBuilderArgs
, ldBuilderArgs
, makeBuilderArgs
- , sphinxBuilderArgs
- , builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
- , builder (Tar Extract) ? Hadrian.Builder.Tar.args Extract
- , xelatexBuilderArgs ]
+ , xelatexBuilderArgs
+ -- Generic builders from the Hadrian library:
+ , builder (Ar Pack ) ? Hadrian.Builder.Ar.args Pack
+ , builder (Ar Unpack ) ? Hadrian.Builder.Ar.args Unpack
+ , builder (Sphinx Html ) ? Hadrian.Builder.Sphinx.args Html
+ , builder (Sphinx Latex) ? Hadrian.Builder.Sphinx.args Latex
+ , builder (Sphinx Man ) ? Hadrian.Builder.Sphinx.args Man
+ , builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
+ , builder (Tar Extract ) ? Hadrian.Builder.Tar.args Extract ]
-- TODO: Disable warnings for Windows specifics.
-- TODO: Move this elsewhere?
More information about the ghc-commits
mailing list