Commit 0c9571aa authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Add Settings/Builders/Common.hs for storing common Args, refactor code.

parent f415ad1d
......@@ -8,7 +8,7 @@ import Predicates (registerPackage)
import Rules.Actions
import Rules.Resources
import Settings
import Settings.Builders.GhcCabal
import Settings.Builders.Common
-- Build package-data.mk by using GhcCabal to process pkgCabal file
buildPackageData :: Resources -> PartialTarget -> Rules ()
......@@ -42,9 +42,9 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
postProcessPackageData dataFile
-- TODO: PROGNAME was $(CrossCompilePrefix)hp2ps
-- TODO: code duplication around ghcIncludeDirs
priority 2.0 $ do
when (pkg == hp2ps) $ dataFile %> \mk -> do
includes <- interpretPartial target $ fromDiffExpr includesArgs
let prefix = "utils_hp2ps_stage" ++ show (fromEnum stage) ++ "_"
cSrcs = [ "AreaBelow.c", "Curves.c", "Error.c", "Main.c"
, "Reorder.c", "TopTwenty.c", "AuxFile.c"
......@@ -57,7 +57,7 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
, "INSTALL = YES"
, "INSTALL_INPLACE = YES"
, "DEP_EXTRA_LIBS = m"
, "CC_OPTS = " ++ unwords (map ("-I"++) ghcIncludeDirs) ]
, "CC_OPTS = " ++ unwords includes ]
writeFileChanged mk contents
putSuccess $ "| Successfully generated '" ++ mk ++ "'."
......
......@@ -26,15 +26,15 @@ arCmd path argList = do
fileArgs = drop arFlagsCount argList
if arSupportsAtFile
then useAtFile path flagArgs fileArgs
else useSuccessiveInvokations path flagArgs fileArgs
else useSuccessiveInvocations path flagArgs fileArgs
useAtFile :: FilePath -> [String] -> [String] -> Action ()
useAtFile path flagArgs fileArgs = withTempFile $ \tmp -> do
writeFile' tmp $ unwords fileArgs
cmd [path] flagArgs ('@' : tmp)
useSuccessiveInvokations :: FilePath -> [String] -> [String] -> Action ()
useSuccessiveInvokations path flagArgs fileArgs = do
useSuccessiveInvocations :: FilePath -> [String] -> [String] -> Action ()
useSuccessiveInvocations path flagArgs fileArgs = do
maxChunk <- cmdLineLengthLimit
forM_ (chunksOfSize maxChunk fileArgs) $ \argsChunk ->
unit . cmd [path] $ flagArgs ++ argsChunk
module Settings.Builders.Common (includesArgs) where
import Expression
includes :: [FilePath]
includes = [ "includes", "includes/dist-derivedconstants/header" ]
includesArgs :: Args
includesArgs = append $ map ("-I" ++) includes
......@@ -7,6 +7,7 @@ import Expression
import Oracles.Config.Flag
import Oracles.Config.Setting
import Predicates (builder, file)
import Settings.Builders.Common
import Settings.Builders.GhcCabal
derivedConstantsPath :: FilePath
......@@ -39,7 +40,7 @@ includeCcArgs = do
, ccWarnings
, append confCcArgs
, flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
, append $ map ("-I" ++) ghcIncludeDirs -- TODO: fix code duplication
, includesArgs
, arg "-Irts"
, notM ghcWithSMP ? arg "-DNOSMP"
, arg "-fcommon" ]
module Settings.Builders.GhcCabal (
cabalArgs, ghcCabalHsColourArgs, ghcIncludeDirs, bootPackageDbArgs,
cabalArgs, ghcCabalHsColourArgs, bootPackageDbArgs,
customPackageArgs, ccArgs, cppArgs, ccWarnings, argStagedSettingList, needDll0
) where
......@@ -14,6 +14,7 @@ import Stage
import Expression
import Predicates hiding (stage)
import Settings
import Settings.Builders.Common
cabalArgs :: Args
cabalArgs = builder GhcCabal ? do
......@@ -115,13 +116,8 @@ ccWarnings = do
ldArgs :: Args
ldArgs = mempty
ghcIncludeDirs :: [FilePath]
ghcIncludeDirs = [ "includes", "includes/dist"
, "includes/dist-derivedconstants/header"
, "includes/dist-ghcconstants/header" ]
cppArgs :: Args
cppArgs = append $ map ("-I" ++) ghcIncludeDirs
cppArgs = includesArgs
-- TODO: Is this needed?
-- ifeq "$(GMP_PREFER_FRAMEWORK)" "YES"
......
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