diff options
author | HĂ©cate <hecate+gitlab@glitchbra.in> | 2021-01-12 21:00:48 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-22 18:26:55 -0500 |
commit | ece202297454862717cef8c06d445f8405845b28 (patch) | |
tree | cdcd16d19eae96ad5db0c9828430b8ee0341d58a /hadrian | |
parent | 22ef7ab10097f92a71369ea99f2f24deea6be080 (diff) | |
download | haskell-ece202297454862717cef8c06d445f8405845b28.tar.gz |
Add the docspec:base rule to Hadrian
Diffstat (limited to 'hadrian')
-rw-r--r-- | hadrian/hadrian.cabal | 1 | ||||
-rw-r--r-- | hadrian/src/Main.hs | 2 | ||||
-rw-r--r-- | hadrian/src/Rules/Docspec.hs | 57 |
3 files changed, 60 insertions, 0 deletions
diff --git a/hadrian/hadrian.cabal b/hadrian/hadrian.cabal index 3bca30ff23..0b54bed039 100644 --- a/hadrian/hadrian.cabal +++ b/hadrian/hadrian.cabal @@ -68,6 +68,7 @@ executable hadrian , Rules.Compile , Rules.Configure , Rules.Dependencies + , Rules.Docspec , Rules.Documentation , Rules.Generate , Rules.Gmp diff --git a/hadrian/src/Main.hs b/hadrian/src/Main.hs index d75bc743a7..db808f5a57 100644 --- a/hadrian/src/Main.hs +++ b/hadrian/src/Main.hs @@ -11,6 +11,7 @@ import qualified CommandLine import qualified Environment import qualified Rules import qualified Rules.Clean +import qualified Rules.Docspec import qualified Rules.Documentation import qualified Rules.Lint import qualified Rules.Nofib @@ -83,6 +84,7 @@ main = do rules :: Rules () rules = do Rules.buildRules + Rules.Docspec.docspecRules Rules.Documentation.documentationRules Rules.Clean.cleanRules Rules.Lint.lintRules diff --git a/hadrian/src/Rules/Docspec.hs b/hadrian/src/Rules/Docspec.hs new file mode 100644 index 0000000000..e5f8eb66c4 --- /dev/null +++ b/hadrian/src/Rules/Docspec.hs @@ -0,0 +1,57 @@ +module Rules.Docspec + ( docspecRules + ) where + +import System.Directory (findExecutable) + +import Base +import Context.Path +import Settings.Builders.Common +import qualified Packages as P + +docspecRules :: Rules () +docspecRules = do + "docspec:base" ~> docspec base + +docspec :: Action () -> Action () +docspec lintAction = do + isExecutablePresent <- isJust <$> liftIO (findExecutable "cabal-docspec") + if isExecutablePresent + then do + putBuild "| Running cabal-docspec…" + lintAction + putSuccess "| Done." + else + putFailure "| Please make sure you have the `cabal-docspec` executable in your $PATH" + +base :: Action () +base = do + topDir <- topDirectory + let context = vanillaContext Stage1 P.base + stage1GHCPath <- P.programPath (vanillaContext Stage1 P.ghc) + let stage1GHC = topDir </> stage1GHCPath + stage1Lib <- stageLibPath Stage1 + let cabalFile = pkgCabalFile P.base + let topIncludes = topDir </> "includes" + includeDeps' <- includesDependencies Stage1 + buildPath' <- buildPath context + let buildIncludesPath = topDir </> buildPath' </> "include" + let includeDeps = fmap (topDir </>) includeDeps' + mtlConfFile <- pkgConfFile $ vanillaContext Stage1 P.mtl + deepseqConfFile <- pkgConfFile $ vanillaContext Stage1 P.deepseq + bytestringConfFile <- pkgConfFile $ vanillaContext Stage1 P.bytestring + let neededIncludes = includeDeps ++ [mtlConfFile, deepseqConfFile, bytestringConfFile] + need neededIncludes + + command_ [] "cabal-docspec" [ "-w", stage1GHC + , "--no-cabal-plan" + , "--strip-comments" + , "--timeout", "2" + , "--ghci-rtsopts=-K500K" + , "--extra-package=mtl", "--extra-package=deepseq", "--extra-package=bytestring" + , "-XNoImplicitPrelude" + , "-I", topIncludes + , "-I", buildIncludesPath + , "-I", stage1Lib + , cabalFile + ] |