fix crash when passing invalid inputs as build_target dependencies

The `add_deps` function did not behave correctly when a specified
dependency is not an instance of `dependencies.Dependency`.

Reorder the logic flow to perform this validation first.

Fixes #10468
pull/10503/head
fxxf 2 years ago committed by Eli Schwartz
parent 2e3ac3eec0
commit b7159f4a1a
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 13
      mesonbuild/build.py

@ -1343,12 +1343,6 @@ class BuildTarget(Target):
if dep in self.added_deps:
continue
dep_d_features = dep.d_features
for feature in ('versions', 'import_dirs'):
if feature in dep_d_features:
self.d_features[feature].extend(dep_d_features[feature])
if isinstance(dep, dependencies.InternalDependency):
# Those parts that are internal.
self.process_sourcelist(dep.sources)
@ -1387,6 +1381,13 @@ You probably should put it in link_with instead.''')
'either an external dependency (returned by find_library() or '
'dependency()) or an internal dependency (returned by '
'declare_dependency()).')
dep_d_features = dep.d_features
for feature in ('versions', 'import_dirs'):
if feature in dep_d_features:
self.d_features[feature].extend(dep_d_features[feature])
self.added_deps.add(dep)
def get_external_deps(self) -> T.List[dependencies.Dependency]:

Loading…
Cancel
Save