Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
e3be330a
Commit
e3be330a
authored
Nov 27, 2016
by
Andrey Mokhov
Browse files
Simplify handling of non-Cabal contexts
parent
72a08b0e
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/Expression.hs
View file @
e3be330a
...
...
@@ -3,7 +3,7 @@ module Expression (
-- * Expressions
Expr
,
DiffExpr
,
fromDiffExpr
,
-- ** Operators
apply
,
append
,
arg
,
remove
,
removePair
,
apply
,
append
,
arg
,
remove
,
appendSub
,
appendSubD
,
filterSub
,
removeSub
,
-- ** Evaluation
interpret
,
interpretInContext
,
interpretDiff
,
...
...
@@ -80,16 +80,6 @@ append x = apply (<> x)
remove
::
Eq
a
=>
[
a
]
->
DiffExpr
[
a
]
remove
xs
=
apply
$
filter
(`
notElem
`
xs
)
-- | Remove given pair of elements from a list expression.
-- Example: removePair "-flag" "b" ["-flag", "a", "-flag", "b"] = ["-flag", "a"]
removePair
::
Eq
a
=>
a
->
a
->
DiffExpr
[
a
]
removePair
x
y
=
apply
filterPair
where
filterPair
(
z1
:
z2
:
zs
)
=
if
x
==
z1
&&
y
==
z2
then
filterPair
zs
else
z1
:
filterPair
(
z2
:
zs
)
filterPair
zs
=
zs
-- | Apply a predicate to an expression.
applyPredicate
::
Monoid
a
=>
Predicate
->
Expr
a
->
Expr
a
applyPredicate
predicate
expr
=
do
...
...
src/GHC.hs
View file @
e3be330a
...
...
@@ -9,7 +9,7 @@ module GHC (
parallel
,
pretty
,
primitive
,
process
,
rts
,
runGhc
,
stm
,
templateHaskell
,
terminfo
,
time
,
touchy
,
transformers
,
unlit
,
unix
,
win32
,
xhtml
,
defaultKnownPackages
,
builderProvenance
,
programName
defaultKnownPackages
,
builderProvenance
,
programName
,
nonCabalContext
)
where
import
Builder
...
...
@@ -123,3 +123,10 @@ programName Context {..}
|
package
==
hpcBin
=
"hpc"
|
package
==
runGhc
=
"runhaskell"
|
otherwise
=
pkgNameString
package
-- | Some contexts are special: their packages do have @.cabal@ metadata or
-- we cannot run @ghc-cabal@ on them, e.g. because the latter hasn't been built
-- yet (this is the case with the 'ghcCabal' package in 'Stage0').
nonCabalContext
::
Context
->
Bool
nonCabalContext
Context
{
..
}
=
(
package
`
elem
`
[
hp2ps
,
rts
,
touchy
,
unlit
])
||
package
==
ghcCabal
&&
stage
==
Stage0
src/Rules/Data.hs
View file @
e3be330a
...
...
@@ -52,16 +52,8 @@ buildPackageData context@Context {..} = do
let
oldPath
=
top
-/-
path
</>
"build"
fixFile
conf
$
unlines
.
map
(
replace
oldPath
path
)
.
lines
-- TODO: PROGNAME was $(CrossCompilePrefix)hp2ps.
priority
2.0
$
do
when
(
package
`
elem
`
[
hp2ps
,
rts
,
touchy
,
unlit
])
$
dataFile
%>
generatePackageData
context
-- Bootstrapping `ghcCabal`: although `ghcCabal` is a proper cabal
-- package, we cannot generate the corresponding `package-data.mk` file
-- by running by running `ghcCabal`, because it has not yet been built.
when
(
package
==
ghcCabal
&&
stage
==
Stage0
)
$
dataFile
%>
generatePackageData
context
priority
2.0
$
when
(
nonCabalContext
context
)
$
dataFile
%>
generatePackageData
context
generatePackageData
::
Context
->
FilePath
->
Action
()
generatePackageData
context
@
Context
{
..
}
file
=
do
...
...
src/Rules/Libffi.hs
View file @
e3be330a
...
...
@@ -5,7 +5,6 @@ import Settings.Packages.Rts
import
Target
import
Util
-- TODO: Why copy these include files into rts? Keep in libffi!
libffiDependencies
::
[
FilePath
]
libffiDependencies
=
(
rtsBuildPath
-/-
)
<$>
[
"ffi.h"
,
"ffitarget.h"
]
...
...
src/Settings/Builders/Ghc.hs
View file @
e3be330a
module
Settings.Builders.Ghc
(
ghcBuilderArgs
,
ghcMBuilderArgs
,
commonGhcArgs
)
where
import
Flavour
import
GHC
import
Settings.Builders.Common
ghcBuilderArgs
::
Args
...
...
@@ -106,7 +107,6 @@ packageGhcArgs = do
,
isLibrary
pkg
?
arg
(
thisArg
++
compId
)
,
append
$
map
(
"-package-id "
++
)
pkgDepIds
]
-- TODO: Improve handling of "cabal_macros.h".
includeGhcArgs
::
Args
includeGhcArgs
=
do
pkg
<-
getPackage
...
...
@@ -120,5 +120,6 @@ includeGhcArgs = do
,
cIncludeArgs
,
arg
$
"-I"
++
generatedPath
,
arg
$
"-optc-I"
++
generatedPath
,
arg
"-optP-include"
,
arg
$
"-optP"
++
autogenPath
context
-/-
"cabal_macros.h"
]
,
(
not
$
nonCabalContext
context
)
?
append
[
"-optP-include"
,
"-optP"
++
autogenPath
context
-/-
"cabal_macros.h"
]
]
src/Settings/Packages/GhcCabal.hs
View file @
e3be330a
...
...
@@ -4,14 +4,12 @@ import Base
import
GHC
import
Oracles.Config.Setting
import
Predicate
import
Settings.Path
ghcCabalPackageArgs
::
Args
ghcCabalPackageArgs
=
package
ghcCabal
?
builder
Ghc
?
mconcat
[
ghcCabalBootArgs
,
remove
[
"-no-auto-link-packages"
]
]
-- Boostrapping ghcCabal
-- TODO: do we need -DCABAL_VERSION=$(CABAL_VERSION)?
ghcCabalBootArgs
::
Args
ghcCabalBootArgs
=
stage0
?
do
...
...
@@ -23,7 +21,6 @@ ghcCabalBootArgs = stage0 ? do
,
pretty
,
process
,
time
]
,
notM
windowsHost
?
append
[
unix
]
,
windowsHost
?
append
[
win32
]
]
context
<-
getContext
mconcat
[
append
[
"-package "
++
pkgNameString
pkg
|
pkg
<-
cabalDeps
]
,
arg
"--make"
...
...
@@ -31,7 +28,6 @@ ghcCabalBootArgs = stage0 ? do
,
arg
"-DBOOTSTRAPPING"
,
arg
"-DMIN_VERSION_binary_0_8_0"
,
arg
"-DGENERICS"
,
removePair
"-optP-include"
$
"-optP"
++
autogenPath
context
-/-
"cabal_macros.h"
,
arg
"-optP-include"
,
arg
$
"-optP"
++
pkgPath
ghcCabal
-/-
"cabal_macros_boot.h"
,
arg
"-ilibraries/Cabal/Cabal"
...
...
src/Settings/Packages/Hp2ps.hs
View file @
e3be330a
module
Settings.Packages.Hp2ps
(
hp2psPackageArgs
)
where
import
Base
import
GHC
import
Predicate
import
Settings
hp2psPackageArgs
::
Args
hp2psPackageArgs
=
package
hp2ps
?
do
path
<-
getBuildPath
let
cabalMacros
=
path
-/-
"build/autogen/cabal_macros.h"
hp2psPackageArgs
=
package
hp2ps
?
builder
Ghc
?
mconcat
[
arg
"-no-hs-main"
,
remove
[
"-hide-all-packages"
]
,
removePair
"-optP-include"
$
"-optP"
++
cabalMacros
]
,
remove
[
"-hide-all-packages"
]
]
src/Settings/Packages/Touchy.hs
View file @
e3be330a
module
Settings.Packages.Touchy
(
touchyPackageArgs
)
where
import
Base
import
GHC
import
Predicate
import
Settings
touchyPackageArgs
::
Args
touchyPackageArgs
=
package
touchy
?
do
path
<-
getBuildPath
let
cabalMacros
=
path
-/-
"build/autogen/cabal_macros.h"
touchyPackageArgs
=
package
touchy
?
builder
Ghc
?
mconcat
[
arg
"-no-hs-main"
,
remove
[
"-hide-all-packages"
]
,
removePair
"-optP-include"
$
"-optP"
++
cabalMacros
]
,
remove
[
"-hide-all-packages"
]
]
src/Settings/Packages/Unlit.hs
View file @
e3be330a
module
Settings.Packages.Unlit
(
unlitPackageArgs
)
where
import
Base
import
GHC
import
Predicate
import
Settings
unlitPackageArgs
::
Args
unlitPackageArgs
=
package
unlit
?
do
path
<-
getBuildPath
let
cabalMacros
=
path
-/-
"build/autogen/cabal_macros.h"
unlitPackageArgs
=
package
unlit
?
builder
Ghc
?
mconcat
[
arg
"-no-hs-main"
,
remove
[
"-hide-all-packages"
]
,
removePair
"-optP-include"
$
"-optP"
++
cabalMacros
]
,
remove
[
"-hide-all-packages"
]
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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