Prevent deps of build-time deps from leaking into the build environment
When decided what dependencies should be part of the build environment (and have appropriate entries added to variables like PKG_CONFIG_PATH), we select the entire dependency tree except for (1) inactive optional and recommended deps (2) indirect build-time deps (i.e., build-time deps of other deps) There is a third category that sould be excluded: dependencies of direct build-time deps. These are irrelevant to the build, and including them can cause unexpected linkages.
This commit is contained in:
parent
c137f030bc
commit
2fb5ead38a
@ -100,6 +100,8 @@ class Build
|
|||||||
Dependency.prune
|
Dependency.prune
|
||||||
elsif dep.build? && dependent != f
|
elsif dep.build? && dependent != f
|
||||||
Dependency.prune
|
Dependency.prune
|
||||||
|
elsif dep.build?
|
||||||
|
Dependency.keep_but_prune_recursive_deps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -82,6 +82,8 @@ class Dependency
|
|||||||
next []
|
next []
|
||||||
when :skip
|
when :skip
|
||||||
expand(dep.to_formula, &block)
|
expand(dep.to_formula, &block)
|
||||||
|
when :keep_but_prune_recursive_deps
|
||||||
|
[dep]
|
||||||
else
|
else
|
||||||
expand(dep.to_formula, &block) << dep
|
expand(dep.to_formula, &block) << dep
|
||||||
end
|
end
|
||||||
@ -110,6 +112,11 @@ class Dependency
|
|||||||
throw(:action, :skip)
|
throw(:action, :skip)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Keep a dependency, but prune its dependencies
|
||||||
|
def keep_but_prune_recursive_deps
|
||||||
|
throw(:action, :keep_but_prune_recursive_deps)
|
||||||
|
end
|
||||||
|
|
||||||
def merge_repeats(deps)
|
def merge_repeats(deps)
|
||||||
grouped = deps.group_by(&:name)
|
grouped = deps.group_by(&:name)
|
||||||
|
|
||||||
|
|||||||
@ -95,4 +95,17 @@ class DependencyExpansionTests < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal [@bar, @baz], deps
|
assert_equal [@bar, @baz], deps
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_keep_dep_but_prune_recursive_deps
|
||||||
|
f = stub(:deps => [
|
||||||
|
build_dep(:foo, [:build], [@bar]),
|
||||||
|
build_dep(:baz, [:build]),
|
||||||
|
])
|
||||||
|
|
||||||
|
deps = Dependency.expand(f) do |dependent, dep|
|
||||||
|
Dependency.keep_but_prune_recursive_deps if dep.build?
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal [@foo, @baz], deps
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user