Commit 1ac1688f authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Create Settings/Builders/ directory for keeping builder-related settings.

parent c1b296ab
......@@ -2,10 +2,12 @@ module Settings.Args (args, getArgs) where
import Expression
import Settings.User
import Settings.GhcM
import Settings.GccM
import Settings.GhcPkg
import Settings.GhcCabal
import Settings.Builders.Ar
import Settings.Builders.Ld
import Settings.Builders.Ghc
import Settings.Builders.Gcc
import Settings.Builders.GhcPkg
import Settings.Builders.GhcCabal
args :: Args
args = defaultArgs <> userArgs
......@@ -28,4 +30,8 @@ defaultArgs = mconcat
, ghcPkgArgs
, ghcMArgs
, gccMArgs
, ghcArgs
, gccArgs
, arArgs
, ldArgs
, customPackageArgs ]
module Settings.Builders.Ar (arArgs, arPersistentArgsCount) where
import Builder
import Expression
import Settings.Util
arArgs :: Args
arArgs = builder Ar ? do
objs <- getDependencies
file <- getFile
mconcat [ arg "q"
, arg file
, append objs ]
-- This count includes arg "q" and arg file parameters in arArgs (see above).
-- Update this value appropriately when changing arArgs.
arPersistentArgsCount :: Int
arPersistentArgsCount = 2
module Settings.Gcc (gccArgs, includeGccArgs) where
module Settings.Builders.Gcc (gccArgs, gccMArgs) where
import Base
import Util
......@@ -7,6 +7,7 @@ import Expression
import Oracles.PackageData
import Settings.Util
-- TODO: check code duplication
gccArgs :: Args
gccArgs = stagedBuilder Gcc ? do
path <- getTargetPath
......@@ -20,6 +21,24 @@ gccArgs = stagedBuilder Gcc ? do
, arg "-o"
, arg file ]
-- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
gccMArgs :: Args
gccMArgs = stagedBuilder GccM ? do
path <- getTargetPath
file <- getFile
src <- getDependency
ccArgs <- getPkgDataList CcArgs
mconcat
[ arg "-E"
, arg "-MM"
, append ccArgs -- TODO: remove? any other flags?
, includeGccArgs
, arg "-MF"
, arg file
, arg "-x"
, arg "c"
, arg src ]
includeGccArgs :: Args
includeGccArgs = do
path <- getTargetPath
......
module Settings.Ghc (ghcArgs, packageGhcArgs, includeGhcArgs) where
module Settings.Builders.Ghc (ghcArgs, ghcMArgs) where
import Way
import Util
......@@ -9,7 +9,9 @@ import Expression
import Oracles.Flag
import Oracles.PackageData
import Settings.Util
import Settings.Ways
-- TODO: check code duplication
ghcArgs :: Args
ghcArgs = stagedBuilder Ghc ? do
way <- getWay
......@@ -37,6 +39,29 @@ ghcArgs = stagedBuilder Ghc ? do
, arg "-c", append srcs
, arg "-o", arg file ]
ghcMArgs :: Args
ghcMArgs = stagedBuilder GhcM ? do
ways <- getWays
hsSrcs <- getHsSources
hsArgs <- getPkgDataList HsArgs
cppArgs <- getPkgDataList CppArgs
path <- getTargetPath
let buildPath = path -/- "build"
mconcat
[ arg "-M"
, packageGhcArgs
, includeGhcArgs
, append hsArgs
, append . map ("-optP" ++) $ cppArgs
, arg "-odir" , arg buildPath
, arg "-stubdir" , arg buildPath
, arg "-hidir" , arg buildPath
, arg "-dep-makefile", arg $ buildPath -/- "haskell.deps"
, append . concatMap (\way -> ["-dep-suffix", wayPrefix way]) $ ways
, arg "-no-user-package-db" -- TODO: is this needed?
, arg "-rtsopts" -- TODO: is this needed?
, append hsSrcs ]
-- TODO: do '-ticky' in all debug ways?
wayHcArgs :: Args
wayHcArgs = do
......
module Settings.GhcCabal (
module Settings.Builders.GhcCabal (
cabalArgs, bootPackageDbArgs, customPackageArgs
) where
......
module Settings.GhcPkg (ghcPkgArgs) where
module Settings.Builders.GhcPkg (ghcPkgArgs) where
import Util
import Builder
import Switches
import Expression
import Settings.Util
import Settings.GhcCabal
import Settings.Builders.GhcCabal
ghcPkgArgs :: Args
ghcPkgArgs = stagedBuilder GhcPkg ? do
......
module Settings.Builders.Ld (ldArgs) where
import Builder
import Expression
import Oracles.Setting
import Settings.Util
ldArgs :: Args
ldArgs = builder Ld ? do
stage <- getStage
objs <- getDependencies
file <- getFile
confArgs <- getSettingList $ ConfLdLinkerArgs stage
mconcat [ append confArgs
, arg "-r"
, arg "-o"
, arg file
, append objs ]
module Settings.GccM (gccMArgs) where
import Builder
import Expression
import Oracles.PackageData
import Settings.Gcc
import Settings.Util
-- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
gccMArgs :: Args
gccMArgs = stagedBuilder GccM ? do
path <- getTargetPath
file <- getFile
src <- getDependency
ccArgs <- getPkgDataList CcArgs
mconcat
[ arg "-E"
, arg "-MM"
, append ccArgs -- TODO: remove? any other flags?
, includeGccArgs
, arg "-MF"
, arg file
, arg "-x"
, arg "c"
, arg src ]
module Settings.GhcM (ghcMArgs) where
import Way
import Util
import Builder
import Expression
import Oracles.PackageData
import Settings.Ghc
import Settings.Util
import Settings.Ways
ghcMArgs :: Args
ghcMArgs = stagedBuilder GhcM ? do
ways <- getWays
hsSrcs <- getHsSources
hsArgs <- getPkgDataList HsArgs
cppArgs <- getPkgDataList CppArgs
path <- getTargetPath
let buildPath = path -/- "build"
mconcat
[ arg "-M"
, packageGhcArgs
, includeGhcArgs
, append hsArgs
, append . map ("-optP" ++) $ cppArgs
, arg "-odir" , arg buildPath
, arg "-stubdir" , arg buildPath
, arg "-hidir" , arg buildPath
, arg "-dep-makefile", arg $ buildPath -/- "haskell.deps"
, append . concatMap (\way -> ["-dep-suffix", wayPrefix way]) $ ways
, arg "-no-user-package-db" -- TODO: is this needed?
, arg "-rtsopts" -- TODO: is this needed?
, append hsSrcs ]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment