Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
f1249dab
Commit
f1249dab
authored
Aug 01, 2015
by
Andrey Mokhov
Browse files
Switch to using Distribution package for parsing cabal files.
parent
4aabd6f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Settings/GhcCabal.hs
View file @
f1249dab
...
...
@@ -16,8 +16,11 @@ import Settings.User
import
Settings.Ways
import
Settings.Util
import
Settings.Packages
import
Data.List
import
Control.Applicative
import
Data.Version
import
qualified
Distribution.Package
as
D
import
qualified
Distribution.PackageDescription
as
D
import
qualified
Distribution.Verbosity
as
D
import
qualified
Distribution.PackageDescription.Parse
as
D
cabalArgs
::
Args
cabalArgs
=
builder
GhcCabal
?
do
...
...
@@ -33,7 +36,7 @@ cabalArgs = builder GhcCabal ? do
,
libraryArgs
,
with
HsColour
,
configureArgs
,
stage0
?
packageConstraints
,
packageConstraints
,
withStaged
Gcc
,
notStage0
?
with
Ld
,
with
Ar
...
...
@@ -92,20 +95,19 @@ bootPackageDbArgs = do
dllArgs
::
Args
dllArgs
=
arg
""
-- TODO: speed up by caching the result in Shake database?
packageConstraints
::
Args
packageConstraints
=
do
packageConstraints
=
stage0
?
do
pkgs
<-
getPackages
constraints
<-
lift
$
forM
pkgs
$
\
pkg
->
do
let
cabal
=
pkgPath
pkg
-/-
pkgCabal
pkg
prefix
=
dropExtension
(
pkgCabal
pkg
)
++
" == "
let
cabal
=
pkgPath
pkg
-/-
pkgCabal
pkg
need
[
cabal
]
content
<-
lines
<$>
liftIO
(
readFile
cabal
)
let
vs
=
filter
((
"ersion:"
`
isPrefixOf
`)
.
drop
1
)
content
case
vs
of
[
v
]
->
return
$
prefix
++
dropWhile
(
not
.
isDigit
)
v
_
->
redError
$
"Cannot determine package version in '"
++
cabal
++
"'."
append
$
concatMap
(
\
c
->
[
"--constraint"
,
c
])
$
constraints
description
<-
liftIO
$
D
.
readPackageDescription
D
.
silent
cabal
let
identifier
=
D
.
package
.
D
.
packageDescription
$
description
version
=
showVersion
.
D
.
pkgVersion
$
identifier
D
.
PackageName
name
=
D
.
pkgName
$
identifier
return
$
name
++
" == "
++
version
append
.
concatMap
(
\
c
->
[
"--constraint"
,
c
])
$
constraints
-- TODO: should be in a different file
-- TODO: put all validating options together in one file
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment