diff options
Diffstat (limited to 'hadrian/src/CommandLine.hs')
-rw-r--r-- | hadrian/src/CommandLine.hs | 35 |
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 |