Skip to content

Commit

Permalink
A terrible hack which solves haskell#3545.
Browse files Browse the repository at this point in the history
See the comment in the code.  I don't like it but it's BC!

Signed-off-by: Edward Z. Yang <[email protected]>
  • Loading branch information
ezyang committed Jul 21, 2016
1 parent 487565a commit be5f9e9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Cabal/Distribution/Simple/PreProcess.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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, (</>), (<.>),
Expand Down Expand Up @@ -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)

0 comments on commit be5f9e9

Please sign in to comment.