Commit be5f9e9b authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

A terrible hack which solves #3545.

See the comment in the code.  I don't like it but it's BC!
Signed-off-by: default avatarEdward Z. Yang <>
parent 487565aa
......@@ -47,7 +47,7 @@ import Distribution.Verbosity
import Control.Monad
import Data.Maybe (fromMaybe)
import Data.List (nub, isSuffixOf)
import Data.List (nub, isSuffixOf, isPrefixOf)
import System.Directory (doesFileExist)
import System.Info (os, arch)
import System.FilePath (splitExtension, dropExtensions, (</>), (<.>),
......@@ -650,4 +650,21 @@ preprocessExtras comp lbi = case comp of
BenchmarkUnsupported tt -> die $ "No support for preprocessing benchmark "
++ "type " ++ display tt
pp dir = (map (dir </>) . concat) `fmap` forM knownExtrasHandlers ($ dir)
pp dir = (map (dir </>) . filter not_sub . concat) `fmap` forM knownExtrasHandlers ($ dir)
-- TODO: This is a terrible hack to work around #3545 while we don't
-- reorganize the directory layout. Basically, for the main
-- library, we might accidentally pick up autogenerated sources for
-- our subcomponents, because they are all stored as subdirectories
-- in dist/build. This is a cheap and cheerful check to prevent
-- this from happening. It is not particularly correct; for example
-- if a user has a test suite named foobar and puts their C file in
-- foobar/foo.c, this test will incorrectly exclude it. But I
-- didn't want to break BC...
not_sub p = and [ not (pre `isPrefixOf` p) | pre <- component_dirs ]
component_dirs = component_names (localPkgDescr lbi)
-- TODO: libify me
component_names pkg_descr =
map libName (libraries pkg_descr) ++
map exeName (executables pkg_descr) ++
map testName (testSuites pkg_descr) ++
map benchmarkName (benchmarks pkg_descr)
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