From 393f5c4a2ed1fb9b030d85fba5ea6c44c1fa1fa1 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Sun, 22 Jun 2025 19:29:14 +0100 Subject: [PATCH 1/2] Include repository name in splicing errors --- crate_universe/extensions.bzl | 1 + crate_universe/private/crates_repository.bzl | 1 + crate_universe/private/splicing_utils.bzl | 4 ++++ crate_universe/src/cli/splice.rs | 6 +++++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crate_universe/extensions.bzl b/crate_universe/extensions.bzl index e1c2e66f8e..f85bd6dad8 100644 --- a/crate_universe/extensions.bzl +++ b/crate_universe/extensions.bzl @@ -638,6 +638,7 @@ def _generate_hub_and_spokes( config_path = config_file, output_dir = tag_path.get_child("splicing-output"), debug_workspace_dir = tag_path.get_child("splicing-workspace"), + repository_name = cfg.name, ) # If a cargo lockfile was not provided, use the splicing lockfile. diff --git a/crate_universe/private/crates_repository.bzl b/crate_universe/private/crates_repository.bzl index 394f45927c..c3a29619bf 100644 --- a/crate_universe/private/crates_repository.bzl +++ b/crate_universe/private/crates_repository.bzl @@ -89,6 +89,7 @@ def _crates_repository_impl(repository_ctx): splicing_manifest = splicing_manifest, config_path = config_path, output_dir = repository_ctx.path("splicing-output"), + repository_name = repository_ctx.name, ) kwargs.update({ diff --git a/crate_universe/private/splicing_utils.bzl b/crate_universe/private/splicing_utils.bzl index c799647a23..ea6f4ae5d4 100644 --- a/crate_universe/private/splicing_utils.bzl +++ b/crate_universe/private/splicing_utils.bzl @@ -122,6 +122,7 @@ def splice_workspace_manifest( splicing_manifest, config_path, output_dir, + repository_name, debug_workspace_dir = None): """Splice together a Cargo workspace from various other manifests and package definitions @@ -132,6 +133,7 @@ def splice_workspace_manifest( splicing_manifest (path): The path to a splicing manifest. config_path (path): The path to the config file (containing `cargo_bazel::config::Config`.) output_dir (path): THe location in which to write splicing outputs. + repository_name (str): Name of the repository being generated. debug_workspace_dir (path): The location in which to save splicing outputs for future review. Returns: @@ -147,6 +149,8 @@ def splice_workspace_manifest( splicing_manifest, "--config", config_path, + "--repository-name", + repository_name, ] if cargo_lockfile: diff --git a/crate_universe/src/cli/splice.rs b/crate_universe/src/cli/splice.rs index a3cdec8551..c689fbcc82 100644 --- a/crate_universe/src/cli/splice.rs +++ b/crate_universe/src/cli/splice.rs @@ -57,6 +57,10 @@ pub struct SpliceOptions { /// The path to a rustc binary for use with Cargo #[clap(long, env = "RUSTC")] pub rustc: PathBuf, + + /// The name of the repository being generated. + #[clap(long)] + pub repository_name: String, } /// Combine a set of disjoint manifests into a single workspace. @@ -84,7 +88,7 @@ pub fn splice(opt: SpliceOptions) -> Result<()> { // Splice together the manifest let manifest_path = splicer .splice_workspace() - .context("Failed to splice workspace")?; + .with_context(|| format!("Failed to splice workspace {}", opt.repository_name))?; // Generate a lockfile let cargo_lockfile = generate_lockfile( From b59cbfde08babfc99ae0e1b83825374b9faedd35 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Sun, 22 Jun 2025 19:59:36 +0100 Subject: [PATCH 2/2] Fix test --- crate_universe/tests/cargo_integration_test.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crate_universe/tests/cargo_integration_test.rs b/crate_universe/tests/cargo_integration_test.rs index 3b863aa7bd..7ce82d68d1 100644 --- a/crate_universe/tests/cargo_integration_test.rs +++ b/crate_universe/tests/cargo_integration_test.rs @@ -116,6 +116,7 @@ fn run(repository_name: &str, manifests: HashMap, lockfile: &str config, cargo, rustc, + repository_name: String::from("crates_index"), }) .unwrap();