Commit 3605e9bd authored by ijones's avatar ijones
Browse files

clean now removes preprocessed sources (and is more likely to destroy your...

clean now removes preprocessed sources (and is  more likely to destroy your source code so be careful)
parent 99f91360
......@@ -193,8 +193,7 @@ tests currDir
>>= assertBool "library doesn't exist"
assertEqual "install returned error code" ExitSuccess instRetCode,
TestLabel "package A: GHC and clean" $ TestCase $
do let targetDir = ",tmp/lib/test-1.0/"
system "make clean"
do system "./setup clean"
doesFileExist "C.hs" >>=
assertEqual "C.hs (a generated file) not cleaned." False
......
......@@ -155,13 +155,16 @@ data BuildInfo = BuildInfo {
}
deriving (Show,Read,Eq)
currentDir :: FilePath
currentDir = "."-- FIX: FileUtils.currentDir
emptyBuildInfo :: BuildInfo
emptyBuildInfo = BuildInfo {
buildDepends = [],
modules = [],
exposedModules = [], -- Only used for libs
cSources = [],
hsSourceDir = ".", -- FIX: FileUtils.currentDir
hsSourceDir = currentDir,
extensions = [],
extraLibs = [],
includeDirs = [],
......
......@@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.PreProcess (preprocessSources, knownSuffixHandlers,
ppSuffixes, PPSuffixHandler, PreProcessor,
removePreprocessed)
removePreprocessed, removePreprocessedPackage)
where
import Distribution.PreProcess.Unlit(plain, unlit)
......@@ -47,7 +47,7 @@ import Distribution.Package (PackageDescription(..), BuildInfo(..), Executable(.
import Distribution.Simple.Configure (LocalBuildInfo(..))
import Distribution.Simple.Utils (setupMessage, rawSystemPath, splitFilePath,
joinFilenameDir, joinExt, moduleToFilePath,
sequenceMap, removeFiles, hasExt)
sequenceMap, removeFiles, hasExt, pathJoin)
import Control.Monad(when)
import System.Exit (ExitCode(..), exitWith)
......@@ -113,6 +113,18 @@ findAllSourceFiles PackageDescription{executables=execs, library=lib} allSuffixe
buildInfoSources BuildInfo{modules=mods, hsSourceDir=dir} suffixes
= sequence [moduleToFilePath dir modu suffixes | modu <- mods] >>= return . concat
removePreprocessedPackage :: PackageDescription
-> FilePath -- ^root of source tree (where to look for hsSources)
-> [String] -- ^suffixes
-> IO ()
removePreprocessedPackage pkg_descr r suff
= do maybe (return ()) removePPBuildInfo (library pkg_descr)
sequenceMap removePPBuildInfo (map buildInfo (executables pkg_descr))
return ()
where removePPBuildInfo :: BuildInfo -> IO ()
removePPBuildInfo bi
= removePreprocessed (pathJoin [r, (hsSourceDir bi)]) (modules bi) suff
-- |Remove the preprocessed .hs files. (do we need to get some .lhs files too?)
removePreprocessed :: FilePath -- ^search Location
-> [String] -- ^Modules
......
......@@ -56,7 +56,7 @@ module Distribution.Simple (
-- local
import Distribution.Package --must not specify imports, since we're exporting moule.
import Distribution.PreProcess (knownSuffixHandlers)
import Distribution.PreProcess (knownSuffixHandlers, ppSuffixes, removePreprocessedPackage)
import Distribution.Setup
import Distribution.Simple.Build ( build )
......@@ -97,6 +97,9 @@ doBuildInstall f pkgConf
= do lbi <- getPersistBuildConfig
f pkgConf lbi
currentDir :: FilePath
currentDir = "."-- FIX: FileUtils.currentDir
defaultMain :: IO ()
defaultMain = readPackageDescription defaultPackageDesc >>= defaultMainNoRead
......@@ -120,13 +123,14 @@ defaultMainNoRead pkg_descr
localbuildinfo <- getPersistBuildConfig
build buildPref pkg_descr localbuildinfo
writeInstalledConfig pkg_descr localbuildinfo
CleanCmd -> do
(_, args) <- parseCleanArgs args []
no_extra_flags args
try $ removeFileRecursive buildPref
try $ removeFile installedPkgConfigFile
try $ removeFile localBuildInfoFile
removePreprocessedPackage pkg_descr currentDir (ppSuffixes knownSuffixHandlers)
return ()
InstallCmd mprefix uInst -> do
......
......@@ -50,7 +50,7 @@ module Distribution.Simple.SrcDist (
#endif
) where
import Distribution.Package(PackageDescription(..), BuildInfo(..), showPackageId, allModules)
import Distribution.Package(PackageDescription(..), BuildInfo(..), showPackageId)
import Distribution.Simple.Configure(LocalBuildInfo)
import Distribution.Simple.Utils(setupMessage, moveSources, die, pathJoin)
import Distribution.PreProcess (PPSuffixHandler, ppSuffixes, knownSuffixHandlers, removePreprocessed)
......
......@@ -10,6 +10,9 @@
** where are we using allModules, is this the right place?
** move some of the junk in Utils up one level, then use currentDir =
"." there.
** integrate w/ GHC distro
** Preprocessing
- what other preprocessors can't unlit?
......
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