summaryrefslogtreecommitdiff
path: root/hadrian/src/CommandLine.hs
diff options
context:
space:
mode:
authorAlp Mestanogullari <alpmestan@gmail.com>2019-02-27 17:23:48 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-03-01 16:38:15 -0500
commit8442103aa575dc1cd25cb3231e729c6365dc1b5c (patch)
tree534ea2e212270c21a25f29582dba88290a9981d1 /hadrian/src/CommandLine.hs
parentf37efb11b957a21f3048f7005a234f96350ff938 (diff)
downloadhaskell-8442103aa575dc1cd25cb3231e729c6365dc1b5c.tar.gz
Hadrian: introduce ways to skip some documentation targets
The initial motivation for this is to have a chance to run the binary distribution rules in our Windows CI without having to install sphinx-build and xelatex there, while retaining the ability to generate haddocks. I just ended up extending this idea a little bit so as to have control over whether we build haddocks, (sphinx) HTML manuals, (sphinx) PDF manuals and (sphinx) manpages.
Diffstat (limited to 'hadrian/src/CommandLine.hs')
-rw-r--r--hadrian/src/CommandLine.hs35
1 files changed, 32 insertions, 3 deletions
diff --git a/hadrian/src/CommandLine.hs b/hadrian/src/CommandLine.hs
index 1f940f2152..842fb037cc 100644
--- a/hadrian/src/CommandLine.hs
+++ b/hadrian/src/CommandLine.hs
@@ -1,17 +1,20 @@
module CommandLine (
optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, cmdIntegerSimple,
cmdProgressColour, cmdProgressInfo, cmdConfigure, cmdSplitObjects,
- lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs
+ cmdDocsArgs, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs
) where
import Data.Either
import qualified Data.HashMap.Strict as Map
import Data.List.Extra
import Development.Shake hiding (Normal)
+import Flavour (DocTargets, DocTarget(..))
import Hadrian.Utilities hiding (buildRoot)
import System.Console.GetOpt
import System.Environment
+import qualified Data.Set as Set
+
data TestSpeed = Slow | Average | Fast deriving (Show, Eq)
-- | All arguments that can be passed to Hadrian via the command line.
@@ -24,7 +27,8 @@ data CommandLineArgs = CommandLineArgs
, progressInfo :: ProgressInfo
, splitObjects :: Bool
, buildRoot :: BuildRoot
- , testArgs :: TestArgs }
+ , testArgs :: TestArgs
+ , docTargets :: DocTargets }
deriving (Eq, Show)
-- | Default values for 'CommandLineArgs'.
@@ -38,7 +42,8 @@ defaultCommandLineArgs = CommandLineArgs
, progressInfo = Brief
, splitObjects = False
, buildRoot = BuildRoot "_build"
- , testArgs = defaultTestArgs }
+ , testArgs = defaultTestArgs
+ , docTargets = Set.fromList [minBound..maxBound] }
-- | These arguments are used by the `test` target.
data TestArgs = TestArgs
@@ -179,6 +184,25 @@ readTestWay way =
let newWays = way : testWays (testArgs flags)
in flags { testArgs = (testArgs flags) {testWays = newWays} }
+readDocsArg :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
+readDocsArg ms = maybe (Left "Cannot parse docs argument") (Right . set) (go =<< ms)
+
+ where
+ go :: String -> Maybe (DocTargets -> DocTargets)
+ go "none" = Just (const Set.empty)
+ go "no-haddocks" = Just (Set.delete Haddocks)
+ go "no-sphinx-html" = Just (Set.delete SphinxHTML)
+ go "no-sphinx-pdfs" = Just (Set.delete SphinxPDFs)
+ go "no-sphinx-man" = Just (Set.delete SphinxMan)
+ go "no-sphinx" = Just (Set.delete SphinxHTML
+ . Set.delete SphinxPDFs
+ . Set.delete SphinxMan)
+ go _ = Nothing
+
+ set :: (DocTargets -> DocTargets) -> CommandLineArgs -> CommandLineArgs
+ set tweakTargets flags = flags
+ { docTargets = tweakTargets (docTargets flags) }
+
-- | Standard 'OptDescr' descriptions of Hadrian's command line arguments.
optDescrs :: [OptDescr (Either String (CommandLineArgs -> CommandLineArgs))]
optDescrs =
@@ -198,6 +222,8 @@ optDescrs =
"Progress info style (None, Brief, Normal or Unicorn)."
, Option [] ["split-objects"] (NoArg readSplitObjects)
"Generate split objects (requires a full clean rebuild)."
+ , Option [] ["docs"] (OptArg readDocsArg "TARGET")
+ "Strip down docs targets (none, no-haddocks, no-sphinx[-{html, pdfs, man}]."
, Option [] ["test-compiler"] (OptArg readTestCompiler "TEST_COMPILER")
"Use given compiler [Default=stage2]."
, Option [] ["test-config-file"] (OptArg readTestConfigFile "CONFIG_FILE")
@@ -259,3 +285,6 @@ cmdProgressInfo = progressInfo <$> cmdLineArgs
cmdSplitObjects :: Action Bool
cmdSplitObjects = splitObjects <$> cmdLineArgs
+
+cmdDocsArgs :: Action DocTargets
+cmdDocsArgs = docTargets <$> cmdLineArgs