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

cargo: Fix crash when enabling feature on dev/build dependencies #13976

Merged
merged 1 commit into from
Dec 3, 2024
Merged
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
15 changes: 11 additions & 4 deletions mesonbuild/cargo/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import shutil
import collections
import urllib.parse
import itertools
import typing as T

from . import builder
Expand Down Expand Up @@ -546,8 +547,13 @@ def _load_manifest(self, subdir: str) -> Manifest:
def _add_dependency(self, pkg: PackageState, depname: str) -> None:
if depname in pkg.required_deps:
return
dep = pkg.manifest.dependencies.get(depname)
if not dep:
if depname in itertools.chain(pkg.manifest.dev_dependencies, pkg.manifest.build_dependencies):
# FIXME: Not supported yet
xclaesse marked this conversation as resolved.
Show resolved Hide resolved
return
raise MesonException(f'Dependency {depname} not defined in {pkg.manifest.package.name} manifest')
pkg.required_deps.add(depname)
dep = pkg.manifest.dependencies[depname]
dep_pkg, _ = self._fetch_package(dep.package, dep.api)
if dep.default_features:
self._enable_feature(dep_pkg, 'default')
Expand Down Expand Up @@ -580,9 +586,10 @@ def _enable_feature(self, pkg: PackageState, feature: str) -> None:
pkg.optional_deps_features[depname].add(dep_f)
else:
self._add_dependency(pkg, depname)
dep = pkg.manifest.dependencies[depname]
dep_pkg = self._dep_package(dep)
self._enable_feature(dep_pkg, dep_f)
dep = pkg.manifest.dependencies.get(depname)
if dep:
dep_pkg = self._dep_package(dep)
self._enable_feature(dep_pkg, dep_f)
elif f.startswith('dep:'):
self._add_dependency(pkg, f[4:])
else:
Expand Down
Loading