-
Notifications
You must be signed in to change notification settings - Fork 138
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
Fix #404 Accommodate ${pkgroot} and tolerate GHC errors on Windows #405
Open
mpilgrem
wants to merge
1
commit into
ndmitchell:master
Choose a base branch
from
mpilgrem:fix404
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+23
−4
Open
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{-# LANGUAGE ViewPatterns, PatternGuards, TupleSections, RecordWildCards, ScopedTypeVariables #-} | ||
{-# LANGUAGE CPP, ViewPatterns, PatternGuards, TupleSections, RecordWildCards, ScopedTypeVariables #-} | ||
|
||
-- | Module for reading Cabal files. | ||
module Input.Cabal( | ||
|
@@ -79,19 +79,38 @@ packagePopularity cbl = mp `seq` (errs, mp) | |
-- | Run 'ghc-pkg' and get a list of packages which are installed. | ||
readGhcPkg :: Settings -> IO (Map.Map PkgName Package) | ||
readGhcPkg settings = do | ||
-- On Windows, the `haddock-html` field in `*.conf` files for GHC boot | ||
-- libraries for GHC >= 9.0 (up to at least GHC 9.6.2) contain errors. For | ||
-- example, this may be specified: | ||
-- haddock-html: ${pkgroot}/../../doc/html/libraries/base-4.18.0.0 | ||
-- when the correct specification would be: | ||
-- haddock-html: ${pkgroot}/../doc/html/libraries/base-4.18.0.0 | ||
-- So, a unique approach is taken to `readGhcPkg` in that case. It assumes that | ||
-- the `*.conf` files have not been manually corrected. | ||
#if defined(mingw32_HOST_OS) && __GLASGOW_HASKELL__>=901 | ||
let ghcPkgArgs = ["dump"] | ||
-- ^ Do not expand the ${pkgroot} (by default) | ||
unwantedPrefix = "${pkgroot}/.." | ||
-- ^ Should result in ${pkgroot}/../bin/../doc/html/libraries/... | ||
#else | ||
-- From GHC 9.0.1, the `haddock-html` field in `*.conf` files for GHC boot | ||
-- libraries has used `${pkgroot}`, which can be expanded in the output. | ||
let ghcPkgArgs = ["dump", "--expand-pkgroot"] | ||
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. Using |
||
unwantedPrefix = "$topdir" | ||
-- ^ Backwards compatibility with GHC < 9.0 | ||
#endif | ||
topdir <- findExecutable "ghc-pkg" | ||
-- important to use BS process reading so it's in Binary format, see #194 | ||
(exit, stdout, stderr) <- BS.readProcessWithExitCode "ghc-pkg" ["dump"] mempty | ||
(exit, stdout, stderr) <- BS.readProcessWithExitCode "ghc-pkg" ghcPkgArgs mempty | ||
when (exit /= ExitSuccess) $ | ||
errorIO $ "Error when reading from ghc-pkg, " ++ show exit ++ "\n" ++ UTF8.toString stderr | ||
let g (stripPrefix "$topdir" -> Just x) | Just t <- topdir = takeDirectory t ++ x | ||
let g (stripPrefix unwantedPrefix -> Just x) | Just t <- topdir = takeDirectory t ++ x | ||
g x = x | ||
let fixer p = p{packageLibrary = True, packageDocs = g <$> packageDocs p} | ||
let f ((stripPrefix "name: " -> Just x):xs) = Just (strPack $ trimStart x, fixer $ readCabal settings $ unlines xs) | ||
f xs = Nothing | ||
pure $ Map.fromList $ mapMaybe f $ splitOn ["---"] $ lines $ filter (/= '\r') $ UTF8.toString stdout | ||
|
||
|
||
-- | Given a tarball of Cabal files, parse the latest version of each package. | ||
parseCabalTarball :: Settings -> FilePath -> IO (Map.Map PkgName Package) | ||
-- items are stored as: | ||
|
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.
This CPP should have an upper bound, it is fixed in 9.10.1.
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.
I'm not sure it's a great idea to bake this logic about some broken bindists into hoogle, someone could build their own bindist which doesn't have this bug and it would be broken.