-
Notifications
You must be signed in to change notification settings - Fork 695
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
Finish new-install #5399
Merged
Merged
Finish new-install #5399
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
bbbb833
Allow resolveTargets to know about Hackage packages
typedrat ceb0db8
Remove redundant import
typedrat 97f4a47
Teach new-install to build non-local exes
typedrat 78cb12b
WIP, waiting on a way to make a SourceHash of a local file. `sdist`?
typedrat da8c04d
Unbreak broken things
typedrat 067b467
Add local target support
typedrat 72c9db4
Fix new-install outside of packages
typedrat ccbf77a
Add library component installation support
typedrat 57f6c92
Restructure code, fix library new-install solving on macOS
typedrat 6df9877
Fix typo
typedrat c217882
Fix typo 2: fix harder
typedrat f1deb37
Add warning when library installation isn't possible
typedrat ab3392b
Document new-install's completion
typedrat 9d050f9
Fix missing imports
typedrat 3e4bf39
Remove unneeded imports (Fix -Werror failure)
typedrat 945a40f
Use correct program DB
typedrat 802c57a
Remove old TODOs [ci skip]
typedrat c931050
Use updated program DB.
typedrat fd1cec6
Add correct prefix to sdists
typedrat 0d9afdd
Fix logic error in CmdInstall
typedrat 8030619
Drop Parsec dependency in cabal-install
typedrat 063efa8
(Hopefully) fix GHC 7.10
typedrat 1fb3464
Fix incorrect environment parser
typedrat c28caec
Expose `parseGhcEnvironmentFile`.
typedrat 7935920
Add warning if environment file is unparsable
typedrat f0d374d
Add GHC core libraries to environment file by default
typedrat 9068961
Fix sdist tests
typedrat 4467a90
Fix zip sdists as well
typedrat f100994
Remove redundant import
typedrat 12479ba
Add `--lib` option
typedrat 11e2d0d
Add flag to control library installation
typedrat 1f5225e
Fix new-install by 'PackageId'
typedrat 4bff0e4
Add --env-cwd
typedrat e0ee808
Change environment flag to mirror GHC
typedrat 832a532
Fix code clean-up error
typedrat ec97ec0
Update documentation with accurate usage
typedrat 1fc266e
Fix verbosity-parsing bug.
typedrat 7d961eb
Make packageToSdist restore $OLDPWD
typedrat 6b06e6a
Fix ProjectPlanning so not all SpecificSourcePackages are local
typedrat 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{-# LANGUAGE DeriveDataTypeable #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
module Distribution.Simple.GHC.EnvironmentParser | ||
( parseGhcEnvironmentFile, readGhcEnvironmentFile, ParseErrorExc(..) ) where | ||
|
||
import Prelude () | ||
import Distribution.Compat.Prelude | ||
|
||
import Distribution.Simple.Compiler | ||
( PackageDB(..) ) | ||
import Distribution.Simple.GHC.Internal | ||
( GhcEnvironmentFileEntry(..) ) | ||
import Distribution.Types.UnitId | ||
( mkUnitId ) | ||
|
||
import Control.Exception | ||
( Exception, throwIO ) | ||
import qualified Text.Parsec as P | ||
import Text.Parsec.String | ||
( Parser, parseFromFile ) | ||
|
||
parseEnvironmentFileLine :: Parser GhcEnvironmentFileEntry | ||
parseEnvironmentFileLine = GhcEnvFileComment <$> comment | ||
<|> GhcEnvFilePackageId <$> unitId | ||
<|> GhcEnvFilePackageDb <$> packageDb | ||
<|> pure GhcEnvFileClearPackageDbStack <* clearDb | ||
where | ||
comment = P.string "--" *> P.many (P.noneOf "\r\n") | ||
unitId = P.try $ P.string "package-id" *> P.spaces *> | ||
(mkUnitId <$> P.many1 (P.satisfy $ \c -> isAlphaNum c || c `elem` "-_.+")) | ||
packageDb = (P.string "global-package-db" *> pure GlobalPackageDB) | ||
<|> (P.string "user-package-db" *> pure UserPackageDB) | ||
<|> (P.string "package-db" *> P.spaces *> (SpecificPackageDB <$> P.many1 (P.noneOf "\r\n") <* P.lookAhead P.endOfLine)) | ||
clearDb = P.string "clear-package-db" | ||
|
||
newtype ParseErrorExc = ParseErrorExc P.ParseError | ||
deriving (Show, Typeable) | ||
|
||
instance Exception ParseErrorExc | ||
|
||
parseGhcEnvironmentFile :: Parser [GhcEnvironmentFileEntry] | ||
parseGhcEnvironmentFile = parseEnvironmentFileLine `P.sepEndBy` P.endOfLine <* P.eof | ||
|
||
readGhcEnvironmentFile :: FilePath -> IO [GhcEnvironmentFileEntry] | ||
readGhcEnvironmentFile path = | ||
either (throwIO . ParseErrorExc) return =<< | ||
parseFromFile parseGhcEnvironmentFile path |
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
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
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.
GHC has code for parsing these files in DynFlags, but this code is better and we should have an eye on reusing it in GHC. Specifically, I think exporting
parseEnvironmentFile
along withGhcEnvironmentFileEntry
and its constructors from a non-internal module ought to be enough (which we ought to do anyway, since it's mentioned in the types of this non-internal module).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.
Already exposed in
Distribution.Simple.GHC
. When we get this merged and available to GHC, I'd be happy to write a patch to use this instead. :)