|
15 | 15 | "split_lockfile_packages", |
16 | 16 | "workspace_dep_data", |
17 | 17 | _fq_crate = "fq_crate", |
| 18 | + _manifest_package_dir = "manifest_package_dir", |
18 | 19 | _normalize_path = "normalize_path", |
19 | 20 | _select = "select_items", |
20 | 21 | ) |
@@ -416,6 +417,8 @@ crate.annotation( |
416 | 417 | _fq_crate(package["name"], package["version"]): package |
417 | 418 | for package in packages |
418 | 419 | } |
| 420 | + repo_root = _normalize_path(cargo_metadata["workspace_root"]) |
| 421 | + workspace_package = _label_directory(cargo_lock_path) |
419 | 422 |
|
420 | 423 | hub_contents = [] |
421 | 424 | for name, versions in versions_by_name.items(): |
@@ -478,6 +481,19 @@ alias( |
478 | 481 | default_version = default_version, |
479 | 482 | )) |
480 | 483 |
|
| 484 | + for package in cargo_metadata["packages"]: |
| 485 | + package_dir = _manifest_package_dir(package["manifest_path"], repo_root) |
| 486 | + bazel_package = paths.join(workspace_package, package_dir) if package_dir else workspace_package |
| 487 | + hub_contents.append(""" |
| 488 | +alias( |
| 489 | + name = "{name}-{version}", |
| 490 | + actual = "@@//{bazel_package}", |
| 491 | +)""".format( |
| 492 | + name = package["name"], |
| 493 | + version = package["version"], |
| 494 | + bazel_package = bazel_package, |
| 495 | + )) |
| 496 | + |
481 | 497 | workspace_deps, conditional_workspace_deps = render_select( |
482 | 498 | [], |
483 | 499 | workspace_dep_labels_by_triple, |
@@ -577,8 +593,6 @@ RESOLVED_PLATFORMS = select({{ |
577 | 593 |
|
578 | 594 | _date(mctx, "done") |
579 | 595 |
|
580 | | - repo_root = _normalize_path(cargo_metadata["workspace_root"]) |
581 | | - workspace_package = _label_directory(cargo_lock_path) |
582 | 596 | data_bzl_contents = render_dep_data(workspace_dep_data( |
583 | 597 | cargo_metadata = cargo_metadata, |
584 | 598 | feature_resolutions_by_fq_crate = feature_resolutions_by_fq_crate, |
|
0 commit comments