Commit 85d2cf37 authored by Moritz Angermann's avatar Moritz Angermann
Browse files

Cleanup

parent d34af518
......@@ -176,7 +176,7 @@ defaultMainHelper hooks args = topHandler $
,replCommand progs `commandAddAction` replAction hooks
,installCommand `commandAddAction` installAction hooks
,copyCommand `commandAddAction` copyAction hooks
,doctestCommand `commandAddAction` doctestAcion hooks
,doctestCommand `commandAddAction` doctestAction hooks
,haddockCommand `commandAddAction` haddockAction hooks
,cleanCommand `commandAddAction` cleanAction hooks
,sdistCommand `commandAddAction` sdistAction hooks
......@@ -292,8 +292,8 @@ hscolourAction hooks flags args = do
(getBuildConfig hooks verbosity distPref)
hooks flags' args
doctestAcion :: UserHooks -> DoctestFlags -> Args -> IO ()
doctestAcion hooks flags args = do
doctestAction :: UserHooks -> DoctestFlags -> Args -> IO ()
doctestAction hooks flags args = do
distPref <- findDistPrefOrDefault (doctestDistPref flags)
let verbosity = fromFlag $ doctestVerbosity flags
......
{-# LANGUAGE RankNTypes #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Simple.BuildPaths
......@@ -31,11 +32,16 @@ module Distribution.Simple.BuildPaths (
objExtension,
dllExtension,
staticLibExtension,
-- * Source files & build directories
getSourceFiles, getLibSourceFiles, getExeSourceFiles,
getFLibSourceFiles, exeBuildDir, flibBuildDir,
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Types.ForeignLib
import Distribution.Types.UnqualComponentName (unUnqualComponentName)
import Distribution.Package
import Distribution.ModuleName as ModuleName
import Distribution.Compiler
......@@ -44,8 +50,10 @@ import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Setup
import Distribution.Text
import Distribution.System
import Distribution.Verbosity
import Distribution.Simple.Utils
import System.FilePath ((</>), (<.>))
import System.FilePath ((</>), (<.>), normalise)
-- ---------------------------------------------------------------------------
-- Build directories and files
......@@ -104,6 +112,72 @@ autogenPathsModuleName pkg_descr =
haddockName :: PackageDescription -> FilePath
haddockName pkg_descr = display (packageName pkg_descr) <.> "haddock"
-- -----------------------------------------------------------------------------
-- Source File helper
getLibSourceFiles :: Verbosity
-> LocalBuildInfo
-> Library
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, FilePath)]
getLibSourceFiles verbosity lbi lib clbi = getSourceFiles verbosity searchpaths modules
where
bi = libBuildInfo lib
modules = allLibModules lib clbi
searchpaths = componentBuildDir lbi clbi : hsSourceDirs bi ++
[ autogenComponentModulesDir lbi clbi
, autogenPackageModulesDir lbi ]
getExeSourceFiles :: Verbosity
-> LocalBuildInfo
-> Executable
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, FilePath)]
getExeSourceFiles verbosity lbi exe clbi = do
moduleFiles <- getSourceFiles verbosity searchpaths modules
srcMainPath <- findFile (hsSourceDirs bi) (modulePath exe)
return ((ModuleName.main, srcMainPath) : moduleFiles)
where
bi = buildInfo exe
modules = otherModules bi
searchpaths = autogenComponentModulesDir lbi clbi
: autogenPackageModulesDir lbi
: exeBuildDir lbi exe : hsSourceDirs bi
getFLibSourceFiles :: Verbosity
-> LocalBuildInfo
-> ForeignLib
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, FilePath)]
getFLibSourceFiles verbosity lbi flib clbi = getSourceFiles verbosity searchpaths modules
where
bi = foreignLibBuildInfo flib
modules = otherModules bi
searchpaths = autogenComponentModulesDir lbi clbi
: autogenPackageModulesDir lbi
: flibBuildDir lbi flib : hsSourceDirs bi
getSourceFiles :: Verbosity -> [FilePath]
-> [ModuleName.ModuleName]
-> IO [(ModuleName.ModuleName, FilePath)]
getSourceFiles verbosity dirs modules = flip traverse modules $ \m -> fmap ((,) m) $
findFileWithExtension ["hs", "lhs", "hsig", "lhsig"] dirs (ModuleName.toFilePath m)
>>= maybe (notFound m) (return . normalise)
where
notFound module_ = die' verbosity $ "can't find source for module " ++ display module_
-- | The directory where we put build results for an executable
exeBuildDir :: LocalBuildInfo -> Executable -> FilePath
exeBuildDir lbi exe = buildDir lbi </> nm </> nm ++ "-tmp"
where
nm = unUnqualComponentName $ exeName exe
-- | The directory where we put build results for a foreign library
flibBuildDir :: LocalBuildInfo -> ForeignLib -> FilePath
flibBuildDir lbi flib = buildDir lbi </> nm </> nm ++ "-tmp"
where
nm = unUnqualComponentName $ foreignLibName flib
-- ---------------------------------------------------------------------------
-- Library file names
......
......@@ -20,11 +20,6 @@ import Distribution.Compat.Prelude
-- local
-- import Distribution.Backpack.DescribeUnitId (setupMessage')
import Distribution.Types.UnqualComponentName
import Distribution.Types.ComponentLocalBuildInfo
-- import Distribution.Package
import qualified Distribution.ModuleName as ModuleName
import Distribution.PackageDescription as PD hiding (Flag)
import Distribution.Simple.Program
import Distribution.Simple.PreProcess
......@@ -32,13 +27,9 @@ import Distribution.Simple.Setup
import Distribution.Simple.Build
import Distribution.Simple.LocalBuildInfo hiding (substPathTemplate)
import Distribution.Simple.BuildPaths
import Distribution.Simple.Utils
import Distribution.Text
import Distribution.Version
import Distribution.Verbosity
import System.FilePath ( (</>), normalise )
-- -----------------------------------------------------------------------------
-- Types
......@@ -102,52 +93,6 @@ renderArgs _verbosity args k = do
-- doctest invocation, and disable doctests automagic discovery heuristics.
k (["--no-magic"], argTargets args)
-- -----------------------------------------------------------------------------
-- TODO: move somewhere else (this is copied from Haddock.hs!)
getLibSourceFiles :: Verbosity
-> LocalBuildInfo
-> Library
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, FilePath)]
getLibSourceFiles verbosity lbi lib clbi = getSourceFiles verbosity searchpaths modules
where
bi = libBuildInfo lib
modules = allLibModules lib clbi
searchpaths = componentBuildDir lbi clbi : hsSourceDirs bi ++
[ autogenComponentModulesDir lbi clbi
, autogenPackageModulesDir lbi ]
getExeSourceFiles :: Verbosity
-> LocalBuildInfo
-> Executable
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, FilePath)]
getExeSourceFiles verbosity lbi exe clbi = do
moduleFiles <- getSourceFiles verbosity searchpaths modules
srcMainPath <- findFile (hsSourceDirs bi) (modulePath exe)
return ((ModuleName.main, srcMainPath) : moduleFiles)
where
bi = buildInfo exe
modules = otherModules bi
searchpaths = autogenComponentModulesDir lbi clbi
: autogenPackageModulesDir lbi
: exeBuildDir lbi exe : hsSourceDirs bi
getSourceFiles :: Verbosity -> [FilePath]
-> [ModuleName.ModuleName]
-> IO [(ModuleName.ModuleName, FilePath)]
getSourceFiles verbosity dirs modules = flip traverse modules $ \m -> fmap ((,) m) $
findFileWithExtension ["hs", "lhs", "hsig", "lhsig"] dirs (ModuleName.toFilePath m)
>>= maybe (notFound m) (return . normalise)
where
notFound module_ = die' verbosity $ "doctest: can't find source for module " ++ display module_
-- | The directory where we put build results for an executable
exeBuildDir :: LocalBuildInfo -> Executable -> FilePath
exeBuildDir lbi exe = buildDir lbi </> nm </> nm ++ "-tmp"
where
nm = unUnqualComponentName $ exeName exe
-- ------------------------------------------------------------------------------
-- Boilerplate Monoid instance.
instance Monoid DoctestArgs where
......
......@@ -751,71 +751,6 @@ haddockToHscolour flags =
hscolourVerbosity = haddockVerbosity flags,
hscolourDistPref = haddockDistPref flags
}
---------------------------------------------------------------------------------
-- TODO these should be moved elsewhere.
getLibSourceFiles :: Verbosity
-> LocalBuildInfo
-> Library
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, FilePath)]
getLibSourceFiles verbosity lbi lib clbi = getSourceFiles verbosity searchpaths modules
where
bi = libBuildInfo lib
modules = allLibModules lib clbi
searchpaths = componentBuildDir lbi clbi : hsSourceDirs bi ++
[ autogenComponentModulesDir lbi clbi
, autogenPackageModulesDir lbi ]
getExeSourceFiles :: Verbosity
-> LocalBuildInfo
-> Executable
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, FilePath)]
getExeSourceFiles verbosity lbi exe clbi = do
moduleFiles <- getSourceFiles verbosity searchpaths modules
srcMainPath <- findFile (hsSourceDirs bi) (modulePath exe)
return ((ModuleName.main, srcMainPath) : moduleFiles)
where
bi = buildInfo exe
modules = otherModules bi
searchpaths = autogenComponentModulesDir lbi clbi
: autogenPackageModulesDir lbi
: exeBuildDir lbi exe : hsSourceDirs bi
getFLibSourceFiles :: Verbosity
-> LocalBuildInfo
-> ForeignLib
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, FilePath)]
getFLibSourceFiles verbosity lbi flib clbi = getSourceFiles verbosity searchpaths modules
where
bi = foreignLibBuildInfo flib
modules = otherModules bi
searchpaths = autogenComponentModulesDir lbi clbi
: autogenPackageModulesDir lbi
: flibBuildDir lbi flib : hsSourceDirs bi
getSourceFiles :: Verbosity -> [FilePath]
-> [ModuleName.ModuleName]
-> IO [(ModuleName.ModuleName, FilePath)]
getSourceFiles verbosity dirs modules = flip traverse modules $ \m -> fmap ((,) m) $
findFileWithExtension ["hs", "lhs", "hsig", "lhsig"] dirs (ModuleName.toFilePath m)
>>= maybe (notFound m) (return . normalise)
where
notFound module_ = die' verbosity $ "haddock: can't find source for module " ++ display module_
-- | The directory where we put build results for an executable
exeBuildDir :: LocalBuildInfo -> Executable -> FilePath
exeBuildDir lbi exe = buildDir lbi </> nm </> nm ++ "-tmp"
where
nm = unUnqualComponentName $ exeName exe
-- | The directory where we put build results for a foreign library
flibBuildDir :: LocalBuildInfo -> ForeignLib -> FilePath
flibBuildDir lbi flib = buildDir lbi </> nm </> nm ++ "-tmp"
where
nm = unUnqualComponentName $ foreignLibName flib
-- ------------------------------------------------------------------------------
-- Boilerplate Monoid instance.
......
......@@ -62,7 +62,7 @@ module Distribution.Simple.LocalBuildInfo (
module Distribution.Simple.InstallDirs,
absoluteInstallDirs, prefixRelativeInstallDirs,
absoluteComponentInstallDirs, prefixRelativeComponentInstallDirs,
substPathTemplate
substPathTemplate,
) where
import Prelude ()
......@@ -383,3 +383,4 @@ substPathTemplate pkgid lbi uid = fromPathTemplate
uid
(compilerInfo (compiler lbi))
(hostPlatform lbi)
......@@ -50,7 +50,7 @@ import Distribution.Client.Setup
)
import Distribution.Simple.Setup
( HaddockTarget(..)
, DoctestFlags(..), doctestCommand, defaultDoctestFlags
, DoctestFlags(..), doctestCommand
, HaddockFlags(..), haddockCommand, defaultHaddockFlags
, HscolourFlags(..), hscolourCommand
, ReplFlags(..)
......@@ -271,7 +271,7 @@ mainWorker args = topHandler $
, regularCmd buildCommand buildAction
, regularCmd replCommand replAction
, regularCmd sandboxCommand sandboxAction
, regularCmd doctestCommand doctestAcion
, regularCmd doctestCommand doctestAction
, regularCmd haddockCommand haddockAction
, regularCmd execCommand execAction
, regularCmd userConfigCommand userConfigAction
......@@ -763,10 +763,9 @@ haddockAction haddockFlags extraArgs globalFlags = do
createTarGzFile dest docDir name
notice verbosity $ "Documentation tarball created: " ++ dest
doctestAcion :: DoctestFlags -> [String] -> Action
doctestAcion doctestFlags extraArgs globalFlags = do
doctestAction :: DoctestFlags -> [String] -> Action
doctestAction doctestFlags extraArgs _globalFlags = do
let verbosity = fromFlag (doctestVerbosity doctestFlags)
(useSandbox, config) <- loadConfigOrSandboxConfig verbosity globalFlags
setupWrapper verbosity defaultSetupScriptOptions Nothing
doctestCommand (const doctestFlags) extraArgs
......
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