Skip to content

Commit

Permalink
Add support for cargo dependency renaming
Browse files Browse the repository at this point in the history
It is possible to reference a crate using an import name other than its
package name. The package name and import name are typically the same,
but when they differ, we should use the package name to construct the
dependency graph. The import name is of no consequence outside of the
package being built.
  • Loading branch information
cottsay committed Feb 6, 2025
1 parent 1c2882e commit 0d43a49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion colcon_cargo/package_augmentation/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def create_dependency_descriptor(name, constraints, path):
"""
Create a dependency descriptor from a Cargo dependency specification.
:param name: The name of the dependee
:param name: The name of the dependee as it is imported
:param constraints: The dependency constraints, either a string or
a dict
:param path: The directory from where relative paths should be
Expand All @@ -94,6 +94,7 @@ def create_dependency_descriptor(name, constraints, path):
else:
source = constraints.get('git') or \
constraints.get('registry')
name = constraints.get('package', name)
else:
source = None
metadata = {
Expand Down
2 changes: 1 addition & 1 deletion test/rust-sample-package/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rust-pure-library = {path = "../rust-pure-library"}
local-rust-pure-library = {package = "rust-pure-library", path = "../rust-pure-library"}

0 comments on commit 0d43a49

Please sign in to comment.