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
8ba58271
Commit
8ba58271
authored
Dec 30, 2015
by
Andrey Mokhov
Browse files
Decompose Settings/Builders/Ghc.hs (see
#60
).
parent
7ca8be77
Changes
12
Hide whitespace changes
Inline
Side-by-side
shaking-up-ghc.cabal
View file @
8ba58271
...
...
@@ -72,6 +72,10 @@ executable ghc-shake
, Settings.Packages
, Settings.Packages.Compiler
, Settings.Packages.Directory
, Settings.Packages.Ghc
, Settings.Packages.GhcCabal
, Settings.Packages.Hp2ps
, Settings.Packages.RunGhc
, Settings.TargetDirectory
, Settings.User
, Settings.Ways
...
...
src/Settings/Args.hs
View file @
8ba58271
...
...
@@ -18,6 +18,10 @@ import Settings.Builders.HsCpp
import
Settings.Builders.Ld
import
Settings.Packages.Compiler
import
Settings.Packages.Directory
import
Settings.Packages.Ghc
import
Settings.Packages.GhcCabal
import
Settings.Packages.Hp2ps
import
Settings.Packages.RunGhc
import
Settings.User
getArgs
::
Expr
[
String
]
...
...
@@ -51,5 +55,9 @@ defaultBuilderArgs = mconcat
defaultPackageArgs
::
Args
defaultPackageArgs
=
mconcat
[
compilerArgs
,
directoryArgs
]
[
compilerPackageArgs
,
directoryPackageArgs
,
ghcPackageArgs
,
ghcCabalPackageArgs
,
hp2psPackageArgs
,
runGhcPackageArgs
]
src/Settings/Builders/GenPrimopCode.hs
View file @
8ba58271
...
...
@@ -4,7 +4,6 @@ import Expression
import
Predicates
(
builder
,
file
)
-- Stdin/stdout are handled in a special way. See Rules/Actions.hs.
-- TODO: Do we want to keep "--usage"? It seems to be unused.
genPrimopCodeArgs
::
Args
genPrimopCodeArgs
=
builder
GenPrimopCode
?
mconcat
[
file
"//PrimopWrappers.hs"
?
arg
"--make-haskell-wrappers"
...
...
src/Settings/Builders/Ghc.hs
View file @
8ba58271
...
...
@@ -3,7 +3,6 @@ module Settings.Builders.Ghc (ghcArgs, ghcMArgs, commonGhcArgs) where
import
Base
import
Expression
import
Oracles
import
GHC
import
Predicates
hiding
(
way
,
stage
)
import
Settings
import
Settings.Builders.GhcCabal
(
bootPackageDbArgs
)
...
...
@@ -22,20 +21,14 @@ ghcArgs = stagedBuilder Ghc ? do
let
buildObj
=
(
"//*."
++
osuf
way
)
?==
output
||
(
"//*."
++
obootsuf
way
)
?==
output
libs
<-
getPkgDataList
DepExtraLibs
libDirs
<-
getPkgDataList
DepLibDirs
version
<-
getSetting
ProjectVersion
mconcat
[
commonGhcArgs
,
ghcCabalBootArgs
,
arg
"-H32m"
,
stage0
?
arg
"-O"
,
notStage0
?
arg
"-O2"
,
arg
"-Wall"
,
arg
"-fwarn-tabs"
,
isLibrary
pkg
?
splitObjects
?
arg
"-split-objs"
,
package
ghc
?
arg
"-no-hs-main"
-- TODO: simplify
,
package
hp2ps
?
arg
"-no-hs-main"
,
(
pkg
/=
ghcCabal
)
?
not
buildObj
?
arg
"-no-auto-link-packages"
,
package
runghc
?
file
"//Main.o"
?
append
[
"-cpp"
,
"-DVERSION=
\"
"
++
version
++
"
\"
"
]
,
not
buildObj
?
arg
"-no-auto-link-packages"
,
not
buildObj
?
append
[
"-optl-l"
++
lib
|
lib
<-
libs
]
,
not
buildObj
?
append
[
"-optl-L"
++
dir
|
dir
<-
libDirs
]
,
buildObj
?
arg
"-c"
...
...
@@ -98,8 +91,7 @@ packageGhcArgs = do
compId
<-
getPkgData
ComponentId
pkgDepIds
<-
getPkgDataList
DepIds
mconcat
[
not
(
pkg
==
hp2ps
||
pkg
==
ghcCabal
&&
stage
==
Stage0
)
?
arg
"-hide-all-packages"
[
arg
"-hide-all-packages"
,
arg
"-no-user-package-db"
,
bootPackageDbArgs
,
isLibrary
pkg
?
...
...
@@ -111,7 +103,6 @@ packageGhcArgs = do
-- TODO: Improve handling of "cabal_macros.h"
includeGhcArgs
::
Args
includeGhcArgs
=
do
stage
<-
getStage
pkg
<-
getPackage
path
<-
getTargetPath
srcDirs
<-
getPkgDataList
SrcDirs
...
...
@@ -122,26 +113,8 @@ includeGhcArgs = do
,
arg
$
"-i"
++
autogenPath
,
append
[
"-i"
++
pkgPath
pkg
-/-
dir
|
dir
<-
srcDirs
]
,
cIncludeArgs
,
(
pkg
==
compiler
||
pkg
==
ghc
)
?
arg
(
"-I"
++
pkgPath
compiler
-/-
"stage"
++
show
(
fromEnum
stage
))
,
not
(
pkg
==
hp2ps
||
pkg
==
ghcCabal
&&
stage
==
Stage0
)
?
append
[
"-optP-include"
,
"-optP"
++
autogenPath
-/-
"cabal_macros.h"
]
]
-- Boostrapping ghcCabal
-- TODO: do we need -DCABAL_VERSION=$(CABAL_VERSION)?
ghcCabalBootArgs
::
Args
ghcCabalBootArgs
=
package
ghcCabal
?
stage0
?
mconcat
[
arg
"--make"
,
arg
"-DBOOTSTRAPPING"
,
arg
"-DMIN_VERSION_binary_0_8_0"
,
arg
"-DGENERICS"
,
arg
"-optP-include"
,
arg
$
"-optP"
++
pkgPath
ghcCabal
-/-
"cabal_macros_boot.h"
,
arg
"-ilibraries/Cabal/Cabal"
,
arg
"-ilibraries/binary/src"
,
arg
"-ilibraries/filepath"
,
arg
"-ilibraries/hpc"
]
,
arg
"-optP-include"
,
arg
$
"-optP"
++
autogenPath
-/-
"cabal_macros.h"
]
-- # Options for passing to plain ld
-- $1_$2_$3_ALL_LD_OPTS = \
...
...
src/Settings/Builders/GhcCabal.hs
View file @
8ba58271
...
...
@@ -89,8 +89,7 @@ bootPackageDbArgs :: Args
bootPackageDbArgs
=
stage0
?
do
path
<-
getSetting
GhcSourcePath
lift
$
need
[
bootstrappingConfInitialised
]
isGhc
<-
stagedBuilder
Ghc
||^
stagedBuilder
GhcM
let
prefix
=
if
isGhc
then
"-package-db "
else
"--package-db="
prefix
<-
ifM
builderGhc
(
return
"-package-db "
)
(
return
"--package-db="
)
arg
$
prefix
++
path
-/-
bootstrappingConf
packageConstraints
::
Args
...
...
src/Settings/Builders/HsCpp.hs
View file @
8ba58271
...
...
@@ -11,7 +11,7 @@ hsCppArgs = builder HsCpp ? do
mconcat
[
append
=<<
getSettingList
HsCppArgs
,
arg
"-P"
,
cppArgs
,
arg
$
"-Icompiler/
stage
"
++
s
how
(
fromEnum
stage
)
,
arg
$
"-Icompiler/"
++
s
tageString
stage
,
arg
"-x"
,
arg
"c"
,
arg
=<<
getInput
]
src/Settings/Packages/Compiler.hs
View file @
8ba58271
module
Settings.Packages.Compiler
(
compilerArgs
)
where
module
Settings.Packages.Compiler
(
compiler
Package
Args
)
where
import
Base
import
Expression
import
GHC
(
compiler
)
import
Predicates
(
builder
,
package
)
import
Predicates
(
builder
,
builderGhc
,
package
)
compilerArgs
::
Args
compilerArgs
=
package
compiler
?
mconcat
[
builder
Alex
?
arg
"--latin1"
]
compilerPackageArgs
::
Args
compilerPackageArgs
=
package
compiler
?
do
stage
<-
getStage
mconcat
[
builder
Alex
?
arg
"--latin1"
,
builderGhc
?
arg
(
"-I"
++
pkgPath
compiler
-/-
stageString
stage
)
]
src/Settings/Packages/Directory.hs
View file @
8ba58271
module
Settings.Packages.Directory
(
directoryArgs
)
where
module
Settings.Packages.Directory
(
directory
Package
Args
)
where
import
Expression
import
GHC
(
directory
)
...
...
@@ -8,6 +8,6 @@ import Predicates (stagedBuilder, package)
-- effectively empty. I presume it was expected that GHC will be used for
-- compiling all C files, but I don't know why. It seems that directory.c is the
-- only file which requires special treatment when using GCC.
directoryArgs
::
Args
directoryArgs
=
package
directory
?
directory
Package
Args
::
Args
directory
Package
Args
=
package
directory
?
stagedBuilder
Gcc
?
arg
"-D__GLASGOW_HASKELL__"
src/Settings/Packages/Ghc.hs
0 → 100644
View file @
8ba58271
module
Settings.Packages.Ghc
(
ghcPackageArgs
)
where
import
Base
import
Expression
import
GHC
(
ghc
,
compiler
)
import
Predicates
(
builderGhc
,
package
)
ghcPackageArgs
::
Args
ghcPackageArgs
=
package
ghc
?
do
stage
<-
getStage
mconcat
[
builderGhc
?
mconcat
[
arg
(
"-I"
++
pkgPath
compiler
-/-
stageString
stage
)
,
arg
"-no-hs-main"
]
]
src/Settings/Packages/GhcCabal.hs
0 → 100644
View file @
8ba58271
module
Settings.Packages.GhcCabal
(
ghcCabalPackageArgs
)
where
import
Base
import
Expression
import
GHC
(
ghcCabal
)
import
Predicates
(
builderGhc
,
package
,
stage0
)
import
Settings
ghcCabalPackageArgs
::
Args
ghcCabalPackageArgs
=
package
ghcCabal
?
mconcat
[
builderGhc
?
mconcat
[
ghcCabalBootArgs
,
remove
[
"-no-auto-link-packages"
]
]
]
-- Boostrapping ghcCabal
-- TODO: do we need -DCABAL_VERSION=$(CABAL_VERSION)?
ghcCabalBootArgs
::
Args
ghcCabalBootArgs
=
stage0
?
do
path
<-
getTargetPath
let
cabalMacros
=
path
-/-
"build/autogen/cabal_macros.h"
cabalMacrosBoot
=
pkgPath
ghcCabal
-/-
"cabal_macros_boot.h"
mconcat
[
remove
[
"-hide-all-packages"
]
,
removePair
"-optP-include"
$
"-optP"
++
cabalMacros
,
arg
"--make"
,
arg
"-DBOOTSTRAPPING"
,
arg
"-DMIN_VERSION_binary_0_8_0"
,
arg
"-DGENERICS"
,
arg
"-optP-include"
,
arg
$
"-optP"
++
cabalMacrosBoot
,
arg
"-ilibraries/Cabal/Cabal"
,
arg
"-ilibraries/binary/src"
,
arg
"-ilibraries/filepath"
,
arg
"-ilibraries/hpc"
]
src/Settings/Packages/Hp2ps.hs
0 → 100644
View file @
8ba58271
module
Settings.Packages.Hp2ps
(
hp2psPackageArgs
)
where
import
Base
import
Expression
import
GHC
(
hp2ps
)
import
Predicates
(
builderGhc
,
package
)
import
Settings
hp2psPackageArgs
::
Args
hp2psPackageArgs
=
package
hp2ps
?
do
path
<-
getTargetPath
let
cabalMacros
=
path
-/-
"build/autogen/cabal_macros.h"
mconcat
[
builderGhc
?
mconcat
[
arg
"-no-hs-main"
,
remove
[
"-hide-all-packages"
]
,
removePair
"-optP-include"
$
"-optP"
++
cabalMacros
]
]
src/Settings/Packages/RunGhc.hs
0 → 100644
View file @
8ba58271
module
Settings.Packages.RunGhc
(
runGhcPackageArgs
)
where
import
Expression
import
GHC
(
runGhc
)
import
Oracles.Config.Setting
import
Predicates
(
builderGhc
,
file
,
package
)
runGhcPackageArgs
::
Args
runGhcPackageArgs
=
package
runGhc
?
do
version
<-
getSetting
ProjectVersion
mconcat
[
builderGhc
?
file
"//Main.o"
?
append
[
"-cpp"
,
"-DVERSION=
\"
"
++
version
++
"
\"
"
]
]
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