Commit 5603275f authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Refactor imports, add comments.

parent aff7b3c9
......@@ -9,6 +9,7 @@ module Expression (
Expr, DiffExpr, fromDiffExpr,
Predicate, (?), applyPredicate,
Args, Ways, Packages,
Target, PartialTarget (..), fromPartial, fullTarget, fullTargetWithWay,
apply, append, appendM, remove,
appendSub, appendSubD, filterSub, removeSub,
interpret, interpretPartial, interpretWithStage, interpretDiff,
......@@ -21,7 +22,7 @@ import Builder
import Control.Monad.Reader
import Package
import Stage
import Target (Target (..), PartialTarget (..), fromPartial)
import Target
import Way
-- Expr a is a computation that produces a value of type Action a and can read
......@@ -86,10 +87,6 @@ instance PredicateLike Bool where
instance PredicateLike (Action Bool) where
(?) = applyPredicate . lift
-- An equivalent of if-then-else for predicates
-- (??) :: (PredicateLike a, Monoid m) => a -> (Expr m, Expr m) -> Expr m
-- p ?? (t, f) = p ? t <> notP p ? f
-- A monadic version of append
appendM :: Monoid a => Action a -> DiffExpr a
appendM = (append =<<) . lift
......
......@@ -7,10 +7,10 @@ module GHC (
defaultKnownPackages, defaultTargetDirectory
) where
import Stage
import Package
import Stage
-- These are all packages we know about. Build rules will be generated for
-- These are all GHC packages we know about. Build rules will be generated for
-- all of them. However, not all of these packages will be built. For example,
-- package 'win32' is built only on Windows.
-- Settings/Packages.hs defines default conditions for building each package,
......@@ -58,11 +58,12 @@ unix = library "unix"
win32 = library "Win32"
xhtml = library "xhtml"
-- Build results will be placed into a target directory with the following
-- GHC build results will be placed into target directories with the following
-- typical structure:
-- * build/ : contains compiled object code
-- * doc/ : produced by haddock
-- * package-data.mk : contains output of ghc-cabal applied to pkgCabal
-- * build/ : contains compiled object code
-- * doc/ : produced by haddock
-- * package-data.mk : contains output of ghc-cabal applied to pkgCabal
-- TODO: simplify to just 'show stage'?
defaultTargetDirectory :: Stage -> Package -> FilePath
defaultTargetDirectory stage package
| package == compiler = "stage" ++ show (fromEnum stage + 1)
......
......@@ -5,9 +5,9 @@ import Rules.Config
import Rules.Oracles
main :: IO ()
main = shakeArgs shakeOptions{shakeFiles = shakeFilesPath} $ do
generateTargets -- see module Rules
packageRules -- see module Rules
cabalRules -- see module Rules.Cabal
configRules -- see module Rules.Config
oracleRules -- see module Rules.Oracles
main = shakeArgs shakeOptions { shakeFiles = shakeFilesPath } $ do
generateTargets -- see Rules
packageRules -- see Rules
cabalRules -- see Rules.Cabal
configRules -- see Rules.Config
oracleRules -- see Rules.Oracles
{-# LANGUAGE DeriveGeneric #-}
module Package (
Package (..), PackageName, pkgCabalFile, setPath,
library, topLevel
Package (..), PackageName, pkgCabalFile, setPath, library, topLevel
) where
import Base
......@@ -22,15 +21,6 @@ data Package = Package
pkgCabalFile :: Package -> FilePath
pkgCabalFile pkg = pkgPath pkg -/- pkgName pkg <.> "cabal"
instance Show Package where
show = pkgName
instance Eq Package where
(==) = (==) `on` pkgName
instance Ord Package where
compare = compare `on` pkgName
library :: PackageName -> Package
library name = Package name ("libraries" -/- name)
......@@ -40,6 +30,15 @@ topLevel name = Package name name
setPath :: Package -> FilePath -> Package
setPath pkg path = pkg { pkgPath = path }
instance Show Package where
show = pkgName
instance Eq Package where
(==) = (==) `on` pkgName
instance Ord Package where
compare = compare `on` pkgName
-- Instances for storing in the Shake database
instance Binary Package
instance Hashable Package where
......
module Rules (generateTargets, packageRules) where
import Expression
import Oracles.PackageData
import Oracles
import Rules.Package
import Rules.Resources
import Settings
import Target (PartialTarget (..))
-- generateTargets needs top-level build targets
generateTargets :: Rules ()
......
module Rules.Actions (build, buildWithResources) where
import Target hiding (builder)
import qualified Target
import Builder
import Expression
import Oracles
import Oracles.ArgsHash
import Settings
import Settings.Args
import qualified Target
-- Build a given target using an appropriate builder and acquiring necessary
-- resources. Force a rebuilt if the argument list has changed since the last
......
module Rules.Cabal (cabalRules) where
import Stage
import Package hiding (library)
import Expression
import Settings
import Data.Version
import Distribution.Package
import Distribution.Verbosity
import Distribution.PackageDescription
import Distribution.PackageDescription.Parse
import Expression
import Package hiding (library)
import Settings
cabalRules :: Rules ()
cabalRules = do
......
module Rules.Compile (compilePackage) where
import Way
import Base
import Builder
import Target (PartialTarget (..), fullTarget, fullTargetWithWay)
import Oracles.Dependencies
import Settings
import Expression
import Oracles
import Rules.Actions
import Rules.Resources
import Settings
compilePackage :: Resources -> PartialTarget -> Rules ()
compilePackage _ target @ (PartialTarget stage package) = do
......
module Rules.Data (buildPackageData) where
import Target (PartialTarget (..), fullTarget)
import Package
import Builder
import Expression
import Predicates (registerPackage)
import Oracles
import Settings
import Predicates (registerPackage)
import Rules.Actions
import Rules.Resources
import Settings
-- Build package-data.mk by using GhcCabal to process pkgCabal file
buildPackageData :: Resources -> PartialTarget -> Rules ()
......
module Rules.Dependencies (buildPackageDependencies) where
import Builder
import Package
import Expression
import Target (PartialTarget (..), fullTarget)
import Oracles.PackageData
import Settings
import Oracles
import Rules.Actions
import Rules.Resources
import Settings
buildPackageDependencies :: Resources -> PartialTarget -> Rules ()
buildPackageDependencies _ target @ (PartialTarget stage pkg) =
......
module Rules.Documentation (buildPackageDocumentation) where
import Way
import Stage
import Builder
import Package
import Expression
import Oracles.PackageData
import Target (PartialTarget (..), fullTarget, fullTargetWithWay)
import Oracles
import Rules.Actions
import Rules.Resources
import Settings
......
module Rules.Library (buildPackageLibrary) where
import Expression hiding (splitPath)
import Oracles.PackageData
import Oracles
import Predicates (splitObjects)
import Rules.Actions
import Rules.Resources
import Settings
import qualified System.Directory as IO
import Target (PartialTarget (..), fullTarget)
buildPackageLibrary :: Resources -> PartialTarget -> Rules ()
buildPackageLibrary _ target @ (PartialTarget stage pkg) = do
......
{-# LANGUAGE DeriveGeneric, FlexibleInstances #-}
module Target (
Target (..), PartialTarget (..),
fromPartial, fullTarget, fullTargetWithWay
Target (..), PartialTarget (..), fromPartial, fullTarget, fullTargetWithWay
) where
import Base
......
......@@ -17,6 +17,8 @@ import Data.IntSet (IntSet)
import qualified Data.IntSet as Set
import Oracles
-- Note: order of constructors is important for compatibility with the old build
-- system, e.g. we want "thr_p", not "p_thr" (see instance Show Way).
data WayUnit = Threaded
| Debug
| Profiling
......
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