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

Refactor imports.

parent 134cac9a
module Base (
shakeFilesPath, configPath,
bootPackageConstraints, packageDependencies,
module Development.Shake,
module Development.Shake.Util,
module Development.Shake.Config,
module Development.Shake.Classes,
module Development.Shake.FilePath
module Development.Shake.Config,
module Development.Shake.FilePath,
module Development.Shake.Util,
shakeFilesPath, configPath, bootPackageConstraints, packageDependencies
) where
import Development.Shake
import Development.Shake.Util
import Development.Shake.Config
import Development.Shake hiding (unit)
import Development.Shake.Classes
import Development.Shake.Config
import Development.Shake.FilePath
import Development.Shake.Util
shakeFilesPath :: FilePath
shakeFilesPath = "_build/"
......
{-# LANGUAGE DeriveGeneric #-}
module Builder (
Builder (..), builderKey, builderPath, specified, needBuilder
) where
module Builder (Builder (..), builderPath, specified, needBuilder) where
import Base
import Util
import Stage
import Data.List
import GHC.Generics
import Oracles.Base
import Oracles.Setting
import Oracles.WindowsRoot
import GHC.Generics
import Stage
-- A Builder is an external command invoked in separate process using Shake.cmd
--
......
{-# LANGUAGE FlexibleInstances #-}
module Expression (
module Data.Monoid,
module Control.Monad.Reader,
module Builder,
module Package,
module Stage,
module Util,
module Way,
Expr, DiffExpr, fromDiffExpr,
Predicate, PredicateLike (..), applyPredicate, (??),
Predicate, (?), (??), notP, applyPredicate,
Args, Ways, Packages,
apply, append, appendM, remove,
appendSub, appendSubD, filterSub, removeSub,
......@@ -12,16 +16,14 @@ module Expression (
getSources, getSource, getWay
) where
import Way
import Base
import Util
import Stage
import Builder
import Control.Monad.Reader
import Package
import Stage
import Target (Target (..), PartialTarget (..), fromPartial)
import Data.List
import Data.Monoid
import Control.Monad.Reader hiding (liftIO)
import Util
import Way
-- Expr a is a computation that produces a value of type Action a and can read
-- parameters of the current build Target.
......@@ -119,7 +121,7 @@ appendSubD :: String -> Args -> Args
appendSubD prefix diffExpr = fromDiffExpr diffExpr >>= appendSub prefix
filterSub :: String -> (String -> Bool) -> Args
filterSub prefix p = apply . map $ filterSubstr
filterSub prefix p = apply $ map filterSubstr
where
filterSubstr s
| prefix `isPrefixOf` s = unwords . filter p . words $ s
......
import Base
import Rules
import Rules.Cabal
import Rules.Config
import Rules.Oracles
main :: IO ()
main = shakeArgs shakeOptions{shakeFiles = shakeFilesPath} $ do
oracleRules -- see module Rules.Oracles
cabalRules -- see module Rules.Cabal
generateTargets -- see module Rules
packageRules -- see module Rules
cabalRules -- see module Rules.Cabal
configRules -- see module Rules.Config
generateTargets -- see module Rules
oracleRules -- see module Rules.Oracles
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
module Oracles.Base (
askConfigWithDefault, askConfig, configOracle,
putOracle
module Base,
module Control.Applicative,
module Util,
askConfig, askConfigWithDefault, configOracle
) where
import Base
import Util
import Control.Applicative
import Control.Monad.Extra
import Control.Applicative hiding ((*>))
import qualified Data.HashMap.Strict as Map
newtype ConfigKey = ConfigKey String
deriving (Show, Typeable, Eq, Hashable, Binary, NFData)
askConfig :: String -> Action String
askConfig key = askConfigWithDefault key . putError
$ "Cannot find key '" ++ key ++ "' in configuration files."
askConfigWithDefault :: String -> Action String -> Action String
askConfigWithDefault key defaultAction = do
maybeValue <- askOracle $ ConfigKey key
......@@ -21,10 +26,6 @@ askConfigWithDefault key defaultAction = do
Just value -> return value
Nothing -> defaultAction
askConfig :: String -> Action String
askConfig key = askConfigWithDefault key . putError
$ "Cannot find key '" ++ key ++ "' in configuration files."
-- Oracle for configuration files
configOracle :: Rules ()
configOracle = do
......
......@@ -7,8 +7,6 @@ module Oracles.Dependencies (
import Base
import Util
import Data.List
import Data.Function
import qualified Data.HashMap.Strict as Map
import Control.Applicative
......
......@@ -4,11 +4,8 @@ module Oracles.Flag (
platformSupportsSharedLibs, ghcWithSMP, ghcWithNativeCodeGen
) where
import Base
import Util
import Oracles.Base
import Oracles.Setting
import Control.Monad
data Flag = GccIsClang
| GccLt46
......
......@@ -7,7 +7,6 @@ module Oracles.PackageData (
import Base
import Util
import Data.List
import Control.Applicative
import qualified Data.HashMap.Strict as Map
......
......@@ -5,12 +5,9 @@ module Oracles.PackageDeps (
packageDepsOracle
) where
import Base
import Package
import Oracles.Base
import Data.Maybe
import qualified Data.HashMap.Strict as Map
import Control.Applicative
newtype PackageDepsKey = PackageDepsKey PackageName
deriving (Show, Typeable, Eq, Hashable, Binary, NFData)
......
......@@ -6,7 +6,6 @@ module Oracles.Setting (
ghcEnableTablesNextToCode, cmdLineLengthLimit
) where
import Base
import Stage
import Oracles.Base
......
......@@ -6,7 +6,6 @@ module Oracles.WindowsRoot (
import Base
import Util
import Data.List
newtype WindowsRoot = WindowsRoot ()
deriving (Show, Typeable, Eq, Hashable, Binary, NFData)
......
{-# LANGUAGE DeriveGeneric #-}
module Package (
Package (..), PackageName, pkgCabalFile,
library, topLevel, setPath
Package (..), PackageName, pkgCabalFile, setPath,
library, topLevel
) where
import Base
import GHC.Generics (Generic)
import Util
import Data.Function
import GHC.Generics
-- It is helpful to distinguish package names from strings.
type PackageName = String
......
......@@ -4,15 +4,11 @@ module Predicates (
registerPackage, splitObjects
) where
import Way
import Base
import Stage
import Package
import Builder
import Expression
import Settings.Default
import Oracles.Flag
import Oracles.Setting
import Settings.Default
-- Basic predicates (see Switches.hs for derived predicates)
stage :: Stage -> Predicate
......
module Rules (
oracleRules, cabalRules, configRules, packageRules, generateTargets
) where
module Rules (generateTargets, packageRules) where
import Way
import Base
import Util
import Stage
import Target (PartialTarget (..))
import Expression
import Oracles.PackageData
import Rules.Cabal
import Rules.Config
import Rules.Package
import Rules.Oracles
import Rules.Resources
import Settings.Ways
import Settings.Packages
import Settings.User
import Settings.Util
import Settings.Packages
import Settings.TargetDirectory
import Settings.Ways
import Target (PartialTarget (..))
-- generateTargets needs package-data.mk files of all target packages
-- generateTargets needs top-level build targets
generateTargets :: Rules ()
generateTargets = action $ do
targets <- fmap concat . forM [Stage0 ..] $ \stage -> do
......
......@@ -5,7 +5,6 @@ import Stage
import Package hiding (library)
import Expression
import Settings.Packages
import Data.List
import Data.Version
import Distribution.Package
import Distribution.Verbosity
......
......@@ -2,8 +2,6 @@ module Rules.Config (configRules) where
import Base
import Util
import Data.List
import Control.Monad
-- We add the following line to 'configure.ac' in order to produce configuration
-- file "system.config" from "system.config.in" by running 'configure' script.
......
......@@ -12,9 +12,6 @@ import Settings.Packages
import Settings.TargetDirectory
import Rules.Actions
import Rules.Resources
import Data.List
import Control.Applicative
import Control.Monad.Extra
-- Build package-data.mk by using GhcCabal to process pkgCabal file
buildPackageData :: Resources -> PartialTarget -> Rules ()
......@@ -23,7 +20,7 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
cabalFile = pkgCabalFile pkg
configure = pkgPath pkg -/- "configure"
(path -/-) <$>
fmap (path -/-)
[ "package-data.mk"
, "haddock-prologue.txt"
, "inplace-pkg-config"
......@@ -65,7 +62,7 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
-- Reason: Shake's built-in makefile parser doesn't recognise slashes
postProcessPackageData :: FilePath -> Action ()
postProcessPackageData file = do
pkgData <- (filter ('$' `notElem`) . lines) <$> liftIO (readFile file)
pkgData <- fmap (filter ('$' `notElem`) . lines) . liftIO $ readFile file
length pkgData `seq` writeFileLines file $ map processLine pkgData
where
processLine line = replaceSeparators '_' prefix ++ suffix
......
......@@ -8,7 +8,6 @@ import Expression
import Target (PartialTarget (..), fullTarget)
import Oracles.PackageData
import Settings.Util
import Settings.TargetDirectory
import Rules.Actions
import Rules.Resources
......@@ -28,7 +27,7 @@ buildPackageDependencies _ target @ (PartialTarget stage pkg) =
srcs <- interpretPartial target getPackageSources
need srcs
build $ fullTarget target (GhcM stage) srcs [file]
removeFile $ file <.> "bak"
removeFileIfExists $ file <.> "bak"
(buildPath -/- ".dependencies") %> \file -> do
cSrcs <- pkgDataList $ CSrcs path
......
......@@ -14,7 +14,6 @@ import Rules.Resources
import Settings.Util
import Settings.User
import Settings.Packages
import Control.Monad.Extra
-- Note: this build rule creates plenty of files, not just the .haddock one.
-- All of them go into the 'doc' subdirectory. Pedantically tracking all built
......
module Rules.Library (buildPackageLibrary) where
import Way
import Base hiding (splitPath)
import Util
import Target (PartialTarget (..), fullTarget)
import Builder
import Package
import Base hiding (splitPath, getDirectoryContents)
import Expression
import Predicates (splitObjects)
import Oracles.PackageData
import Settings.Util
import Settings.TargetDirectory
import Predicates (splitObjects)
import Rules.Actions
import Rules.Resources
import Data.List
import qualified System.Directory as IO
import Settings.Util
import System.Directory (getDirectoryContents)
import Target (PartialTarget (..), fullTarget)
buildPackageLibrary :: Resources -> PartialTarget -> Rules ()
buildPackageLibrary _ target @ (PartialTarget stage pkg) = do
......@@ -23,7 +17,7 @@ buildPackageLibrary _ target @ (PartialTarget stage pkg) = do
-- TODO: handle dynamic libraries
matchBuildResult buildPath "a" ?> \a -> do
removeFile a
removeFileIfExists a
cSrcs <- cSources target
hSrcs <- hSources target
......@@ -39,7 +33,7 @@ buildPackageLibrary _ target @ (PartialTarget stage pkg) = do
splitObjs <- if not split then return [] else
fmap concat $ forM hSrcs $ \src -> do
let splitPath = buildPath -/- src ++ "_" ++ osuf way ++ "_split"
contents <- liftIO $ IO.getDirectoryContents splitPath
contents <- liftIO $ getDirectoryContents splitPath
return . map (splitPath -/-)
. filter (not . all (== '.')) $ contents
......
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