Skip to content

Commit 9969cd3

Browse files
committed
Cabal should look for unknown build-tools entries on the PATH too
This is a bug from `first build-tool-depends` PR: #4104 Also, remove TODO about factoring things out. The exact set of deps filter here is no longer so globally relevant, and `Distribution.Simple.BuildToolDepends` exposes better filters which are.
1 parent 0a3aac8 commit 9969cd3

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

Cabal/Distribution/Simple/Configure.hs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -570,19 +570,31 @@ configure (pkg_descr0', pbi) cfg = do
570570
die $ "Cannot build some foreign libraries: "
571571
++ intercalate "," unsupportedFLibs
572572

573-
-- Configure known/required programs & external build tools.
574-
-- Exclude build-tool deps on "internal" exes in the same package
573+
-- Configure certain external build tools, see below for which ones.
575574
--
576-
-- TODO: Factor this into a helper package.
577-
---
578575
-- TODO: HACK we're currently ignoring wildcard deps as we don't know
579576
-- precisely which executables the resolved package will contain.
580-
let requiredBuildTools =
581-
[ LegacyExeDependency (unUnqualComponentName eName) versionRange
582-
| bi <- enabledBuildInfos pkg_descr enabled
583-
, buildTool@(ExeDependency _ (Just eName) versionRange)
584-
<- getAllToolDependencies pkg_descr bi
585-
, not $ isInternal pkg_descr buildTool ]
577+
let requiredBuildTools = do
578+
bi <- enabledBuildInfos pkg_descr enabled
579+
-- First, we collect any tool dep that we know is external. This is,
580+
-- in practice:
581+
--
582+
-- 1. `build-tools` entries on the whitelist
583+
--
584+
-- 2. `build-tool-depends` that aren't from the current package.
585+
let externBuildToolDeps =
586+
[ LegacyExeDependency (unUnqualComponentName eName) versionRange
587+
| buildTool@(ExeDependency _ (Just eName) versionRange)
588+
<- getAllToolDependencies pkg_descr bi
589+
, not $ isInternal pkg_descr buildTool ]
590+
-- Second, we collect any build-tools entry we don't know how to
591+
-- desugar. We'll never have no idea how to build them, so we just
592+
-- hope they are already on the PATH.
593+
let unknownBuildTools =
594+
[ buildTool
595+
| buildTool <- buildTools bi
596+
, Nothing == desugarBuildTool pkg_descr buildTool ]
597+
externBuildToolDeps ++ unknownBuildTools
586598

587599
programDb' <-
588600
configureAllKnownPrograms (lessVerbose verbosity) programDb

0 commit comments

Comments
 (0)