Skip to content

Commit

Permalink
Update crate_universe to determine dep+feature trees per host (#2877)
Browse files Browse the repository at this point in the history
This change expands the use of `cargo tree` to resolve features for
different combinations of `host -> target` platform triples where before
`cargo-bazel` was only capable of resolving host dependencies for the
current host platform and not a foreign platform.

A lengthy description of how this was done can be found at
`crate_universe/src/metadata/cargo_tree_resolver.rs -
TreeResolver::create_rustc_wrapper`.

closes #2212

---------

Co-authored-by: Daniel Wagner-Hall <[email protected]>
  • Loading branch information
UebelAndre and illicitonion authored Sep 18, 2024
1 parent beebf3b commit 350d249
Show file tree
Hide file tree
Showing 51 changed files with 16,575 additions and 688 deletions.
47 changes: 45 additions & 2 deletions bindgen/3rdparty/crates/BUILD.proc-macro2-1.0.60.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 45 additions & 2 deletions bindgen/3rdparty/crates/BUILD.quote-1.0.28.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 59 additions & 4 deletions crate_universe/3rdparty/crates/BUILD.phf_shared-0.11.2.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 45 additions & 2 deletions crate_universe/3rdparty/crates/BUILD.rand-0.8.5.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 16 additions & 13 deletions crate_universe/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,23 @@ bzl_library(
)

filegroup(
name = "rust_srcs",
name = "rust_data",
srcs = glob([
"src/**/*.bzl",
"src/**/*.j2",
"src/**/*.rs",
"src/**/*.sh",
"src/**/*.bat",
]),
visibility = ["//:__subpackages__"],
)

filegroup(
name = "rust_srcs",
srcs = glob([
"src/**/*.rs",
]) + [
":rust_data",
],
visibility = ["//crate_universe:__subpackages__"],
)

rust_library(
Expand All @@ -52,10 +62,7 @@ rust_library(
exclude = ["src/main.rs"],
),
aliases = aliases(),
compile_data = glob(
include = ["src/**"],
exclude = ["src/**/*.rs"],
),
compile_data = [":rust_data"],
edition = "2021",
proc_macro_deps = all_crate_deps(proc_macro = True),
# This target embeds additional, stamping related information (see
Expand Down Expand Up @@ -119,16 +126,12 @@ rust_test(
],
edition = "2021",
env = {
"CARGO": "$(rootpath @rules_rust//rust/toolchain:current_cargo_files)",
"RUSTC": "$(rootpath @rules_rust//rust/toolchain:current_rustc_files)",
"CARGO": "$(rlocationpath @rules_rust//rust/toolchain:current_cargo_files)",
"RUSTC": "$(rlocationpath @rules_rust//rust/toolchain:current_rustc_files)",
},
proc_macro_deps = all_crate_deps(
proc_macro_dev = True,
),
rustc_env = {
"CARGO": "$(rootpath @rules_rust//rust/toolchain:current_cargo_files)",
"RUSTC": "$(rootpath @rules_rust//rust/toolchain:current_rustc_files)",
},
tags = ["requires-network"],
deps = [
":cargo_bazel",
Expand Down
2 changes: 1 addition & 1 deletion crate_universe/private/bootstrap_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _format_src_label(label):
return "Label(\"{}\"),".format(str(label).lstrip("@"))

def _srcs_module_impl(ctx):
srcs = [_format_src_label(src.owner) for src in ctx.files.srcs]
srcs = [_format_src_label(src.owner) for src in sorted(ctx.files.srcs)]
if not srcs:
fail("`srcs` cannot be empty")
output = ctx.actions.declare_file(ctx.label.name)
Expand Down
2 changes: 2 additions & 0 deletions crate_universe/private/srcs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ CARGO_BAZEL_SRCS = [
Label("//crate_universe:src/metadata.rs"),
Label("//crate_universe:src/metadata/cargo_bin.rs"),
Label("//crate_universe:src/metadata/cargo_tree_resolver.rs"),
Label("//crate_universe:src/metadata/cargo_tree_rustc_wrapper.bat"),
Label("//crate_universe:src/metadata/cargo_tree_rustc_wrapper.sh"),
Label("//crate_universe:src/metadata/dependency.rs"),
Label("//crate_universe:src/metadata/metadata_annotation.rs"),
Label("//crate_universe:src/rendering.rs"),
Expand Down
Loading

0 comments on commit 350d249

Please sign in to comment.