Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A terrible hack which solves #3545. #3557

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)