Skip to content

Commit

Permalink
cargo: Fix crash when enabling feature on dev/build dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
xclaesse committed Dec 3, 2024
1 parent fd309ff commit 9e4feed
Showing 1 changed file with 11 additions and 4 deletions.
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
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

0 comments on commit 9e4feed

Please sign in to comment.