Commit caf0d6a6 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Add predicate input, rename predicate file to output.

See #245.
parent 7239000f
{-# LANGUAGE LambdaCase, FlexibleInstances #-}
-- | Convenient predicates
module Predicates (
stage, package, builder, file, way, stage0, stage1, stage2, notStage0, notPackage
stage, stage0, stage1, stage2, notStage0,
package, notPackage, builder, input, output, way
) where
import Base
......@@ -41,9 +42,13 @@ instance BuilderLike a => BuilderLike (FilePath -> a) where
Configure f -> builder $ f2b f
_ -> return False
-- | Does any of the input files match a given pattern?
input :: FilePattern -> Predicate
input f = any (f ?==) <$> getInputs
-- | Does any of the output files match a given pattern?
file :: FilePattern -> Predicate
file f = any (f ?==) <$> getOutputs
output :: FilePattern -> Predicate
output f = any (f ?==) <$> getOutputs
-- | Is the current build 'Way' equal to a certain value?
way :: Way -> Predicate
......
......@@ -4,21 +4,21 @@ import Base
import Expression
import Oracles.Config.Flag
import Oracles.Config.Setting
import Predicates (builder, file)
import Predicates (builder, output)
import Settings.Builders.Common
-- TODO: do we need to support `includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT`?
deriveConstantsBuilderArgs :: Args
deriveConstantsBuilderArgs = builder DeriveConstants ? do
cFlags <- fromDiffExpr includeCcArgs
[output, tempDir] <- getOutputs
[outputFile, tempDir] <- getOutputs
mconcat
[ file "//DerivedConstants.h" ? arg "--gen-header"
, file "//GHCConstantsHaskellType.hs" ? arg "--gen-haskell-type"
, file "//platformConstants" ? arg "--gen-haskell-value"
, file "//GHCConstantsHaskellWrappers.hs" ? arg "--gen-haskell-wrappers"
, file "//GHCConstantsHaskellExports.hs" ? arg "--gen-haskell-exports"
, arg "-o", arg output
[ output "//DerivedConstants.h" ? arg "--gen-header"
, output "//GHCConstantsHaskellType.hs" ? arg "--gen-haskell-type"
, output "//platformConstants" ? arg "--gen-haskell-value"
, output "//GHCConstantsHaskellWrappers.hs" ? arg "--gen-haskell-wrappers"
, output "//GHCConstantsHaskellExports.hs" ? arg "--gen-haskell-exports"
, arg "-o", arg outputFile
, arg "--tmpdir", arg tempDir
, arg "--gcc-program", arg =<< getBuilderPath (Cc Compile Stage1)
, append . concat $ map (\a -> ["--gcc-flag", a]) cFlags
......
module Settings.Builders.GenPrimopCode (genPrimopCodeBuilderArgs) where
import Expression
import Predicates (builder, file)
import Predicates (builder, output)
-- Stdin/stdout are handled in a special way. See Rules/Actions.hs.
genPrimopCodeBuilderArgs :: Args
genPrimopCodeBuilderArgs = builder GenPrimopCode ? mconcat
[ file "//PrimopWrappers.hs" ? arg "--make-haskell-wrappers"
, file "//Prim.hs" ? arg "--make-haskell-source"
, file "//primop-data-decl.hs-incl" ? arg "--data-decl"
, file "//primop-tag.hs-incl" ? arg "--primop-tag"
, file "//primop-list.hs-incl" ? arg "--primop-list"
, file "//primop-has-side-effects.hs-incl" ? arg "--has-side-effects"
, file "//primop-out-of-line.hs-incl" ? arg "--out-of-line"
, file "//primop-commutable.hs-incl" ? arg "--commutable"
, file "//primop-code-size.hs-incl" ? arg "--code-size"
, file "//primop-can-fail.hs-incl" ? arg "--can-fail"
, file "//primop-strictness.hs-incl" ? arg "--strictness"
, file "//primop-fixity.hs-incl" ? arg "--fixity"
, file "//primop-primop-info.hs-incl" ? arg "--primop-primop-info"
, file "//primop-vector-uniques.hs-incl" ? arg "--primop-vector-uniques"
, file "//primop-vector-tys.hs-incl" ? arg "--primop-vector-tys"
, file "//primop-vector-tys-exports.hs-incl" ? arg "--primop-vector-tys-exports"
, file "//primop-vector-tycons.hs-incl" ? arg "--primop-vector-tycons"
, file "//primop-usage.hs-incl" ? arg "--usage" ]
[ output "//PrimopWrappers.hs" ? arg "--make-haskell-wrappers"
, output "//Prim.hs" ? arg "--make-haskell-source"
, output "//primop-data-decl.hs-incl" ? arg "--data-decl"
, output "//primop-tag.hs-incl" ? arg "--primop-tag"
, output "//primop-list.hs-incl" ? arg "--primop-list"
, output "//primop-has-side-effects.hs-incl" ? arg "--has-side-effects"
, output "//primop-out-of-line.hs-incl" ? arg "--out-of-line"
, output "//primop-commutable.hs-incl" ? arg "--commutable"
, output "//primop-code-size.hs-incl" ? arg "--code-size"
, output "//primop-can-fail.hs-incl" ? arg "--can-fail"
, output "//primop-strictness.hs-incl" ? arg "--strictness"
, output "//primop-fixity.hs-incl" ? arg "--fixity"
, output "//primop-primop-info.hs-incl" ? arg "--primop-primop-info"
, output "//primop-vector-uniques.hs-incl" ? arg "--primop-vector-uniques"
, output "//primop-vector-tys.hs-incl" ? arg "--primop-vector-tys"
, output "//primop-vector-tys-exports.hs-incl" ? arg "--primop-vector-tys-exports"
, output "//primop-vector-tycons.hs-incl" ? arg "--primop-vector-tycons"
, output "//primop-usage.hs-incl" ? arg "--usage" ]
......@@ -11,7 +11,7 @@ ghcPkgBuilderArgs :: Args
ghcPkgBuilderArgs = builder GhcPkg ? (initArgs <> updateArgs)
initPredicate :: Predicate
initPredicate = orM $ map (file . packageDbDirectory) [Stage0 ..]
initPredicate = orM $ map (output . packageDbDirectory) [Stage0 ..]
initArgs :: Args
initArgs = initPredicate ? do
......
......@@ -6,7 +6,7 @@ import GHC
import Package
import Expression
import Oracles.PackageData
import Predicates hiding (file)
import Predicates
import Settings
import Settings.Builders.Ghc
......
......@@ -7,7 +7,7 @@ import Expression
import GHC (rts, rtsContext)
import Oracles.Config.Flag
import Oracles.Config.Setting
import Predicates (builder, package, file)
import Predicates (builder, package, input)
import Settings
import Settings.Builders.Common
......@@ -66,10 +66,10 @@ rtsPackageArgs = package rts ? do
, way == threaded ? arg "-DTHREADED_RTS"
, (file "//RtsMessages.*" ||^ file "//Trace.*") ?
, (input "//RtsMessages.c" ||^ input "//Trace.c") ?
arg ("-DProjectVersion=" ++ quote projectVersion)
, file "//RtsUtils.*" ? append
, input "//RtsUtils.c" ? append
[ "-DProjectVersion=" ++ quote projectVersion
, "-DHostPlatform=" ++ quote hostPlatform
, "-DHostArch=" ++ quote hostArch
......@@ -86,11 +86,11 @@ rtsPackageArgs = package rts ? do
, "-DGhcUnregisterised=" ++ quote ghcUnreg
, "-DGhcEnableTablesNextToCode=" ++ quote ghcEnableTNC ]
, file "//Evac.*" ? arg "-funroll-loops"
, file "//Evac_thr.*" ? arg "-funroll-loops"
, input "//Evac.c" ? arg "-funroll-loops"
, input "//Evac_thr.c" ? arg "-funroll-loops"
, file "//Evac_thr.*" ? append [ "-DPARALLEL_GC", "-Irts/sm" ]
, file "//Scav_thr.*" ? append [ "-DPARALLEL_GC", "-Irts/sm" ] ]
, input "//Evac_thr.c" ? append [ "-DPARALLEL_GC", "-Irts/sm" ]
, input "//Scav_thr.c" ? append [ "-DPARALLEL_GC", "-Irts/sm" ] ]
, builder Ghc ? (arg "-Irts" <> includesArgs)
......
......@@ -3,11 +3,11 @@ module Settings.Packages.RunGhc (runGhcPackageArgs) where
import Expression
import GHC (runGhc)
import Oracles.Config.Setting
import Predicates (builder, file, package)
import Predicates (builder, input, package)
runGhcPackageArgs :: Args
runGhcPackageArgs = package runGhc ? do
version <- getSetting ProjectVersion
mconcat [ builder Ghc ?
file "//Main.*" ?
input "//Main.hs" ?
append ["-cpp", "-DVERSION=\"" ++ version ++ "\""] ]
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