Skip to content

Commit 5a43f35

Browse files
committed
Ensure crate_universe modules don't override intermediates for debugging
1 parent 59c980d commit 5a43f35

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

crate_universe/extensions.bzl

+5-4
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,8 @@ def _generate_hub_and_spokes(
629629
cargo_lockfile = cargo_lockfile,
630630
splicing_manifest = splicing_manifest,
631631
config_path = config_file,
632-
output_dir = module_ctx.path("{}/{}".format(tag_path, "splicing-output")),
632+
output_dir = tag_path.get_child("splicing-output"),
633+
debug_workspace_dir = tag_path.get_child("splicing-workspace"),
633634
)
634635

635636
# If a cargo lockfile was not provided, use the splicing lockfile.
@@ -638,7 +639,7 @@ def _generate_hub_and_spokes(
638639

639640
# Create a fallback lockfile to be parsed downstream.
640641
if lockfile == None:
641-
lockfile = module_ctx.path("cargo-bazel-lock.json")
642+
lockfile = tag_path.get_child("cargo-bazel-lock.json")
642643
module_ctx.file(lockfile, "")
643644

644645
kwargs.update({
@@ -648,8 +649,8 @@ def _generate_hub_and_spokes(
648649
# The workspace root when one is explicitly provided.
649650
nonhermetic_root_bazel_workspace_dir = module_ctx.path(Label("@@//:MODULE.bazel")).dirname
650651

651-
paths_to_track_file = module_ctx.path("paths_to_track.json")
652-
warnings_output_file = module_ctx.path("warnings_output.json")
652+
paths_to_track_file = tag_path.get_child("paths_to_track.json")
653+
warnings_output_file = tag_path.get_child("warnings_output.json")
653654

654655
# Run the generator
655656
module_ctx.report_progress("Generating crate BUILD files for `{}`".format(cfg.name))

crate_universe/private/splicing_utils.bzl

+6-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ def splice_workspace_manifest(
121121
cargo_lockfile,
122122
splicing_manifest,
123123
config_path,
124-
output_dir):
124+
output_dir,
125+
debug_workspace_dir = None):
125126
"""Splice together a Cargo workspace from various other manifests and package definitions
126127
127128
Args:
@@ -131,6 +132,7 @@ def splice_workspace_manifest(
131132
splicing_manifest (path): The path to a splicing manifest.
132133
config_path (path): The path to the config file (containing `cargo_bazel::config::Config`.)
133134
output_dir (path): THe location in which to write splicing outputs.
135+
debug_workspace_dir (path): The location in which to save splicing outputs for future review.
134136
135137
Returns:
136138
path: The path to a Cargo metadata json file found in the spliced workspace root.
@@ -156,9 +158,11 @@ def splice_workspace_manifest(
156158
# Optionally set the splicing workspace directory to somewhere within the repository directory
157159
# to improve the debugging experience.
158160
if CARGO_BAZEL_DEBUG in repository_ctx.os.environ:
161+
if debug_workspace_dir == None:
162+
debug_workspace_dir = repository_ctx.path("splicing-workspace")
159163
arguments.extend([
160164
"--workspace-dir",
161-
repository_ctx.path("splicing-workspace"),
165+
debug_workspace_dir,
162166
])
163167

164168
env = {}

0 commit comments

Comments
 (0)