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
65b298b0
Commit
65b298b0
authored
Jul 25, 2015
by
Andrey Mokhov
Browse files
Implement buildPackageDependencies rule.
parent
ff86f40e
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/Builder.hs
View file @
65b298b0
...
...
@@ -29,6 +29,7 @@ data Builder = Ar
|
Gcc
Stage
|
Ghc
Stage
|
GhcM
Stage
|
GccM
Stage
|
GhcPkg
Stage
deriving
(
Show
,
Eq
,
Generic
)
...
...
@@ -51,6 +52,7 @@ builderKey builder = case builder of
GhcPkg
_
->
"ghc-pkg"
-- GhcM is currently a synonym for Ghc (to be called with -M flag)
GhcM
stage
->
builderKey
$
Ghc
stage
GccM
stage
->
builderKey
$
Gcc
stage
builderPath
::
Builder
->
Action
String
builderPath
builder
=
do
...
...
src/Package/Dependencies.hs
deleted
100644 → 0
View file @
ff86f40e
{-# LANGUAGE NoImplicitPrelude #-}
module
Package.Dependencies
(
buildPackageDependencies
)
where
import
Package.Base
-- TODO: use oracles instead of arg files.
argListDir
::
FilePath
argListDir
=
"shake/arg/buildPackageDependencies"
ghcArgs
::
Package
->
TodoItem
->
Args
ghcArgs
(
Package
name
path
_
_
)
(
stage
,
dist
,
settings
)
=
let
pathDist
=
path
</>
dist
buildDir
=
unifyPath
$
pathDist
</>
"build"
depFile
=
buildDir
</>
"haskell.deps"
in
args
[
arg
"-M"
,
packageArgs
stage
pathDist
,
includeGhcArgs
path
dist
,
concatArgs
[
"-optP"
]
$
CppArgs
pathDist
,
productArgs
[
"-odir"
,
"-stubdir"
,
"-hidir"
]
[
buildDir
]
,
args
[
"-dep-makefile"
,
depFile
]
,
productArgs
[
"-dep-suffix"
]
$
map
wayPrefix
<$>
ways
settings
,
args
$
HsArgs
pathDist
,
args
$
pkgHsSources
path
dist
]
-- $1_$2_$3_ALL_CC_OPTS = \
-- $$(WAY_$3_CC_OPTS) \
-- $$($1_$2_DIST_GCC_CC_OPTS) \
-- $$($1_$2_$3_CC_OPTS) \
-- $$($$(basename $$<)_CC_OPTS) \
-- $$($1_$2_EXTRA_CC_OPTS) \
-- $$(EXTRA_CC_OPTS)
--
-- $1_$2_DIST_CC_OPTS = \
-- $$(SRC_CC_OPTS) \
-- $$($1_CC_OPTS) \
-- -I$1/$2/build/autogen \
-- $$(foreach dir,$$(filter-out /%,$$($1_$2_INCLUDE_DIRS)),-I$1/$$(dir)) \
-- $$(foreach dir,$$(filter /%,$$($1_$2_INCLUDE_DIRS)),-I$$(dir)) \
-- $$($1_$2_CC_OPTS) \
-- $$($1_$2_CPP_OPTS) \
-- $$($1_$2_CC_INC_FLAGS) \
-- $$($1_$2_DEP_CC_OPTS) \
-- $$(SRC_CC_WARNING_OPTS)
-- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
gccArgs
::
FilePath
->
Package
->
TodoItem
->
Args
gccArgs
sourceFile
(
Package
_
path
_
_
)
(
stage
,
dist
,
settings
)
=
let
pathDist
=
path
</>
dist
buildDir
=
pathDist
</>
"build"
depFile
=
buildDir
</>
takeFileName
sourceFile
<.>
"deps"
in
args
[
args
[
"-E"
,
"-MM"
]
-- TODO: add a Cpp Builder instead
,
args
$
CcArgs
pathDist
,
commonCcArgs
-- TODO: remove?
,
customCcArgs
settings
-- TODO: Replace by customCppArgs?
,
commonCcWarninigArgs
-- TODO: remove?
,
includeGccArgs
path
dist
,
args
[
"-MF"
,
unifyPath
depFile
]
,
args
[
"-x"
,
"c"
]
,
arg
$
unifyPath
sourceFile
]
buildRule
::
Package
->
TodoItem
->
Rules
()
buildRule
pkg
@
(
Package
name
path
_
_
)
todo
@
(
stage
,
dist
,
settings
)
=
do
let
pathDist
=
path
</>
dist
buildDir
=
pathDist
</>
"build"
(
buildDir
</>
"haskell.deps"
)
%>
\
_
->
do
run
(
Ghc
stage
)
$
ghcArgs
pkg
todo
-- Finally, record the argument list
need
[
argListPath
argListDir
pkg
stage
]
(
buildDir
</>
"c.deps"
)
%>
\
out
->
do
srcs
<-
args
$
CSrcs
pathDist
deps
<-
fmap
concat
$
forM
srcs
$
\
src
->
do
let
srcPath
=
path
</>
src
depFile
=
buildDir
</>
takeFileName
src
<.>
"deps"
run
(
Gcc
stage
)
$
gccArgs
srcPath
pkg
todo
liftIO
$
readFile
depFile
writeFileChanged
out
deps
liftIO
$
removeFiles
buildDir
[
"*.c.deps"
]
-- Finally, record the argument list
need
[
argListPath
argListDir
pkg
stage
]
argListRule
::
Package
->
TodoItem
->
Rules
()
argListRule
pkg
todo
@
(
stage
,
_
,
_
)
=
(
argListPath
argListDir
pkg
stage
)
%>
\
out
->
do
need
$
[
"shake/src/Package/Dependencies.hs"
]
++
sourceDependecies
ghcList
<-
argList
(
Ghc
stage
)
$
ghcArgs
pkg
todo
gccList
<-
argList
(
Gcc
stage
)
$
gccArgs
"source.c"
pkg
todo
writeFileChanged
out
$
ghcList
++
"
\n
"
++
gccList
buildPackageDependencies
::
Package
->
TodoItem
->
Rules
()
buildPackageDependencies
=
argListRule
<>
buildRule
src/Rules.hs
View file @
65b298b0
...
...
@@ -21,7 +21,8 @@ generateTargets = action $
forM_
[
Stage0
..
]
$
\
stage
->
do
pkgs
<-
interpret
(
stageTarget
stage
)
packages
forM_
pkgs
$
\
pkg
->
do
need
[
targetPath
stage
pkg
-/-
"package-data.mk"
]
need
[
targetPath
stage
pkg
-/-
"build/haskell.deps"
]
need
[
targetPath
stage
pkg
-/-
"build/c.deps"
]
-- TODO: add Stage2 (compiler only?)
packageRules
::
Rules
()
...
...
src/Rules/Actions.hs
View file @
65b298b0
...
...
@@ -47,12 +47,10 @@ interestingInfo :: Builder -> [String] -> [String]
interestingInfo
builder
ss
=
case
builder
of
Ar
->
prefixAndSuffix
2
1
ss
Ld
->
prefixAndSuffix
4
0
ss
Gcc
_
->
if
head
ss
==
"-MM"
then
prefixAndSuffix
1
1
ss
else
prefixAndSuffix
0
4
ss
Ghc
_
->
if
head
ss
==
"-M"
then
prefixAndSuffix
1
1
ss
else
prefixAndSuffix
0
4
ss
Gcc
_
->
prefixAndSuffix
0
4
ss
GccM
_
->
prefixAndSuffix
0
1
ss
Ghc
_
->
prefixAndSuffix
0
4
ss
GhcM
_
->
prefixAndSuffix
1
1
ss
GhcPkg
_
->
prefixAndSuffix
3
0
ss
GhcCabal
->
prefixAndSuffix
3
0
ss
_
->
ss
...
...
src/Rules/Data.hs
View file @
65b298b0
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
module
Rules.Data
(
cabalArgs
,
ghcPkgArgs
,
buildPackageData
)
where
module
Rules.Data
(
buildPackageData
)
where
import
Util
import
Package
...
...
@@ -10,8 +6,6 @@ import Builder
import
Switches
import
Expression
import
qualified
Target
import
Settings.GhcPkg
import
Settings.GhcCabal
import
Settings.TargetDirectory
import
Rules.Actions
import
Control.Applicative
...
...
src/Rules/Dependencies.hs
View file @
65b298b0
{-# LANGUAGE NoImplicitPrelude #-}
module
Rules.Data
(
ghcArgs
,
gccArgs
,
buildPackageDependencies
)
where
module
Rules.Dependencies
(
buildPackageDependencies
)
where
import
qualified
Ways
import
Base
hiding
(
arg
,
args
,
Args
)
import
Package
import
Expression.Base
import
Oracles.Flag
(
when
)
import
Oracles.Builder
import
Targets
import
Switches
import
Util
packageSettings
::
Settings
packageSettings
=
msum
[
args
[
"-hide-all-packages"
,
"-no-user-package-db"
,
"-include-pkg-deps"
]
,
stage
Stage0
?
(
arg
"-package-db"
|>
argPath
"libraries/bootstrapping.conf"
)
,
supportsPackageKey
?
notStage
Stage0
??
(
argPairs
"-this-package-key"
argPackageKey
<|>
argPairs
"-package-key"
argPackageDepKeys
,
argPairs
"-package-name"
argPackageKey
<|>
argPairs
"-package"
argPackageDeps
)]
ghcArgs
::
Settings
ghcArgs
=
let
pathDist
=
path
</>
dist
buildDir
=
unifyPath
$
pathDist
</>
"build"
depFile
=
buildDir
</>
"haskell.deps"
in
msum
[
arg
"-M"
,
packageSettings
,
includeGhcArgs
path
dist
,
concatArgs
[
"-optP"
]
$
CppArgs
pathDist
,
productArgs
[
"-odir"
,
"-stubdir"
,
"-hidir"
]
[
buildDir
]
,
args
[
"-dep-makefile"
,
depFile
]
,
productArgs
[
"-dep-suffix"
]
$
map
wayPrefix
<$>
ways
settings
,
args
$
HsArgs
pathDist
,
args
$
pkgHsSources
path
dist
]
-- $1_$2_$3_ALL_CC_OPTS = \
-- $$(WAY_$3_CC_OPTS) \
-- $$($1_$2_DIST_GCC_CC_OPTS) \
-- $$($1_$2_$3_CC_OPTS) \
-- $$($$(basename $$<)_CC_OPTS) \
-- $$($1_$2_EXTRA_CC_OPTS) \
-- $$(EXTRA_CC_OPTS)
--
-- $1_$2_DIST_CC_OPTS = \
-- $$(SRC_CC_OPTS) \
-- $$($1_CC_OPTS) \
-- -I$1/$2/build/autogen \
-- $$(foreach dir,$$(filter-out /%,$$($1_$2_INCLUDE_DIRS)),-I$1/$$(dir)) \
-- $$(foreach dir,$$(filter /%,$$($1_$2_INCLUDE_DIRS)),-I$$(dir)) \
-- $$($1_$2_CC_OPTS) \
-- $$($1_$2_CPP_OPTS) \
-- $$($1_$2_CC_INC_FLAGS) \
-- $$($1_$2_DEP_CC_OPTS) \
-- $$(SRC_CC_WARNING_OPTS)
-- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
gccArgs
::
FilePath
->
Package
->
TodoItem
->
Args
gccArgs
sourceFile
(
Package
_
path
_
_
)
(
stage
,
dist
,
settings
)
=
let
pathDist
=
path
</>
dist
buildDir
=
pathDist
</>
"build"
depFile
=
buildDir
</>
takeFileName
sourceFile
<.>
"deps"
in
args
[
args
[
"-E"
,
"-MM"
]
-- TODO: add a Cpp Builder instead
,
args
$
CcArgs
pathDist
,
commonCcArgs
-- TODO: remove?
,
customCcArgs
settings
-- TODO: Replace by customCppArgs?
,
commonCcWarninigArgs
-- TODO: remove?
,
includeGccArgs
path
dist
,
args
[
"-MF"
,
unifyPath
depFile
]
,
args
[
"-x"
,
"c"
]
,
arg
$
unifyPath
sourceFile
]
buildRule
::
Package
->
TodoItem
->
Rules
()
buildRule
pkg
@
(
Package
name
path
_
_
)
todo
@
(
stage
,
dist
,
settings
)
=
do
let
pathDist
=
path
</>
dist
buildDir
=
pathDist
</>
"build"
(
buildDir
</>
"haskell.deps"
)
%>
\
_
->
do
run
(
Ghc
stage
)
$
ghcArgs
pkg
todo
-- Finally, record the argument list
need
[
argListPath
argListDir
pkg
stage
]
(
buildDir
</>
"c.deps"
)
%>
\
out
->
do
srcs
<-
args
$
CSrcs
pathDist
deps
<-
fmap
concat
$
forM
srcs
$
\
src
->
do
let
srcPath
=
path
</>
src
depFile
=
buildDir
</>
takeFileName
src
<.>
"deps"
run
(
Gcc
stage
)
$
gccArgs
srcPath
pkg
todo
liftIO
$
readFile
depFile
writeFileChanged
out
deps
liftIO
$
removeFiles
buildDir
[
"*.c.deps"
]
-- Finally, record the argument list
need
[
argListPath
argListDir
pkg
stage
]
argListRule
::
Package
->
TodoItem
->
Rules
()
argListRule
pkg
todo
@
(
stage
,
_
,
_
)
=
(
argListPath
argListDir
pkg
stage
)
%>
\
out
->
do
need
$
[
"shake/src/Package/Dependencies.hs"
]
++
sourceDependecies
ghcList
<-
argList
(
Ghc
stage
)
$
ghcArgs
pkg
todo
gccList
<-
argList
(
Gcc
stage
)
$
gccArgs
"source.c"
pkg
todo
writeFileChanged
out
$
ghcList
++
"
\n
"
++
gccList
buildPackageDependencies
::
Package
->
TodoItem
->
Rules
()
buildPackageDependencies
=
argListRule
<>
buildRule
-- Build package-data.mk by using GhcCabal to process pkgCabal file
buildPackageData
::
Stage
->
Package
->
FilePath
->
Ways
->
Settings
->
Rules
()
buildPackageData
stage
pkg
dir
ways
settings
=
(
dir
</>
)
<$>
[
"package-data.mk"
,
"haddock-prologue.txt"
,
"inplace-pkg-config"
,
"setup-config"
,
"build"
</>
"autogen"
</>
"cabal_macros.h"
-- TODO: Is this needed? Also check out Paths_cpsa.hs.
-- , "build" </> "autogen" </> ("Paths_" ++ name) <.> "hs"
]
&%>
\
_
->
do
let
configure
=
pkgPath
pkg
</>
"configure"
need
[
pkgPath
pkg
</>
pkgCabal
pkg
]
-- GhcCabal will run the configure script, so we depend on it
-- We still don't know who build the configure script from configure.ac
when
(
doesFileExist
$
configure
<.>
"ac"
)
$
need
[
configure
]
run'
GhcCabal
settings
-- TODO: when (registerPackage settings) $
run'
(
GhcPkg
stage
)
settings
postProcessPackageData
$
dir
</>
"package-data.mk"
run'
::
Builder
->
Settings
->
Action
()
run'
builder
settings
=
do
settings'
<-
evaluate
(
project
builder
settings
)
case
fromSettings
settings'
of
Nothing
->
redError
$
"Cannot determine "
++
show
builder
++
" settings."
Just
args
->
do
putColoured
Green
(
show
args
)
run
builder
args
--buildRule :: Package -> TodoItem -> Rules ()
--buildRule pkg @ (Package name path cabal _) todo @ (stage, dist, settings) =
-- let pathDist = path </> dist
-- cabalPath = path </> cabal
-- configure = path </> "configure"
-- in
-- -- All these files are produced by a single run of GhcCabal
-- (pathDist </>) <$>
-- [ "package-data.mk"
-- , "haddock-prologue.txt"
-- , "inplace-pkg-config"
-- , "setup-config"
-- , "build" </> "autogen" </> "cabal_macros.h"
-- -- TODO: Is this needed? Also check out Paths_cpsa.hs.
-- -- , "build" </> "autogen" </> ("Paths_" ++ name) <.> "hs"
-- ] &%> \_ -> do
-- need [cabalPath]
-- when (doesFileExist $ configure <.> "ac") $ need [configure]
-- -- GhcCabal will run the configure script, so we depend on it
-- -- We still don't know who build the configure script from configure.ac
-- run GhcCabal $ cabalArgs pkg todo
-- when (registerPackage settings) $
-- run (GhcPkg stage) $ ghcPkgArgs pkg todo
-- postProcessPackageData $ pathDist </> "package-data.mk"
ccSettings
::
Settings
ccSettings
=
msum
[
package
integerLibrary
?
argPath
"-Ilibraries/integer-gmp2/gmp"
,
builder
GhcCabal
?
argStagedConfig
"conf-cc-args"
,
validating
?
msum
[
not
(
builder
GhcCabal
)
?
arg
"-Werror"
,
arg
"-Wall"
,
gccIsClang
??
(
arg
"-Wno-unknown-pragmas"
<|>
not
gccLt46
?
windowsHost
?
arg
"-Werror=unused-but-set-variable"
,
not
gccLt46
?
arg
"-Wno-error=inline"
)]]
ldSettings
::
Settings
ldSettings
=
builder
GhcCabal
?
argStagedConfig
"conf-gcc-linker-args"
cppSettings
::
Settings
cppSettings
=
builder
GhcCabal
?
argStagedConfig
"conf-cpp-args"
import
Builder
import
Package
import
Expression
import
qualified
Target
import
Oracles.PackageData
import
Settings.TargetDirectory
import
Rules.Actions
import
Development.Shake
buildPackageDependencies
::
StagePackageTarget
->
Rules
()
buildPackageDependencies
target
=
let
stage
=
Target
.
stage
target
pkg
=
Target
.
package
target
path
=
targetPath
stage
pkg
buildPath
=
path
-/-
"build"
in
do
(
buildPath
-/-
"haskell.deps"
)
%>
\
file
->
build
$
fullTarget
target
[
file
]
(
GhcM
stage
)
(
buildPath
-/-
"c.deps"
)
%>
\
file
->
do
srcs
<-
pkgDataList
$
CSrcs
path
deps
<-
fmap
concat
$
forM
srcs
$
\
src
->
do
build
$
fullTarget
target
[
pkgPath
pkg
-/-
src
]
(
GccM
stage
)
liftIO
$
readFile
(
buildPath
-/-
takeFileName
src
<.>
"deps"
)
writeFileChanged
file
deps
liftIO
$
removeFiles
path
[
"*.c.deps"
]
src/Rules/Package.hs
View file @
65b298b0
...
...
@@ -2,9 +2,10 @@ module Rules.Package (
buildPackage
)
where
import
Rules.Data
import
Expression
import
Rules.Data
import
Rules.Dependencies
import
Development.Shake
buildPackage
::
StagePackageTarget
->
Rules
()
buildPackage
=
buildPackageData
buildPackage
=
buildPackageData
<>
buildPackageDependencies
src/Settings/Args.hs
View file @
65b298b0
...
...
@@ -4,6 +4,7 @@ module Settings.Args (
import
Settings.User
import
Settings.GhcM
import
Settings.GccM
import
Settings.GhcPkg
import
Settings.GhcCabal
import
Expression
...
...
@@ -18,4 +19,5 @@ defaultArgs = mconcat
[
cabalArgs
,
ghcPkgArgs
,
ghcMArgs
,
gccMArgs
,
customPackageArgs
]
src/Settings/GccM.hs
0 → 100644
View file @
65b298b0
module
Settings.GccM
(
gccMArgs
)
where
import
Util
import
Builder
import
Package
import
Expression
import
Oracles.PackageData
import
Settings.Util
import
Settings.TargetDirectory
-- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
gccMArgs
::
Args
gccMArgs
=
do
stage
<-
getStage
builder
(
GccM
stage
)
?
do
pkg
<-
getPackage
files
<-
getFiles
ccArgs
<-
getPkgDataList
CcArgs
let
file
=
head
files
path
=
targetPath
stage
pkg
-/-
"build"
mconcat
[
arg
"-E"
,
arg
"-MM"
,
append
ccArgs
-- TODO: remove? any other flags?
,
includeGccArgs
,
arg
"-MF"
,
arg
$
path
-/-
takeFileName
file
<.>
"deps"
,
arg
"-x"
,
arg
"c"
,
arg
file
]
includeGccArgs
::
Args
includeGccArgs
=
do
stage
<-
getStage
pkg
<-
getPackage
incDirs
<-
getPkgDataList
IncludeDirs
depIncDirs
<-
getPkgDataList
DepIncludeDirs
let
path
=
pkgPath
pkg
mconcat
[
arg
$
"-I"
++
targetPath
stage
pkg
-/-
"build/autogen"
,
append
.
map
(
\
dir
->
"-I"
++
path
-/-
dir
)
$
incDirs
++
depIncDirs
]
src/Settings/GhcM.hs
View file @
65b298b0
...
...
@@ -29,11 +29,11 @@ ghcMArgs = do
,
packageGhcArgs
,
includeGhcArgs
,
append
.
map
(
"-optP"
++
)
$
cppArgs
,
arg
$
"-odir
"
++
buildPath
,
arg
$
"-stubdir
"
++
buildPath
,
arg
$
"-hidir
"
++
buildPath
,
arg
$
"-dep-makefile
"
++
buildPath
-/-
"haskell.deps"
,
append
.
m
ap
(
\
way
->
"-dep-suffix
"
++
wayPrefix
way
)
$
ways
,
arg
"-odir
"
,
arg
buildPath
,
arg
"-stubdir
"
,
arg
buildPath
,
arg
"-hidir"
,
arg
buildPath
,
arg
"-dep-makefile
"
,
arg
$
buildPath
-/-
"haskell.deps"
,
append
.
concatM
ap
(
\
way
->
[
"-dep-suffix
"
,
wayPrefix
way
]
)
$
ways
,
append
hsArgs
,
append
hsSrcs
]
...
...
@@ -57,10 +57,10 @@ packageGhcArgs = do
includeGhcArgs
::
Args
includeGhcArgs
=
do
stage
<-
getStage
pkg
<-
getPackage
srcDirs
<-
getPkgDataList
SrcDirs
inc
lude
Dirs
<-
getPkgDataList
IncludeDirs
stage
<-
getStage
pkg
<-
getPackage
srcDirs
<-
getPkgDataList
SrcDirs
incDirs
<-
getPkgDataList
IncludeDirs
let
buildPath
=
targetPath
stage
pkg
-/-
"build"
autogenPath
=
buildPath
-/-
"autogen"
mconcat
...
...
@@ -70,7 +70,7 @@ includeGhcArgs = do
,
arg
$
"-i"
++
autogenPath
,
arg
$
"-I"
++
buildPath
,
arg
$
"-I"
++
autogenPath
,
append
.
map
(
\
dir
->
"-I"
++
pkgPath
pkg
-/-
dir
)
$
inc
lude
Dirs
,
append
.
map
(
\
dir
->
"-I"
++
pkgPath
pkg
-/-
dir
)
$
incDirs
,
arg
"-optP-include"
-- TODO: Shall we also add -cpp?
,
arg
$
"-optP"
++
autogenPath
-/-
"cabal_macros.h"
]
...
...
@@ -79,80 +79,16 @@ getHsSources = do
stage
<-
getStage
pkg
<-
getPackage
srcDirs
<-
getPkgDataList
SrcDirs
let
autogen
Path
=
targetPath
stage
pkg
-/-
"build/autogen"
dirs
=
autogen
Path
:
map
(
pkgPath
pkg
-/-
)
srcDirs
get
Modul
eFiles
dir
s
[
".hs"
,
".lhs"
]
let
autogen
=
targetPath
stage
pkg
-/-
"build/autogen"
paths
=
autogen
:
map
(
pkgPath
pkg
-/-
)
srcDirs
get
Sourc
eFiles
path
s
[
".hs"
,
".lhs"
]
getModuleFiles
::
[
FilePath
]
->
[
String
]
->
Expr
[
FilePath
]
getModuleFiles
directories
suffixes
=
do
-- Find all source files in specified paths and with given extensions
getSourceFiles
::
[
FilePath
]
->
[
String
]
->
Expr
[
FilePath
]
getSourceFiles
paths
exts
=
do
modules
<-
getPkgDataList
Modules
let
modPaths
=
map
(
replaceEq
'.'
pathSeparator
)
modules
files
<-
lift
$
forM
[
dir
-/-
modPath
++
suffix
|
dir
<-
directories
,
modPath
<-
modPaths
,
suffix
<-
suffixes
]
$
\
file
->
do
let
dir
=
takeDirectory
file
dirExists
<-
doesDirectoryExist
dir
return
[
unifyPath
file
|
dirExists
]
result
<-
lift
$
getDirectoryFiles
""
(
concat
files
)
let
modPaths
=
map
(
replaceEq
'.'
'/'
)
modules
candidates
=
[
p
-/-
m
++
e
|
p
<-
paths
,
m
<-
modPaths
,
e
<-
exts
]
files
<-
lift
$
filterM
(
doesDirectoryExist
.
takeDirectory
)
candidates
result
<-
lift
$
getDirectoryFiles
""
files
return
$
map
unifyPath
result
-- $1_$2_$3_ALL_CC_OPTS = \
-- $$(WAY_$3_CC_OPTS) \
-- $$($1_$2_DIST_GCC_CC_OPTS) \
-- $$($1_$2_$3_CC_OPTS) \
-- $$($$(basename $$<)_CC_OPTS) \
-- $$($1_$2_EXTRA_CC_OPTS) \
-- $$(EXTRA_CC_OPTS)
--
-- $1_$2_DIST_CC_OPTS = \
-- $$(SRC_CC_OPTS) \
-- $$($1_CC_OPTS) \
-- -I$1/$2/build/autogen \
-- $$(foreach dir,$$(filter-out /%,$$($1_$2_INCLUDE_DIRS)),-I$1/$$(dir)) \
-- $$(foreach dir,$$(filter /%,$$($1_$2_INCLUDE_DIRS)),-I$$(dir)) \
-- $$($1_$2_CC_OPTS) \
-- $$($1_$2_CPP_OPTS) \
-- $$($1_$2_CC_INC_FLAGS) \
-- $$($1_$2_DEP_CC_OPTS) \
-- $$(SRC_CC_WARNING_OPTS)
-- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
-- gccArgs :: FilePath -> Package -> TodoItem -> Args
-- gccArgs sourceFile (Package _ path _ _) (stage, dist, settings) =
-- let pathDist = path </> dist
-- buildDir = pathDist </> "build"
-- depFile = buildDir </> takeFileName sourceFile <.> "deps"
-- in args [ args ["-E", "-MM"] -- TODO: add a Cpp Builder instead
-- , args $ CcArgs pathDist
-- , commonCcArgs -- TODO: remove?
-- , customCcArgs settings -- TODO: Replace by customCppArgs?
-- , commonCcWarninigArgs -- TODO: remove?
-- , includeGccArgs path dist
-- , args ["-MF", unifyPath depFile]
-- , args ["-x", "c"]
-- , arg $ unifyPath sourceFile ]
-- buildRule :: Package -> TodoItem -> Rules ()
-- buildRule pkg @ (Package name path _ _) todo @ (stage, dist, settings) = do
-- let pathDist = path </> dist
-- buildDir = pathDist </> "build"
-- (buildDir </> "haskell.deps") %> \_ -> do
-- run (Ghc stage) $ ghcArgs pkg todo
-- -- Finally, record the argument list
-- need [argListPath argListDir pkg stage]
-- (buildDir </> "c.deps") %> \out -> do
-- srcs <- args $ CSrcs pathDist
-- deps <- fmap concat $ forM srcs $ \src -> do
-- let srcPath = path </> src
-- depFile = buildDir </> takeFileName src <.> "deps"
-- run (Gcc stage) $ gccArgs srcPath pkg todo
-- liftIO $ readFile depFile
-- writeFileChanged out deps
-- liftIO $ removeFiles buildDir ["*.c.deps"]
-- -- Finally, record the argument list
-- need [argListPath argListDir pkg stage]
src/Settings/GhcPkg.hs
View file @
65b298b0
module
Settings.GhcPkg
(
ghcPkgArgs
)
where
module
Settings.GhcPkg
(
ghcPkgArgs
)
where
import
Util
import
Builder
...
...
src/Settings/User.hs
View file @
65b298b0
...
...
@@ -17,7 +17,7 @@ userArgs = mempty
-- Control which packages get to be built
userPackages
::
Packages
userPackages
=
mempty
userPackages
=
remove
[
compiler
]
-- TODO: fix compiler
-- Add new user-defined packages
userKnownPackages
::
[
Package
]
...
...
src/Settings/Util.hs
View file @
65b298b0
...
...
@@ -61,9 +61,10 @@ getPkgDataList key = do
appendCcArgs
::
[
String
]
->
Args
appendCcArgs
xs
=
do
stage
<-
getStage
mconcat
[
builder
(
Gcc
stage
)
?
append
xs
,
builder
GhcCabal
?
appendSub
"--configure-option=CFLAGS"
xs
,
builder
GhcCabal
?
appendSub
"--gcc-options"
xs
]
mconcat
[
builder
(
Gcc
stage
)
?
append
xs
,
builder
(
GccM
stage
)
?
append
xs
,
builder
GhcCabal
?
appendSub
"--configure-option=CFLAGS"
xs
,
builder
GhcCabal
?
appendSub
"--gcc-options"
xs
]
-- Make sure a builder exists on the given path and rebuild it if out of date.
-- If laxDependencies is true (Settings/User.hs) then we do not rebuild GHC
...
...
@@ -77,58 +78,6 @@ needBuilder builder = do
path
<-
builderPath
builder
need
[
path
]
-- packageData :: Arity -> String -> Args
-- packageData arity key =
-- return $ EnvironmentParameter $ PackageData arity key Nothing Nothing
-- -- Accessing key value pairs from package-data.mk files
-- argPackageKey :: Args