-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build haddocks for dependencies (#143) #362
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import Data.Map.Strict (Map) | |
import qualified Data.Map.Strict as M | ||
import qualified Data.Map.Strict as Map | ||
import Data.Maybe | ||
import Data.Set (Set) | ||
import qualified Data.Set as Set | ||
import Data.Streaming.Process hiding (callProcess, env) | ||
import qualified Data.Streaming.Process as Process | ||
|
@@ -115,7 +116,6 @@ printPlan finalAction plan = do | |
DoNothing -> Nothing | ||
DoBenchmarks -> Just "benchmark" | ||
DoTests -> Just "test" | ||
DoHaddock -> Just "haddock" | ||
case mfinalLabel of | ||
Nothing -> return () | ||
Just finalLabel -> do | ||
|
@@ -174,6 +174,7 @@ data ExecuteEnv = ExecuteEnv | |
, eeSetupHs :: !(Path Abs File) | ||
, eeCabalPkgVer :: !Version | ||
, eeTotalWanted :: !Int | ||
, eeWanted :: !(Set PackageName) | ||
} | ||
|
||
-- | Perform the actual plan | ||
|
@@ -208,6 +209,7 @@ executePlan menv bopts baseConfigOpts locals plan = do | |
, eeSetupHs = setupHs | ||
, eeCabalPkgVer = cabalPkgVer | ||
, eeTotalWanted = length $ filter lpWanted locals | ||
, eeWanted = wantedLocalPackages locals | ||
} | ||
|
||
unless (Map.null $ planInstallExes plan) $ do | ||
|
@@ -372,7 +374,6 @@ toActions runInBase ee (mbuild, mfinal) = | |
DoNothing -> Nothing | ||
DoTests -> Just (singleTest, checkTest) | ||
DoBenchmarks -> Just (singleBench, checkBench) | ||
DoHaddock -> Just (singleHaddock, const True) | ||
|
||
checkTest task = | ||
case taskType task of | ||
|
@@ -419,6 +420,8 @@ ensureConfig pkgDir ExecuteEnv {..} Task {..} announce cabal cabalfp extra = do | |
case taskType of | ||
TTLocal lp -> Set.map encodeUtf8 $ lpComponents lp | ||
TTUpstream _ _ -> Set.empty | ||
, configCacheHaddock = | ||
shouldBuildHaddock eeBuildOpts eeWanted (packageIdentifierName taskProvides) | ||
} | ||
|
||
let needConfig = mOldConfigCache /= Just newConfigCache | ||
|
@@ -593,6 +596,16 @@ singleBuild ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} = | |
TTLocal lp -> "build" : map T.unpack (Set.toList $ lpComponents lp) | ||
TTUpstream _ _ -> ["build"] | ||
|
||
when (shouldBuildHaddock eeBuildOpts eeWanted (packageName package) && | ||
packageHasLibrary package && | ||
-- Works around haddock failing on bytestring-builder since it has no modules when | ||
-- bytestring is new enough. | ||
packageHasExposedModules package) $ do | ||
announce "haddock" | ||
hscolourExists <- doesExecutableExist eeEnvOverride "hscolour" | ||
cabal False (concat [["haddock", "--html"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth throwing in the |
||
,["--hyperlink-source" | hscolourExists]]) | ||
|
||
withMVar eeInstallLock $ \() -> do | ||
announce "install" | ||
cabal False ["install"] | ||
|
@@ -720,61 +733,6 @@ singleBench ac ee task = | |
announce "benchmarks" | ||
cabal False ["bench"] | ||
|
||
singleHaddock :: M env m | ||
=> ActionContext | ||
-> ExecuteEnv | ||
-> Task | ||
-> m () | ||
singleHaddock ac ee task = | ||
withSingleContext ac ee task $ \_package _cabalfp _pkgDir cabal announce _console _mlogFile -> do | ||
announce "haddock" | ||
hscolourExists <- doesExecutableExist (eeEnvOverride ee) "hscolour" | ||
{- EKB TODO: doc generation for stack-doc-server | ||
#ifndef mingw32_HOST_OS | ||
liftIO (removeDocLinks docLoc package) | ||
#endif | ||
ifcOpts <- liftIO (haddockInterfaceOpts docLoc package packages) | ||
-} | ||
cabal False (concat [["haddock", "--html"] | ||
,["--hyperlink-source" | hscolourExists]]) | ||
{- EKB TODO: doc generation for stack-doc-server | ||
,"--hoogle" | ||
,"--html-location=../$pkg-$version/" | ||
,"--haddock-options=" ++ intercalate " " ifcOpts ] | ||
haddockLocs <- | ||
liftIO (findFiles (packageDocDir package) | ||
(\loc -> FilePath.takeExtensions (toFilePath loc) == | ||
"." ++ haddockExtension) | ||
(not . isHiddenDir)) | ||
forM_ haddockLocs $ \haddockLoc -> | ||
do let hoogleTxtPath = FilePath.replaceExtension (toFilePath haddockLoc) "txt" | ||
hoogleDbPath = FilePath.replaceExtension hoogleTxtPath hoogleDbExtension | ||
hoogleExists <- liftIO (doesFileExist hoogleTxtPath) | ||
when hoogleExists | ||
(callProcess | ||
"hoogle" | ||
["convert" | ||
,"--haddock" | ||
,hoogleTxtPath | ||
,hoogleDbPath]) | ||
-} | ||
{- EKB TODO: doc generation for stack-doc-server | ||
#ifndef mingw32_HOST_OS | ||
case setupAction of | ||
DoHaddock -> liftIO (createDocLinks docLoc package) | ||
_ -> return () | ||
#endif | ||
|
||
-- | Package's documentation directory. | ||
packageDocDir :: (MonadThrow m, MonadReader env m, HasPlatform env) | ||
=> PackageIdentifier -- ^ Cabal version | ||
-> Package | ||
-> m (Path Abs Dir) | ||
packageDocDir cabalPkgVer package' = do | ||
dist <- distDirFromDir cabalPkgVer (packageDir package') | ||
return (dist </> $(mkRelDir "doc/")) | ||
--} | ||
|
||
-- | Grab all output from the given @Handle@ and print it to stdout, stripping | ||
-- Template Haskell "Loading package" lines. Does work in a separate thread. | ||
printBuildOutput :: (MonadIO m, MonadBaseControl IO m, MonadLogger m) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this redundant with
packageHasExposedModules
? If not, under what circumstances may it be necessary? If it is redundant, looks like a good place to useassert
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure it's redundant (I think I wrote this before I added the packageHasExposedModules check to shouldBuildHaddock).