From be5f9e9b5ae79f382726b9681557e58aa658cd12 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Thu, 14 Jul 2016 20:31:06 -0700 Subject: [PATCH] A terrible hack which solves #3545. See the comment in the code. I don't like it but it's BC! Signed-off-by: Edward Z. Yang --- Cabal/Distribution/Simple/PreProcess.hs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Cabal/Distribution/Simple/PreProcess.hs b/Cabal/Distribution/Simple/PreProcess.hs index bc76e38fbf2..df11ade8bb7 100644 --- a/Cabal/Distribution/Simple/PreProcess.hs +++ b/Cabal/Distribution/Simple/PreProcess.hs @@ -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 where - 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)