Skip to content

Commit

Permalink
Ignore 'install-includes' that are also listed in 'extra-tmp-files'.
Browse files Browse the repository at this point in the history
  • Loading branch information
23Skidoo committed Oct 24, 2013
1 parent 2959818 commit dba88a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Cabal/Distribution/Simple/SrcDist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import Distribution.Simple.Utils
, installOrdinaryFiles, installMaybeExecutableFiles
, findFile, findFileWithExtension, matchFileGlob
, withTempDirectory, defaultPackageDesc
, die, warn, notice, setupMessage )
, die, warn, notice, setupMessage, notElemBy )
import Distribution.Simple.Setup ( Flag(..), SDistFlags(..)
, fromFlag, flagToMaybe)
import Distribution.Simple.PreProcess ( PPSuffixHandler, ppSuffixes
Expand All @@ -109,7 +109,7 @@ import System.Directory ( doesFileExist )
import System.IO (IOMode(WriteMode), hPutStrLn, withFile)
import Distribution.Verbosity (Verbosity)
import System.FilePath
( (</>), (<.>), dropExtension, isAbsolute )
( (</>), (<.>), dropExtension, isAbsolute, equalFilePath )

-- |Create a source distribution.
sdist :: PackageDescription -- ^information from the tarball
Expand Down Expand Up @@ -262,8 +262,11 @@ listPackageSourcesOrdinary verbosity pkg_descr pps =
-- Install-include files.
, withLib $ \ l -> do
let lbi = libBuildInfo l
-- Ignore include files that are generated by 'configure'. See #1557.
isNotTmpFile f = notElemBy equalFilePath f (extraTmpFiles pkg_descr)
relincdirs = "." : filter (not.isAbsolute) (includeDirs lbi)
mapM (fmap snd . findIncludeFile relincdirs) (installIncludes lbi)
fmap (filter isNotTmpFile)
. mapM (fmap snd . findIncludeFile relincdirs) $ (installIncludes lbi)

-- Setup script, if it exists.
, fmap (maybe [] (\f -> [f])) $ findSetupFile ""
Expand Down
12 changes: 12 additions & 0 deletions Cabal/Distribution/Simple/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ module Distribution.Simple.Utils (
normaliseLineEndings,

-- * generic utils
elemBy,
notElemBy,
equating,
comparing,
isInfixOf,
Expand Down Expand Up @@ -1271,6 +1273,16 @@ normaliseLineEndings ( c :s) = c : normaliseLineEndings s
-- * Common utils
-- ------------------------------------------------------------

-- | Like 'elemBy', but takes a custom comparison function.
elemBy :: (a -> b -> Bool) -> a -> [b] -> Bool
elemBy _ _ [] = False
elemBy f a (b:bs) = f a b || elemBy f a bs

-- | Like 'notElemBy', but takes a custom comparison function.
notElemBy :: (a -> b -> Bool) -> a -> [b] -> Bool
notElemBy _ _ [] = True
notElemBy f a (b:bs) = not (f a b) && notElemBy f a bs

equating :: Eq a => (b -> a) -> b -> b -> Bool
equating p x y = p x == p y

Expand Down

0 comments on commit dba88a1

Please sign in to comment.