`cargo-bazel` now supports `alias_rule` to customize the aliases generated (#2312)

Motivator is to be able to set `default_alias_rule = "opt"` so that all
Cargo fetched 3rd party dependencies are built with
`compilation_mode=opt` regardless of what `compilation_mode` the local
code is being built with.
This commit is contained in:
James Leitch 2023-12-15 09:13:47 -08:00 committed by GitHub
parent c0e66562e9
commit 3803401dd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 3254 additions and 62 deletions

43
crate_universe/3rdparty/crates/alias_rules.bzl generated vendored Normal file
View File

@ -0,0 +1,43 @@
"""Alias that transitions its target to `compilation_mode=opt`. Use `transition_alias="opt"` to enable."""
load("@rules_rust//rust:rust_common.bzl", "COMMON_PROVIDERS")
def _transition_alias_impl(ctx):
# `ctx.attr.actual` is a list of 1 item due to the transition
return [ctx.attr.actual[0][provider] for provider in COMMON_PROVIDERS]
def _change_compilation_mode(compilation_mode):
def _change_compilation_mode_impl(_settings, _attr):
return {
"//command_line_option:compilation_mode": compilation_mode,
}
return transition(
implementation = _change_compilation_mode_impl,
inputs = [],
outputs = [
"//command_line_option:compilation_mode",
],
)
def _transition_alias_rule(compilation_mode):
return rule(
implementation = _transition_alias_impl,
provides = COMMON_PROVIDERS,
attrs = {
"actual": attr.label(
mandatory = True,
doc = "`rust_library()` target to transition to `compilation_mode=opt`.",
providers = COMMON_PROVIDERS,
cfg = _change_compilation_mode(compilation_mode),
),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
doc = "Transitions a Rust library crate to the `compilation_mode=opt`.",
)
transition_alias_dbg = _transition_alias_rule("dbg")
transition_alias_fastbuild = _transition_alias_rule("fastbuild")
transition_alias_opt = _transition_alias_rule("opt")

View File

@ -128,3 +128,33 @@ def cargo_environ(repository_ctx):
})
return env
def parse_alias_rule(value):
"""Attempts to parse an `AliasRule` from supplied string.
Args:
value (str): String value to be parsed.
Returns:
value: A Rust compatible `AliasRule`.
"""
if value == None:
return None
if value == "alias" or value == "dbg" or value == "fastbuild" or value == "opt":
return value
if value.count(":") != 2:
fail("Invalid custom value for `alias_rule`.\n{}\nValues must be in the format '<label to .bzl>:<rule>'.".format(value))
split = value.rsplit(":", 1)
bzl = Label(split[0])
rule = split[1]
if rule == "alias":
fail("Custom value rule cannot be named `alias`.\n{}".format(value))
return struct(
bzl = str(bzl),
rule = rule,
)

View File

@ -1,5 +1,7 @@
"""Macros used for represeting crates or annotations for existing crates"""
load(":common_utils.bzl", "parse_alias_rule")
def _workspace_member(version, sha256 = None):
"""Define information for extra workspace members
@ -83,6 +85,7 @@ def _annotation(
version = "*",
additive_build_file = None,
additive_build_file_content = None,
alias_rule = None,
build_script_data = None,
build_script_tools = None,
build_script_data_glob = None,
@ -118,6 +121,8 @@ def _annotation(
additive_build_file_content (str, optional): Extra contents to write to the bottom of generated BUILD files.
additive_build_file (str, optional): A file containing extra contents to write to the bottom of
generated BUILD files.
alias_rule (str, optional): Alias rule to use instead of `native.alias()`. Overrides [render_config](#render_config)'s
'default_alias_rule'.
build_script_data (list, optional): A list of labels to add to a crate's `cargo_build_script::data` attribute.
build_script_tools (list, optional): A list of labels to add to a crate's `cargo_build_script::tools` attribute.
build_script_data_glob (list, optional): A list of glob patterns to add to a crate's `cargo_build_script::data`
@ -175,6 +180,7 @@ def _annotation(
struct(
additive_build_file = additive_build_file,
additive_build_file_content = additive_build_file_content,
alias_rule = parse_alias_rule(alias_rule),
build_script_data = build_script_data,
build_script_tools = build_script_tools,
build_script_data_glob = build_script_data_glob,

View File

@ -1,6 +1,6 @@
"""Utilities directly related to the `generate` step of `cargo-bazel`."""
load(":common_utils.bzl", "CARGO_BAZEL_DEBUG", "CARGO_BAZEL_ISOLATED", "REPIN_ALLOWLIST_ENV_VAR", "REPIN_ENV_VARS", "cargo_environ", "execute")
load(":common_utils.bzl", "CARGO_BAZEL_DEBUG", "CARGO_BAZEL_ISOLATED", "REPIN_ALLOWLIST_ENV_VAR", "REPIN_ENV_VARS", "cargo_environ", "execute", "parse_alias_rule")
CARGO_BAZEL_GENERATOR_SHA256 = "CARGO_BAZEL_GENERATOR_SHA256"
CARGO_BAZEL_GENERATOR_URL = "CARGO_BAZEL_GENERATOR_URL"
@ -85,6 +85,7 @@ def render_config(
crate_label_template = "@{repository}__{name}-{version}//:{target}",
crate_repository_template = "{repository}__{name}-{version}",
crates_module_template = "//:{file}",
default_alias_rule = "alias",
default_package_name = None,
generate_target_compatible_with = True,
platforms_template = "@rules_rust//rust/platform:{triple}",
@ -113,6 +114,10 @@ def render_config(
available format keys are [`{repository}`, `{name}`, `{version}`].
crates_module_template (str, optional): The pattern to use for the `defs.bzl` and `BUILD.bazel`
file names used for the crates module. The available format keys are [`{file}`].
default_alias_rule (str, option): Alias rule to use when generating aliases for all crates. Acceptable values
are 'alias', 'dbg'/'fastbuild'/'opt' (transitions each crate's `compilation_mode`) or a string
representing a rule in the form '<label to .bzl>:<rule>' that takes a single label parameter 'actual'.
See '@crate_index//:alias_rules.bzl' for an example.
default_package_name (str, optional): The default package name to use in the rendered macros. This affects the
auto package detection of things like `all_crate_deps`.
generate_target_compatible_with (bool, optional): Whether to generate `target_compatible_with` annotations on
@ -132,6 +137,7 @@ def render_config(
crate_label_template = crate_label_template,
crate_repository_template = crate_repository_template,
crates_module_template = crates_module_template,
default_alias_rule = parse_alias_rule(default_alias_rule),
default_package_name = default_package_name,
generate_target_compatible_with = generate_target_compatible_with,
platforms_template = platforms_template,

View File

@ -67,6 +67,10 @@ pub struct RenderConfig {
#[serde(default = "default_crate_repository_template")]
pub crate_repository_template: String,
/// Default alias rule to use for packages. Can be overridden by annotations.
#[serde(default)]
pub default_alias_rule: AliasRule,
/// The default of the `package_name` parameter to use for the module macros like `all_crate_deps`.
/// In general, this should be be unset to allow the macros to do auto-detection in the analysis phase.
pub default_package_name: Option<String>,
@ -99,6 +103,7 @@ impl Default for RenderConfig {
crate_label_template: default_crate_label_template(),
crates_module_template: default_crates_module_template(),
crate_repository_template: default_crate_repository_template(),
default_alias_rule: AliasRule::default(),
default_package_name: Option::default(),
generate_target_compatible_with: default_generate_target_compatible_with(),
platforms_template: default_platforms_template(),
@ -181,6 +186,43 @@ pub enum Checksumish {
},
}
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Clone)]
pub enum AliasRule {
#[default]
#[serde(rename = "alias")]
Alias,
#[serde(rename = "dbg")]
Dbg,
#[serde(rename = "fastbuild")]
Fastbuild,
#[serde(rename = "opt")]
Opt,
#[serde(untagged)]
Custom { bzl: String, rule: String },
}
impl AliasRule {
pub fn bzl(&self) -> Option<String> {
match self {
AliasRule::Alias => None,
AliasRule::Dbg | AliasRule::Fastbuild | AliasRule::Opt => {
Some("//:alias_rules.bzl".to_owned())
}
AliasRule::Custom { bzl, .. } => Some(bzl.clone()),
}
}
pub fn rule(&self) -> String {
match self {
AliasRule::Alias => "alias".to_owned(),
AliasRule::Dbg => "transition_alias_dbg".to_owned(),
AliasRule::Fastbuild => "transition_alias_fastbuild".to_owned(),
AliasRule::Opt => "transition_alias_opt".to_owned(),
AliasRule::Custom { rule, .. } => rule.clone(),
}
}
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq)]
pub struct CrateAnnotations {
/// Which subset of the crate's bins should get produced as `rust_binary` targets.
@ -288,6 +330,9 @@ pub struct CrateAnnotations {
/// Extra targets the should be aliased during rendering.
pub extra_aliased_targets: Option<BTreeMap<String, String>>,
/// Transition rule to use instead of `native.alias()`.
pub alias_rule: Option<AliasRule>,
}
macro_rules! joined_extra_member {
@ -347,6 +392,7 @@ impl Add for CrateAnnotations {
patch_tool: self.patch_tool.or(rhs.patch_tool),
patches: joined_extra_member!(self.patches, rhs.patches, BTreeSet::new, BTreeSet::extend),
extra_aliased_targets: joined_extra_member!(self.extra_aliased_targets, rhs.extra_aliased_targets, BTreeMap::new, BTreeMap::extend),
alias_rule: self.alias_rule.or(rhs.alias_rule),
};
output

View File

@ -5,7 +5,7 @@ use std::collections::{BTreeMap, BTreeSet};
use cargo_metadata::{Node, Package, PackageId};
use serde::{Deserialize, Serialize};
use crate::config::{CrateId, GenBinaries};
use crate::config::{AliasRule, CrateId, GenBinaries};
use crate::metadata::{CrateAnnotation, Dependency, PairredExtras, SourceAnnotation};
use crate::utils::sanitize_module_name;
use crate::utils::starlark::{Glob, SelectList, SelectMap, SelectStringDict, SelectStringList};
@ -325,6 +325,10 @@ pub struct CrateContext {
/// Extra targets that should be aliased.
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub extra_aliased_targets: BTreeMap<String, String>,
/// Transition rule to use instead of `alias`.
#[serde(skip_serializing_if = "Option::is_none")]
pub alias_rule: Option<AliasRule>,
}
impl CrateContext {
@ -481,6 +485,7 @@ impl CrateContext {
additive_build_file_content: None,
disable_pipelining: false,
extra_aliased_targets: BTreeMap::new(),
alias_rule: None,
}
.with_overrides(extras)
}
@ -629,6 +634,11 @@ impl CrateContext {
self.extra_aliased_targets.append(&mut extra.clone());
}
// Transition alias
if let Some(alias_rule) = &crate_extra.alias_rule {
self.alias_rule.get_or_insert(alias_rule.clone());
}
// Git shallow_since
if let Some(SourceAnnotation::Git { shallow_since, .. }) = &mut self.repository {
*shallow_since = crate_extra.shallow_since.clone()

View File

@ -211,7 +211,7 @@ mod test {
);
assert_eq!(
Digest("379610c3d0f58778cb066f51da66894f10d0e7ea903e4621c61534b4d1344e6f".to_owned()),
Digest("9fcd91ea8e2f7ded4c17895b41ae83b4d6c903f101911aea8bb5282135837b19".to_owned()),
digest,
);
}
@ -256,7 +256,7 @@ mod test {
);
assert_eq!(
Digest("c4d5c9def86c1af758a29f144d8d9ab66b1c762d36f878d1e7f9b6e09782c512".to_owned()),
Digest("2b0c255dfcd33196867b604db956aaec0f4aab344941535968e4617c346e44f4".to_owned()),
digest,
);
}
@ -287,7 +287,7 @@ mod test {
);
assert_eq!(
Digest("ab158c3dd56e1771bfaed167c661f9c6c33f1effdf6d870f80640384ad1bffaf".to_owned()),
Digest("b1cee7093144f3c5ed4c8b1b9a25df40da997f1b9da2d46ecfda88c67307f66d".to_owned()),
digest,
);
}
@ -336,7 +336,7 @@ mod test {
);
assert_eq!(
Digest("b707269f173b2f78ae500317f9ae54df3c05c88972531c277045d0eb756fc681".to_owned()),
Digest("487524c404739b42956cff78e5f26779902f28a61bbb3380f6210f79d1c7fceb".to_owned()),
digest,
);
}

View File

@ -12,7 +12,7 @@ use anyhow::{bail, Context as AnyhowContext, Result};
use indoc::formatdoc;
use itertools::Itertools;
use crate::config::{RenderConfig, VendorMode};
use crate::config::{AliasRule, RenderConfig, VendorMode};
use crate::context::crate_context::{CrateContext, CrateDependency, Rule};
use crate::context::{Context, TargetAttributes};
use crate::rendering::template_engine::TemplateEngine;
@ -97,6 +97,9 @@ impl Renderer {
let module_build_label =
render_module_label(&self.config.crates_module_template, "BUILD.bazel")
.context("Failed to resolve string to module file label")?;
let module_alias_rules_label =
render_module_label(&self.config.crates_module_template, "alias_rules.bzl")
.context("Failed to resolve string to module file label")?;
let mut map = BTreeMap::new();
map.insert(
@ -107,6 +110,14 @@ impl Renderer {
Renderer::label_to_path(&module_build_label),
self.render_module_build_file(context)?,
);
map.insert(
Renderer::label_to_path(&module_alias_rules_label),
include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/rendering/verbatim/alias_rules.bzl"
))
.to_owned(),
);
Ok(map)
}
@ -118,6 +129,23 @@ impl Renderer {
let header = self.engine.render_header()?;
starlark.push(Starlark::Verbatim(header));
// Load any `alias_rule`s.
let mut loads: BTreeMap<String, BTreeSet<String>> = BTreeMap::new();
for alias_rule in Iterator::chain(
std::iter::once(&self.config.default_alias_rule),
context
.workspace_member_deps()
.iter()
.flat_map(|dep| &context.crates[&dep.id].alias_rule),
) {
if let Some(bzl) = alias_rule.bzl() {
loads.entry(bzl).or_default().insert(alias_rule.rule());
}
}
for (bzl, items) in loads {
starlark.push(Starlark::Load(Load { bzl, items }))
}
// Package visibility, exported bzl files.
let package = Package::default_visibility_public();
starlark.push(Starlark::Package(package));
@ -147,9 +175,15 @@ impl Renderer {
let mut dependencies = Vec::new();
for dep in context.workspace_member_deps() {
let krate = &context.crates[&dep.id];
let alias_rule = krate
.alias_rule
.as_ref()
.unwrap_or(&self.config.default_alias_rule);
if let Some(library_target_name) = &krate.library_target_name {
let rename = dep.alias.as_ref().unwrap_or(&krate.name);
dependencies.push(Alias {
rule: alias_rule.rule(),
// If duplicates exist, include version to disambiguate them.
name: if context.has_duplicate_workspace_member_dep(dep) {
format!("{}-{}", rename, krate.version)
@ -163,6 +197,7 @@ impl Renderer {
for (alias, target) in &krate.extra_aliased_targets {
dependencies.push(Alias {
rule: alias_rule.rule(),
name: alias.clone(),
actual: self.crate_label(&krate.name, &krate.version, target),
tags: BTreeSet::from(["manual".to_owned()]),
@ -196,6 +231,7 @@ impl Renderer {
for rule in &krate.targets {
if let Rule::Binary(bin) = rule {
binaries.push(Alias {
rule: AliasRule::default().rule(),
// If duplicates exist, include version to disambiguate them.
name: if context.has_duplicate_binary_crate(crate_id) {
format!("{}-{}__{}", krate.name, krate.version, bin.crate_name)
@ -296,6 +332,7 @@ impl Renderer {
self.make_cargo_build_script(platforms, krate, target)?;
starlark.push(Starlark::CargoBuildScript(cargo_build_script));
starlark.push(Starlark::Alias(Alias {
rule: AliasRule::default().rule(),
name: target.crate_name.clone(),
actual: format!("{}_build_script", krate.name),
tags: BTreeSet::from(["manual".to_owned()]),

View File

@ -0,0 +1,43 @@
"""Alias that transitions its target to `compilation_mode=opt`. Use `transition_alias="opt"` to enable."""
load("@rules_rust//rust:rust_common.bzl", "COMMON_PROVIDERS")
def _transition_alias_impl(ctx):
# `ctx.attr.actual` is a list of 1 item due to the transition
return [ctx.attr.actual[0][provider] for provider in COMMON_PROVIDERS]
def _change_compilation_mode(compilation_mode):
def _change_compilation_mode_impl(_settings, _attr):
return {
"//command_line_option:compilation_mode": compilation_mode,
}
return transition(
implementation = _change_compilation_mode_impl,
inputs = [],
outputs = [
"//command_line_option:compilation_mode",
],
)
def _transition_alias_rule(compilation_mode):
return rule(
implementation = _transition_alias_impl,
provides = COMMON_PROVIDERS,
attrs = {
"actual": attr.label(
mandatory = True,
doc = "`rust_library()` target to transition to `compilation_mode=opt`.",
providers = COMMON_PROVIDERS,
cfg = _change_compilation_mode(compilation_mode),
),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
doc = "Transitions a Rust library crate to the `compilation_mode=opt`.",
)
transition_alias_dbg = _transition_alias_rule("dbg")
transition_alias_fastbuild = _transition_alias_rule("fastbuild")
transition_alias_opt = _transition_alias_rule("opt")

View File

@ -9,7 +9,7 @@ mod target_compatible_with;
use std::collections::BTreeSet as Set;
use serde::{Serialize, Serializer};
use serde_starlark::Error as StarlarkError;
use serde_starlark::{Error as StarlarkError, FunctionCall};
pub use glob::*;
pub use label::*;
@ -60,9 +60,8 @@ pub struct Filegroup {
pub srcs: Glob,
}
#[derive(Serialize)]
#[serde(rename = "alias")]
pub struct Alias {
pub rule: String,
pub name: String,
pub actual: String,
pub tags: Set<String>,
@ -244,25 +243,11 @@ pub struct CommonAttrs {
pub srcs: Glob,
#[serde(skip_serializing_if = "Set::is_empty")]
pub tags: Set<String>,
#[serde(
serialize_with = "serialize_target_compatible_with",
skip_serializing_if = "Option::is_none"
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub target_compatible_with: Option<TargetCompatibleWith>,
pub version: String,
}
fn serialize_target_compatible_with<S>(
value: &Option<TargetCompatibleWith>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
// SAFETY: Option::is_none causes serialization to get skipped.
value.as_ref().unwrap().serialize_starlark(serializer)
}
pub struct Data {
pub glob: Glob,
pub select: SelectList<WithOriginalConfigurations<String>>,
@ -276,6 +261,41 @@ impl Package {
}
}
impl Serialize for Alias {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
// Output looks like:
//
// rule(
// name = "name",
// actual = "actual",
// tags = [
// "tag1",
// "tag2",
// ],
// )
#[derive(Serialize)]
struct AliasInner<'a> {
pub name: &'a String,
pub actual: &'a String,
pub tags: &'a Set<String>,
}
FunctionCall::new(
&self.rule,
AliasInner {
name: &self.name,
actual: &self.actual,
tags: &self.tags,
},
)
.serialize(serializer)
}
}
pub fn serialize(starlark: &[Starlark]) -> Result<String, StarlarkError> {
let mut content = String::new();
for call in starlark {

View File

@ -1,10 +1,10 @@
use std::collections::BTreeSet;
use serde::ser::{SerializeMap, SerializeTupleStruct, Serializer};
use serde::{Deserialize, Serialize};
use serde::Serialize;
use serde_starlark::{FunctionCall, MULTILINE};
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, Clone)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
pub struct TargetCompatibleWith {
target_triples: BTreeSet<String>,
}
@ -13,8 +13,10 @@ impl TargetCompatibleWith {
pub fn new(target_triples: BTreeSet<String>) -> Self {
TargetCompatibleWith { target_triples }
}
}
pub fn serialize_starlark<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
impl Serialize for TargetCompatibleWith {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
@ -84,7 +86,7 @@ mod test {
assert_eq!(
target_compatible_with
.serialize_starlark(serde_starlark::Serializer)
.serialize(serde_starlark::Serializer)
.unwrap(),
expected_starlark,
);

View File

@ -605,13 +605,13 @@ string: A json encoded string of all inputs
## crate.annotation
<pre>
crate.annotation(<a href="#crate.annotation-version">version</a>, <a href="#crate.annotation-additive_build_file">additive_build_file</a>, <a href="#crate.annotation-additive_build_file_content">additive_build_file_content</a>, <a href="#crate.annotation-build_script_data">build_script_data</a>,
<a href="#crate.annotation-build_script_tools">build_script_tools</a>, <a href="#crate.annotation-build_script_data_glob">build_script_data_glob</a>, <a href="#crate.annotation-build_script_deps">build_script_deps</a>, <a href="#crate.annotation-build_script_env">build_script_env</a>,
<a href="#crate.annotation-build_script_proc_macro_deps">build_script_proc_macro_deps</a>, <a href="#crate.annotation-build_script_rundir">build_script_rundir</a>, <a href="#crate.annotation-build_script_rustc_env">build_script_rustc_env</a>,
<a href="#crate.annotation-build_script_toolchains">build_script_toolchains</a>, <a href="#crate.annotation-compile_data">compile_data</a>, <a href="#crate.annotation-compile_data_glob">compile_data_glob</a>, <a href="#crate.annotation-crate_features">crate_features</a>, <a href="#crate.annotation-data">data</a>,
<a href="#crate.annotation-data_glob">data_glob</a>, <a href="#crate.annotation-deps">deps</a>, <a href="#crate.annotation-extra_aliased_targets">extra_aliased_targets</a>, <a href="#crate.annotation-gen_binaries">gen_binaries</a>, <a href="#crate.annotation-disable_pipelining">disable_pipelining</a>,
<a href="#crate.annotation-gen_build_script">gen_build_script</a>, <a href="#crate.annotation-patch_args">patch_args</a>, <a href="#crate.annotation-patch_tool">patch_tool</a>, <a href="#crate.annotation-patches">patches</a>, <a href="#crate.annotation-proc_macro_deps">proc_macro_deps</a>, <a href="#crate.annotation-rustc_env">rustc_env</a>,
<a href="#crate.annotation-rustc_env_files">rustc_env_files</a>, <a href="#crate.annotation-rustc_flags">rustc_flags</a>, <a href="#crate.annotation-shallow_since">shallow_since</a>)
crate.annotation(<a href="#crate.annotation-version">version</a>, <a href="#crate.annotation-additive_build_file">additive_build_file</a>, <a href="#crate.annotation-additive_build_file_content">additive_build_file_content</a>, <a href="#crate.annotation-alias_rule">alias_rule</a>,
<a href="#crate.annotation-build_script_data">build_script_data</a>, <a href="#crate.annotation-build_script_tools">build_script_tools</a>, <a href="#crate.annotation-build_script_data_glob">build_script_data_glob</a>, <a href="#crate.annotation-build_script_deps">build_script_deps</a>,
<a href="#crate.annotation-build_script_env">build_script_env</a>, <a href="#crate.annotation-build_script_proc_macro_deps">build_script_proc_macro_deps</a>, <a href="#crate.annotation-build_script_rundir">build_script_rundir</a>,
<a href="#crate.annotation-build_script_rustc_env">build_script_rustc_env</a>, <a href="#crate.annotation-build_script_toolchains">build_script_toolchains</a>, <a href="#crate.annotation-compile_data">compile_data</a>, <a href="#crate.annotation-compile_data_glob">compile_data_glob</a>,
<a href="#crate.annotation-crate_features">crate_features</a>, <a href="#crate.annotation-data">data</a>, <a href="#crate.annotation-data_glob">data_glob</a>, <a href="#crate.annotation-deps">deps</a>, <a href="#crate.annotation-extra_aliased_targets">extra_aliased_targets</a>, <a href="#crate.annotation-gen_binaries">gen_binaries</a>,
<a href="#crate.annotation-disable_pipelining">disable_pipelining</a>, <a href="#crate.annotation-gen_build_script">gen_build_script</a>, <a href="#crate.annotation-patch_args">patch_args</a>, <a href="#crate.annotation-patch_tool">patch_tool</a>, <a href="#crate.annotation-patches">patches</a>,
<a href="#crate.annotation-proc_macro_deps">proc_macro_deps</a>, <a href="#crate.annotation-rustc_env">rustc_env</a>, <a href="#crate.annotation-rustc_env_files">rustc_env_files</a>, <a href="#crate.annotation-rustc_flags">rustc_flags</a>, <a href="#crate.annotation-shallow_since">shallow_since</a>)
</pre>
A collection of extra attributes and settings for a particular crate
@ -624,6 +624,7 @@ A collection of extra attributes and settings for a particular crate
| <a id="crate.annotation-version"></a>version | The version or semver-conditions to match with a crate. The wildcard <code>*</code> matches any version, including prerelease versions. | `"*"` |
| <a id="crate.annotation-additive_build_file"></a>additive_build_file | A file containing extra contents to write to the bottom of generated BUILD files. | `None` |
| <a id="crate.annotation-additive_build_file_content"></a>additive_build_file_content | Extra contents to write to the bottom of generated BUILD files. | `None` |
| <a id="crate.annotation-alias_rule"></a>alias_rule | Alias rule to use instead of <code>native.alias()</code>. Overrides [render_config](#render_config)'s 'default_alias_rule'. | `None` |
| <a id="crate.annotation-build_script_data"></a>build_script_data | A list of labels to add to a crate's <code>cargo_build_script::data</code> attribute. | `None` |
| <a id="crate.annotation-build_script_tools"></a>build_script_tools | A list of labels to add to a crate's <code>cargo_build_script::tools</code> attribute. | `None` |
| <a id="crate.annotation-build_script_data_glob"></a>build_script_data_glob | A list of glob patterns to add to a crate's <code>cargo_build_script::data</code> attribute. | `None` |
@ -750,8 +751,8 @@ list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
<pre>
render_config(<a href="#render_config-build_file_template">build_file_template</a>, <a href="#render_config-crate_label_template">crate_label_template</a>, <a href="#render_config-crate_repository_template">crate_repository_template</a>,
<a href="#render_config-crates_module_template">crates_module_template</a>, <a href="#render_config-default_package_name">default_package_name</a>, <a href="#render_config-generate_target_compatible_with">generate_target_compatible_with</a>,
<a href="#render_config-platforms_template">platforms_template</a>, <a href="#render_config-regen_command">regen_command</a>, <a href="#render_config-vendor_mode">vendor_mode</a>)
<a href="#render_config-crates_module_template">crates_module_template</a>, <a href="#render_config-default_alias_rule">default_alias_rule</a>, <a href="#render_config-default_package_name">default_package_name</a>,
<a href="#render_config-generate_target_compatible_with">generate_target_compatible_with</a>, <a href="#render_config-platforms_template">platforms_template</a>, <a href="#render_config-regen_command">regen_command</a>, <a href="#render_config-vendor_mode">vendor_mode</a>)
</pre>
Various settings used to configure rendered outputs
@ -778,6 +779,7 @@ can be found below where the supported keys for each template can be found in th
| <a id="render_config-crate_label_template"></a>crate_label_template | The base template to use for crate labels. The available format keys are [<code>{repository}</code>, <code>{name}</code>, <code>{version}</code>, <code>{target}</code>]. | `"@{repository}__{name}-{version}//:{target}"` |
| <a id="render_config-crate_repository_template"></a>crate_repository_template | The base template to use for Crate label repository names. The available format keys are [<code>{repository}</code>, <code>{name}</code>, <code>{version}</code>]. | `"{repository}__{name}-{version}"` |
| <a id="render_config-crates_module_template"></a>crates_module_template | The pattern to use for the <code>defs.bzl</code> and <code>BUILD.bazel</code> file names used for the crates module. The available format keys are [<code>{file}</code>]. | `"//:{file}"` |
| <a id="render_config-default_alias_rule"></a>default_alias_rule | Alias rule to use when generating aliases for all crates. Acceptable values are 'alias', 'dbg'/'fastbuild'/'opt' (transitions each crate's <code>compilation_mode</code>) or a string representing a rule in the form '&lt;label to .bzl&gt;:&lt;rule&gt;' that takes a single label parameter 'actual'. See '@crate_index//:alias_rules.bzl' for an example. | `"alias"` |
| <a id="render_config-default_package_name"></a>default_package_name | The default package name to use in the rendered macros. This affects the auto package detection of things like <code>all_crate_deps</code>. | `None` |
| <a id="render_config-generate_target_compatible_with"></a>generate_target_compatible_with | Whether to generate <code>target_compatible_with</code> annotations on the generated BUILD files. This catches a <code>target_triple</code>being targeted that isn't declared in <code>supported_platform_triples</code>. | `True` |
| <a id="render_config-platforms_template"></a>platforms_template | The base template to use for platform names. See [platforms documentation](https://docs.bazel.build/versions/main/platforms.html). The available format keys are [<code>{triple}</code>]. | `"@rules_rust//rust/platform:{triple}"` |

View File

@ -17,7 +17,214 @@ load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencie
crate_universe_dependencies(bootstrap = True)
load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_repository", "splicing_config")
load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_repository", "render_config", "splicing_config")
###############################################################################
# A L I A S R U L E
###############################################################################
crates_repository(
name = "alias_rule_global_alias_annotation_none",
annotations = {
"test_data_passing_crate": [crate.annotation(
alias_rule = None,
)],
},
cargo_lockfile = "//alias_rule:Cargo.Bazel.lock",
# `generator` is not necessary in official releases.
# See load satement for `cargo_bazel_bootstrap`.
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//alias_rule:cargo-bazel-lock_global_alias_annotation_none.json",
packages = {
"test_data_passing_crate": crate.spec(
version = "0.1.0",
),
},
render_config = render_config(
default_alias_rule = "alias",
),
)
load(
"@alias_rule_global_alias_annotation_none//:defs.bzl",
alias_rule_global_alias_annotation_none_crate_repositories = "crate_repositories",
)
alias_rule_global_alias_annotation_none_crate_repositories()
crates_repository(
name = "alias_rule_global_alias_annotation_opt",
annotations = {
"test_data_passing_crate": [crate.annotation(
alias_rule = "opt",
)],
},
cargo_lockfile = "//alias_rule:Cargo.Bazel.lock",
# `generator` is not necessary in official releases.
# See load satement for `cargo_bazel_bootstrap`.
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//alias_rule:cargo-bazel-lock_global_alias_annotation_opt.json",
packages = {
"test_data_passing_crate": crate.spec(
version = "0.1.0",
),
},
render_config = render_config(
default_alias_rule = "alias",
),
)
load(
"@alias_rule_global_alias_annotation_opt//:defs.bzl",
alias_rule_global_alias_annotation_opt_crate_repositories = "crate_repositories",
)
alias_rule_global_alias_annotation_opt_crate_repositories()
crates_repository(
name = "alias_rule_global_opt_annotation_none",
annotations = {
"test_data_passing_crate": [crate.annotation(
alias_rule = None,
)],
},
cargo_lockfile = "//alias_rule:Cargo.Bazel.lock",
# `generator` is not necessary in official releases.
# See load satement for `cargo_bazel_bootstrap`.
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//alias_rule:cargo-bazel-lock_global_opt_annotation_none.json",
packages = {
"test_data_passing_crate": crate.spec(
version = "0.1.0",
),
},
render_config = render_config(
default_alias_rule = "opt",
),
)
load(
"@alias_rule_global_opt_annotation_none//:defs.bzl",
alias_rule_global_opt_annotation_none_crate_repositories = "crate_repositories",
)
alias_rule_global_opt_annotation_none_crate_repositories()
crates_repository(
name = "alias_rule_global_opt_annotation_alias",
annotations = {
"test_data_passing_crate": [crate.annotation(
alias_rule = "alias",
)],
},
cargo_lockfile = "//alias_rule:Cargo.Bazel.lock",
# `generator` is not necessary in official releases.
# See load satement for `cargo_bazel_bootstrap`.
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//alias_rule:cargo-bazel-lock_global_opt_annotation_alias.json",
packages = {
"test_data_passing_crate": crate.spec(
version = "0.1.0",
),
},
render_config = render_config(
default_alias_rule = "opt",
),
)
load(
"@alias_rule_global_opt_annotation_alias//:defs.bzl",
alias_rule_global_opt_annotation_alias_crate_repositories = "crate_repositories",
)
alias_rule_global_opt_annotation_alias_crate_repositories()
crates_repository(
name = "alias_rule_global_opt_annotation_dbg",
annotations = {
"test_data_passing_crate": [crate.annotation(
alias_rule = "dbg",
)],
},
cargo_lockfile = "//alias_rule:Cargo.Bazel.lock",
# `generator` is not necessary in official releases.
# See load satement for `cargo_bazel_bootstrap`.
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//alias_rule:cargo-bazel-lock_global_opt_annotation_dbg.json",
packages = {
"test_data_passing_crate": crate.spec(
version = "0.1.0",
),
},
render_config = render_config(
default_alias_rule = "opt",
),
)
load(
"@alias_rule_global_opt_annotation_dbg//:defs.bzl",
alias_rule_global_opt_annotation_dbg_crate_repositories = "crate_repositories",
)
alias_rule_global_opt_annotation_dbg_crate_repositories()
crates_repository(
name = "alias_rule_global_dbg_annotation_fastbuild",
annotations = {
"test_data_passing_crate": [crate.annotation(
alias_rule = "fastbuild",
)],
},
cargo_lockfile = "//alias_rule:Cargo.Bazel.lock",
# `generator` is not necessary in official releases.
# See load satement for `cargo_bazel_bootstrap`.
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//alias_rule:cargo-bazel-lock_global_dbg_annotation_fastbuild.json",
packages = {
"test_data_passing_crate": crate.spec(
version = "0.1.0",
),
},
render_config = render_config(
default_alias_rule = "dbg",
),
)
load(
"@alias_rule_global_dbg_annotation_fastbuild//:defs.bzl",
alias_rule_global_dbg_annotation_fastbuild_crate_repositories = "crate_repositories",
)
alias_rule_global_dbg_annotation_fastbuild_crate_repositories()
crates_repository(
name = "alias_rule_global_custom_annotation_none",
annotations = {
"test_data_passing_crate": [crate.annotation(
alias_rule = None,
)],
},
cargo_lockfile = "//alias_rule:Cargo.Bazel.lock",
# `generator` is not necessary in official releases.
# See load satement for `cargo_bazel_bootstrap`.
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//alias_rule:cargo-bazel-lock_global_custom_annotation_none.json",
packages = {
"test_data_passing_crate": crate.spec(
version = "0.1.0",
),
},
render_config = render_config(
default_alias_rule = "@//alias_rule:alias_rules.bzl:alias_rule",
),
)
load(
"@alias_rule_global_custom_annotation_none//:defs.bzl",
alias_rule_global_custom_annotation_none_crate_repositories = "crate_repositories",
)
alias_rule_global_custom_annotation_none_crate_repositories()
###############################################################################
# C A R G O A L I A S E S

View File

@ -0,0 +1,43 @@
load("@rules_rust//rust:defs.bzl", "rust_test")
rust_test(
name = "global_alias_annotation_none",
srcs = ["src/fastbuild.rs"],
deps = ["@alias_rule_global_alias_annotation_none//:test_data_passing_crate"],
)
rust_test(
name = "global_alias_annotation_opt",
srcs = ["src/opt.rs"],
deps = ["@alias_rule_global_alias_annotation_opt//:test_data_passing_crate"],
)
rust_test(
name = "global_opt_annotation_none",
srcs = ["src/opt.rs"],
deps = ["@alias_rule_global_opt_annotation_none//:test_data_passing_crate"],
)
rust_test(
name = "global_opt_annotation_alias",
srcs = ["src/fastbuild.rs"],
deps = ["@alias_rule_global_opt_annotation_alias//:test_data_passing_crate"],
)
rust_test(
name = "global_opt_annotation_dbg",
srcs = ["src/dbg.rs"],
deps = ["@alias_rule_global_opt_annotation_dbg//:test_data_passing_crate"],
)
rust_test(
name = "global_dbg_annotation_fastbuild",
srcs = ["src/fastbuild.rs"],
deps = ["@alias_rule_global_dbg_annotation_fastbuild//:test_data_passing_crate"],
)
rust_test(
name = "global_custom_annotation_none",
srcs = ["src/fastbuild.rs"],
deps = ["@alias_rule_global_custom_annotation_none//:test_data_passing_crate"],
)

View File

@ -0,0 +1,16 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "direct-cargo-bazel-deps"
version = "0.0.1"
dependencies = [
"test_data_passing_crate",
]
[[package]]
name = "test_data_passing_crate"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"

View File

@ -0,0 +1,8 @@
"""Wrapper around `native.alias()` to test supplying a custom `alias_rule`."""
def alias_rule(name, actual, tags):
native.alias(
name = name,
actual = actual,
tags = tags,
)

View File

@ -0,0 +1,200 @@
{
"checksum": "bdf13017488624690639faa4db8f33656d9e4e647d7ae38c9f3d9fbc5066d745",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
"version": "0.0.1",
"repository": null,
"targets": [
{
"Library": {
"crate_name": "direct_cargo_bazel_deps",
"crate_root": ".direct_cargo_bazel_deps.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "direct_cargo_bazel_deps",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "test_data_passing_crate"
}
],
"selects": {}
},
"edition": "2018",
"version": "0.0.1"
},
"license": null
},
"test_data_passing_crate 0.1.0": {
"name": "test_data_passing_crate",
"version": "0.1.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
"targets": [
{
"Library": {
"crate_name": "test_data_passing_crate",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
},
{
"BuildScript": {
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "test_data_passing_crate",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "build_script_build"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.1.0"
},
"build_script_attrs": {
"data_glob": [
"**"
]
},
"license": "Apache-2.0"
}
},
"binary_crates": [],
"workspace_members": {
"direct-cargo-bazel-deps 0.0.1": ""
},
"conditions": {
"aarch64-apple-darwin": [
"aarch64-apple-darwin"
],
"aarch64-apple-ios": [
"aarch64-apple-ios"
],
"aarch64-apple-ios-sim": [
"aarch64-apple-ios-sim"
],
"aarch64-fuchsia": [
"aarch64-fuchsia"
],
"aarch64-linux-android": [
"aarch64-linux-android"
],
"aarch64-pc-windows-msvc": [
"aarch64-pc-windows-msvc"
],
"aarch64-unknown-linux-gnu": [
"aarch64-unknown-linux-gnu",
"aarch64-unknown-nixos-gnu"
],
"aarch64-unknown-nto-qnx710": [
"aarch64-unknown-nto-qnx710"
],
"arm-unknown-linux-gnueabi": [
"arm-unknown-linux-gnueabi"
],
"armv7-linux-androideabi": [
"armv7-linux-androideabi"
],
"armv7-unknown-linux-gnueabi": [
"armv7-unknown-linux-gnueabi"
],
"i686-apple-darwin": [
"i686-apple-darwin"
],
"i686-linux-android": [
"i686-linux-android"
],
"i686-pc-windows-msvc": [
"i686-pc-windows-msvc"
],
"i686-unknown-freebsd": [
"i686-unknown-freebsd"
],
"i686-unknown-linux-gnu": [
"i686-unknown-linux-gnu"
],
"powerpc-unknown-linux-gnu": [
"powerpc-unknown-linux-gnu"
],
"riscv32imc-unknown-none-elf": [
"riscv32imc-unknown-none-elf"
],
"riscv64gc-unknown-none-elf": [
"riscv64gc-unknown-none-elf"
],
"s390x-unknown-linux-gnu": [
"s390x-unknown-linux-gnu"
],
"thumbv7em-none-eabi": [
"thumbv7em-none-eabi"
],
"thumbv8m.main-none-eabi": [
"thumbv8m.main-none-eabi"
],
"wasm32-unknown-unknown": [
"wasm32-unknown-unknown"
],
"wasm32-wasi": [
"wasm32-wasi"
],
"x86_64-apple-darwin": [
"x86_64-apple-darwin"
],
"x86_64-apple-ios": [
"x86_64-apple-ios"
],
"x86_64-fuchsia": [
"x86_64-fuchsia"
],
"x86_64-linux-android": [
"x86_64-linux-android"
],
"x86_64-pc-windows-msvc": [
"x86_64-pc-windows-msvc"
],
"x86_64-unknown-freebsd": [
"x86_64-unknown-freebsd"
],
"x86_64-unknown-linux-gnu": [
"x86_64-unknown-linux-gnu",
"x86_64-unknown-nixos-gnu"
],
"x86_64-unknown-none": [
"x86_64-unknown-none"
]
},
"direct_deps": [
"test_data_passing_crate 0.1.0"
],
"direct_dev_deps": []
}

View File

@ -0,0 +1,201 @@
{
"checksum": "ac94129a42c5fbe365ac7f4191548b0ad5166d0f038e96d47f4637933070a05e",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
"version": "0.0.1",
"repository": null,
"targets": [
{
"Library": {
"crate_name": "direct_cargo_bazel_deps",
"crate_root": ".direct_cargo_bazel_deps.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "direct_cargo_bazel_deps",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "test_data_passing_crate"
}
],
"selects": {}
},
"edition": "2018",
"version": "0.0.1"
},
"license": null
},
"test_data_passing_crate 0.1.0": {
"name": "test_data_passing_crate",
"version": "0.1.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
"targets": [
{
"Library": {
"crate_name": "test_data_passing_crate",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
},
{
"BuildScript": {
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "test_data_passing_crate",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "build_script_build"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.1.0"
},
"build_script_attrs": {
"data_glob": [
"**"
]
},
"license": "Apache-2.0",
"alias_rule": "opt"
}
},
"binary_crates": [],
"workspace_members": {
"direct-cargo-bazel-deps 0.0.1": ""
},
"conditions": {
"aarch64-apple-darwin": [
"aarch64-apple-darwin"
],
"aarch64-apple-ios": [
"aarch64-apple-ios"
],
"aarch64-apple-ios-sim": [
"aarch64-apple-ios-sim"
],
"aarch64-fuchsia": [
"aarch64-fuchsia"
],
"aarch64-linux-android": [
"aarch64-linux-android"
],
"aarch64-pc-windows-msvc": [
"aarch64-pc-windows-msvc"
],
"aarch64-unknown-linux-gnu": [
"aarch64-unknown-linux-gnu",
"aarch64-unknown-nixos-gnu"
],
"aarch64-unknown-nto-qnx710": [
"aarch64-unknown-nto-qnx710"
],
"arm-unknown-linux-gnueabi": [
"arm-unknown-linux-gnueabi"
],
"armv7-linux-androideabi": [
"armv7-linux-androideabi"
],
"armv7-unknown-linux-gnueabi": [
"armv7-unknown-linux-gnueabi"
],
"i686-apple-darwin": [
"i686-apple-darwin"
],
"i686-linux-android": [
"i686-linux-android"
],
"i686-pc-windows-msvc": [
"i686-pc-windows-msvc"
],
"i686-unknown-freebsd": [
"i686-unknown-freebsd"
],
"i686-unknown-linux-gnu": [
"i686-unknown-linux-gnu"
],
"powerpc-unknown-linux-gnu": [
"powerpc-unknown-linux-gnu"
],
"riscv32imc-unknown-none-elf": [
"riscv32imc-unknown-none-elf"
],
"riscv64gc-unknown-none-elf": [
"riscv64gc-unknown-none-elf"
],
"s390x-unknown-linux-gnu": [
"s390x-unknown-linux-gnu"
],
"thumbv7em-none-eabi": [
"thumbv7em-none-eabi"
],
"thumbv8m.main-none-eabi": [
"thumbv8m.main-none-eabi"
],
"wasm32-unknown-unknown": [
"wasm32-unknown-unknown"
],
"wasm32-wasi": [
"wasm32-wasi"
],
"x86_64-apple-darwin": [
"x86_64-apple-darwin"
],
"x86_64-apple-ios": [
"x86_64-apple-ios"
],
"x86_64-fuchsia": [
"x86_64-fuchsia"
],
"x86_64-linux-android": [
"x86_64-linux-android"
],
"x86_64-pc-windows-msvc": [
"x86_64-pc-windows-msvc"
],
"x86_64-unknown-freebsd": [
"x86_64-unknown-freebsd"
],
"x86_64-unknown-linux-gnu": [
"x86_64-unknown-linux-gnu",
"x86_64-unknown-nixos-gnu"
],
"x86_64-unknown-none": [
"x86_64-unknown-none"
]
},
"direct_deps": [
"test_data_passing_crate 0.1.0"
],
"direct_dev_deps": []
}

View File

@ -0,0 +1,200 @@
{
"checksum": "32e2ef845e4e602a87aa07fdb983aa69e8dd263e4e46edce7dde5ae229f172f9",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
"version": "0.0.1",
"repository": null,
"targets": [
{
"Library": {
"crate_name": "direct_cargo_bazel_deps",
"crate_root": ".direct_cargo_bazel_deps.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "direct_cargo_bazel_deps",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "test_data_passing_crate"
}
],
"selects": {}
},
"edition": "2018",
"version": "0.0.1"
},
"license": null
},
"test_data_passing_crate 0.1.0": {
"name": "test_data_passing_crate",
"version": "0.1.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
"targets": [
{
"Library": {
"crate_name": "test_data_passing_crate",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
},
{
"BuildScript": {
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "test_data_passing_crate",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "build_script_build"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.1.0"
},
"build_script_attrs": {
"data_glob": [
"**"
]
},
"license": "Apache-2.0"
}
},
"binary_crates": [],
"workspace_members": {
"direct-cargo-bazel-deps 0.0.1": ""
},
"conditions": {
"aarch64-apple-darwin": [
"aarch64-apple-darwin"
],
"aarch64-apple-ios": [
"aarch64-apple-ios"
],
"aarch64-apple-ios-sim": [
"aarch64-apple-ios-sim"
],
"aarch64-fuchsia": [
"aarch64-fuchsia"
],
"aarch64-linux-android": [
"aarch64-linux-android"
],
"aarch64-pc-windows-msvc": [
"aarch64-pc-windows-msvc"
],
"aarch64-unknown-linux-gnu": [
"aarch64-unknown-linux-gnu",
"aarch64-unknown-nixos-gnu"
],
"aarch64-unknown-nto-qnx710": [
"aarch64-unknown-nto-qnx710"
],
"arm-unknown-linux-gnueabi": [
"arm-unknown-linux-gnueabi"
],
"armv7-linux-androideabi": [
"armv7-linux-androideabi"
],
"armv7-unknown-linux-gnueabi": [
"armv7-unknown-linux-gnueabi"
],
"i686-apple-darwin": [
"i686-apple-darwin"
],
"i686-linux-android": [
"i686-linux-android"
],
"i686-pc-windows-msvc": [
"i686-pc-windows-msvc"
],
"i686-unknown-freebsd": [
"i686-unknown-freebsd"
],
"i686-unknown-linux-gnu": [
"i686-unknown-linux-gnu"
],
"powerpc-unknown-linux-gnu": [
"powerpc-unknown-linux-gnu"
],
"riscv32imc-unknown-none-elf": [
"riscv32imc-unknown-none-elf"
],
"riscv64gc-unknown-none-elf": [
"riscv64gc-unknown-none-elf"
],
"s390x-unknown-linux-gnu": [
"s390x-unknown-linux-gnu"
],
"thumbv7em-none-eabi": [
"thumbv7em-none-eabi"
],
"thumbv8m.main-none-eabi": [
"thumbv8m.main-none-eabi"
],
"wasm32-unknown-unknown": [
"wasm32-unknown-unknown"
],
"wasm32-wasi": [
"wasm32-wasi"
],
"x86_64-apple-darwin": [
"x86_64-apple-darwin"
],
"x86_64-apple-ios": [
"x86_64-apple-ios"
],
"x86_64-fuchsia": [
"x86_64-fuchsia"
],
"x86_64-linux-android": [
"x86_64-linux-android"
],
"x86_64-pc-windows-msvc": [
"x86_64-pc-windows-msvc"
],
"x86_64-unknown-freebsd": [
"x86_64-unknown-freebsd"
],
"x86_64-unknown-linux-gnu": [
"x86_64-unknown-linux-gnu",
"x86_64-unknown-nixos-gnu"
],
"x86_64-unknown-none": [
"x86_64-unknown-none"
]
},
"direct_deps": [
"test_data_passing_crate 0.1.0"
],
"direct_dev_deps": []
}

View File

@ -0,0 +1,201 @@
{
"checksum": "6d04daf0170bd6bcaed2c06d0c0c1db87317a820b1a5574a3fa5a23232070eba",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
"version": "0.0.1",
"repository": null,
"targets": [
{
"Library": {
"crate_name": "direct_cargo_bazel_deps",
"crate_root": ".direct_cargo_bazel_deps.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "direct_cargo_bazel_deps",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "test_data_passing_crate"
}
],
"selects": {}
},
"edition": "2018",
"version": "0.0.1"
},
"license": null
},
"test_data_passing_crate 0.1.0": {
"name": "test_data_passing_crate",
"version": "0.1.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
"targets": [
{
"Library": {
"crate_name": "test_data_passing_crate",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
},
{
"BuildScript": {
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "test_data_passing_crate",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "build_script_build"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.1.0"
},
"build_script_attrs": {
"data_glob": [
"**"
]
},
"license": "Apache-2.0",
"alias_rule": "fastbuild"
}
},
"binary_crates": [],
"workspace_members": {
"direct-cargo-bazel-deps 0.0.1": ""
},
"conditions": {
"aarch64-apple-darwin": [
"aarch64-apple-darwin"
],
"aarch64-apple-ios": [
"aarch64-apple-ios"
],
"aarch64-apple-ios-sim": [
"aarch64-apple-ios-sim"
],
"aarch64-fuchsia": [
"aarch64-fuchsia"
],
"aarch64-linux-android": [
"aarch64-linux-android"
],
"aarch64-pc-windows-msvc": [
"aarch64-pc-windows-msvc"
],
"aarch64-unknown-linux-gnu": [
"aarch64-unknown-linux-gnu",
"aarch64-unknown-nixos-gnu"
],
"aarch64-unknown-nto-qnx710": [
"aarch64-unknown-nto-qnx710"
],
"arm-unknown-linux-gnueabi": [
"arm-unknown-linux-gnueabi"
],
"armv7-linux-androideabi": [
"armv7-linux-androideabi"
],
"armv7-unknown-linux-gnueabi": [
"armv7-unknown-linux-gnueabi"
],
"i686-apple-darwin": [
"i686-apple-darwin"
],
"i686-linux-android": [
"i686-linux-android"
],
"i686-pc-windows-msvc": [
"i686-pc-windows-msvc"
],
"i686-unknown-freebsd": [
"i686-unknown-freebsd"
],
"i686-unknown-linux-gnu": [
"i686-unknown-linux-gnu"
],
"powerpc-unknown-linux-gnu": [
"powerpc-unknown-linux-gnu"
],
"riscv32imc-unknown-none-elf": [
"riscv32imc-unknown-none-elf"
],
"riscv64gc-unknown-none-elf": [
"riscv64gc-unknown-none-elf"
],
"s390x-unknown-linux-gnu": [
"s390x-unknown-linux-gnu"
],
"thumbv7em-none-eabi": [
"thumbv7em-none-eabi"
],
"thumbv8m.main-none-eabi": [
"thumbv8m.main-none-eabi"
],
"wasm32-unknown-unknown": [
"wasm32-unknown-unknown"
],
"wasm32-wasi": [
"wasm32-wasi"
],
"x86_64-apple-darwin": [
"x86_64-apple-darwin"
],
"x86_64-apple-ios": [
"x86_64-apple-ios"
],
"x86_64-fuchsia": [
"x86_64-fuchsia"
],
"x86_64-linux-android": [
"x86_64-linux-android"
],
"x86_64-pc-windows-msvc": [
"x86_64-pc-windows-msvc"
],
"x86_64-unknown-freebsd": [
"x86_64-unknown-freebsd"
],
"x86_64-unknown-linux-gnu": [
"x86_64-unknown-linux-gnu",
"x86_64-unknown-nixos-gnu"
],
"x86_64-unknown-none": [
"x86_64-unknown-none"
]
},
"direct_deps": [
"test_data_passing_crate 0.1.0"
],
"direct_dev_deps": []
}

View File

@ -0,0 +1,201 @@
{
"checksum": "3e7b2116f548d5af4c44284bf219c1fa06195a2952813a4b5b66a5d017024ddd",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
"version": "0.0.1",
"repository": null,
"targets": [
{
"Library": {
"crate_name": "direct_cargo_bazel_deps",
"crate_root": ".direct_cargo_bazel_deps.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "direct_cargo_bazel_deps",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "test_data_passing_crate"
}
],
"selects": {}
},
"edition": "2018",
"version": "0.0.1"
},
"license": null
},
"test_data_passing_crate 0.1.0": {
"name": "test_data_passing_crate",
"version": "0.1.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
"targets": [
{
"Library": {
"crate_name": "test_data_passing_crate",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
},
{
"BuildScript": {
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "test_data_passing_crate",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "build_script_build"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.1.0"
},
"build_script_attrs": {
"data_glob": [
"**"
]
},
"license": "Apache-2.0",
"alias_rule": "alias"
}
},
"binary_crates": [],
"workspace_members": {
"direct-cargo-bazel-deps 0.0.1": ""
},
"conditions": {
"aarch64-apple-darwin": [
"aarch64-apple-darwin"
],
"aarch64-apple-ios": [
"aarch64-apple-ios"
],
"aarch64-apple-ios-sim": [
"aarch64-apple-ios-sim"
],
"aarch64-fuchsia": [
"aarch64-fuchsia"
],
"aarch64-linux-android": [
"aarch64-linux-android"
],
"aarch64-pc-windows-msvc": [
"aarch64-pc-windows-msvc"
],
"aarch64-unknown-linux-gnu": [
"aarch64-unknown-linux-gnu",
"aarch64-unknown-nixos-gnu"
],
"aarch64-unknown-nto-qnx710": [
"aarch64-unknown-nto-qnx710"
],
"arm-unknown-linux-gnueabi": [
"arm-unknown-linux-gnueabi"
],
"armv7-linux-androideabi": [
"armv7-linux-androideabi"
],
"armv7-unknown-linux-gnueabi": [
"armv7-unknown-linux-gnueabi"
],
"i686-apple-darwin": [
"i686-apple-darwin"
],
"i686-linux-android": [
"i686-linux-android"
],
"i686-pc-windows-msvc": [
"i686-pc-windows-msvc"
],
"i686-unknown-freebsd": [
"i686-unknown-freebsd"
],
"i686-unknown-linux-gnu": [
"i686-unknown-linux-gnu"
],
"powerpc-unknown-linux-gnu": [
"powerpc-unknown-linux-gnu"
],
"riscv32imc-unknown-none-elf": [
"riscv32imc-unknown-none-elf"
],
"riscv64gc-unknown-none-elf": [
"riscv64gc-unknown-none-elf"
],
"s390x-unknown-linux-gnu": [
"s390x-unknown-linux-gnu"
],
"thumbv7em-none-eabi": [
"thumbv7em-none-eabi"
],
"thumbv8m.main-none-eabi": [
"thumbv8m.main-none-eabi"
],
"wasm32-unknown-unknown": [
"wasm32-unknown-unknown"
],
"wasm32-wasi": [
"wasm32-wasi"
],
"x86_64-apple-darwin": [
"x86_64-apple-darwin"
],
"x86_64-apple-ios": [
"x86_64-apple-ios"
],
"x86_64-fuchsia": [
"x86_64-fuchsia"
],
"x86_64-linux-android": [
"x86_64-linux-android"
],
"x86_64-pc-windows-msvc": [
"x86_64-pc-windows-msvc"
],
"x86_64-unknown-freebsd": [
"x86_64-unknown-freebsd"
],
"x86_64-unknown-linux-gnu": [
"x86_64-unknown-linux-gnu",
"x86_64-unknown-nixos-gnu"
],
"x86_64-unknown-none": [
"x86_64-unknown-none"
]
},
"direct_deps": [
"test_data_passing_crate 0.1.0"
],
"direct_dev_deps": []
}

View File

@ -0,0 +1,201 @@
{
"checksum": "c09c33e0b1322a6cd7e29aa3149ffc031c391244dbecdc0eb9fff07c81fd166c",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
"version": "0.0.1",
"repository": null,
"targets": [
{
"Library": {
"crate_name": "direct_cargo_bazel_deps",
"crate_root": ".direct_cargo_bazel_deps.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "direct_cargo_bazel_deps",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "test_data_passing_crate"
}
],
"selects": {}
},
"edition": "2018",
"version": "0.0.1"
},
"license": null
},
"test_data_passing_crate 0.1.0": {
"name": "test_data_passing_crate",
"version": "0.1.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
"targets": [
{
"Library": {
"crate_name": "test_data_passing_crate",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
},
{
"BuildScript": {
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "test_data_passing_crate",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "build_script_build"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.1.0"
},
"build_script_attrs": {
"data_glob": [
"**"
]
},
"license": "Apache-2.0",
"alias_rule": "dbg"
}
},
"binary_crates": [],
"workspace_members": {
"direct-cargo-bazel-deps 0.0.1": ""
},
"conditions": {
"aarch64-apple-darwin": [
"aarch64-apple-darwin"
],
"aarch64-apple-ios": [
"aarch64-apple-ios"
],
"aarch64-apple-ios-sim": [
"aarch64-apple-ios-sim"
],
"aarch64-fuchsia": [
"aarch64-fuchsia"
],
"aarch64-linux-android": [
"aarch64-linux-android"
],
"aarch64-pc-windows-msvc": [
"aarch64-pc-windows-msvc"
],
"aarch64-unknown-linux-gnu": [
"aarch64-unknown-linux-gnu",
"aarch64-unknown-nixos-gnu"
],
"aarch64-unknown-nto-qnx710": [
"aarch64-unknown-nto-qnx710"
],
"arm-unknown-linux-gnueabi": [
"arm-unknown-linux-gnueabi"
],
"armv7-linux-androideabi": [
"armv7-linux-androideabi"
],
"armv7-unknown-linux-gnueabi": [
"armv7-unknown-linux-gnueabi"
],
"i686-apple-darwin": [
"i686-apple-darwin"
],
"i686-linux-android": [
"i686-linux-android"
],
"i686-pc-windows-msvc": [
"i686-pc-windows-msvc"
],
"i686-unknown-freebsd": [
"i686-unknown-freebsd"
],
"i686-unknown-linux-gnu": [
"i686-unknown-linux-gnu"
],
"powerpc-unknown-linux-gnu": [
"powerpc-unknown-linux-gnu"
],
"riscv32imc-unknown-none-elf": [
"riscv32imc-unknown-none-elf"
],
"riscv64gc-unknown-none-elf": [
"riscv64gc-unknown-none-elf"
],
"s390x-unknown-linux-gnu": [
"s390x-unknown-linux-gnu"
],
"thumbv7em-none-eabi": [
"thumbv7em-none-eabi"
],
"thumbv8m.main-none-eabi": [
"thumbv8m.main-none-eabi"
],
"wasm32-unknown-unknown": [
"wasm32-unknown-unknown"
],
"wasm32-wasi": [
"wasm32-wasi"
],
"x86_64-apple-darwin": [
"x86_64-apple-darwin"
],
"x86_64-apple-ios": [
"x86_64-apple-ios"
],
"x86_64-fuchsia": [
"x86_64-fuchsia"
],
"x86_64-linux-android": [
"x86_64-linux-android"
],
"x86_64-pc-windows-msvc": [
"x86_64-pc-windows-msvc"
],
"x86_64-unknown-freebsd": [
"x86_64-unknown-freebsd"
],
"x86_64-unknown-linux-gnu": [
"x86_64-unknown-linux-gnu",
"x86_64-unknown-nixos-gnu"
],
"x86_64-unknown-none": [
"x86_64-unknown-none"
]
},
"direct_deps": [
"test_data_passing_crate 0.1.0"
],
"direct_dev_deps": []
}

View File

@ -0,0 +1,200 @@
{
"checksum": "3f83a573559bb275de726fa616be2f7092de1548b8b82b579fa58298a05f477d",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
"version": "0.0.1",
"repository": null,
"targets": [
{
"Library": {
"crate_name": "direct_cargo_bazel_deps",
"crate_root": ".direct_cargo_bazel_deps.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "direct_cargo_bazel_deps",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "test_data_passing_crate"
}
],
"selects": {}
},
"edition": "2018",
"version": "0.0.1"
},
"license": null
},
"test_data_passing_crate 0.1.0": {
"name": "test_data_passing_crate",
"version": "0.1.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
"targets": [
{
"Library": {
"crate_name": "test_data_passing_crate",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
},
{
"BuildScript": {
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "test_data_passing_crate",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "test_data_passing_crate 0.1.0",
"target": "build_script_build"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.1.0"
},
"build_script_attrs": {
"data_glob": [
"**"
]
},
"license": "Apache-2.0"
}
},
"binary_crates": [],
"workspace_members": {
"direct-cargo-bazel-deps 0.0.1": ""
},
"conditions": {
"aarch64-apple-darwin": [
"aarch64-apple-darwin"
],
"aarch64-apple-ios": [
"aarch64-apple-ios"
],
"aarch64-apple-ios-sim": [
"aarch64-apple-ios-sim"
],
"aarch64-fuchsia": [
"aarch64-fuchsia"
],
"aarch64-linux-android": [
"aarch64-linux-android"
],
"aarch64-pc-windows-msvc": [
"aarch64-pc-windows-msvc"
],
"aarch64-unknown-linux-gnu": [
"aarch64-unknown-linux-gnu",
"aarch64-unknown-nixos-gnu"
],
"aarch64-unknown-nto-qnx710": [
"aarch64-unknown-nto-qnx710"
],
"arm-unknown-linux-gnueabi": [
"arm-unknown-linux-gnueabi"
],
"armv7-linux-androideabi": [
"armv7-linux-androideabi"
],
"armv7-unknown-linux-gnueabi": [
"armv7-unknown-linux-gnueabi"
],
"i686-apple-darwin": [
"i686-apple-darwin"
],
"i686-linux-android": [
"i686-linux-android"
],
"i686-pc-windows-msvc": [
"i686-pc-windows-msvc"
],
"i686-unknown-freebsd": [
"i686-unknown-freebsd"
],
"i686-unknown-linux-gnu": [
"i686-unknown-linux-gnu"
],
"powerpc-unknown-linux-gnu": [
"powerpc-unknown-linux-gnu"
],
"riscv32imc-unknown-none-elf": [
"riscv32imc-unknown-none-elf"
],
"riscv64gc-unknown-none-elf": [
"riscv64gc-unknown-none-elf"
],
"s390x-unknown-linux-gnu": [
"s390x-unknown-linux-gnu"
],
"thumbv7em-none-eabi": [
"thumbv7em-none-eabi"
],
"thumbv8m.main-none-eabi": [
"thumbv8m.main-none-eabi"
],
"wasm32-unknown-unknown": [
"wasm32-unknown-unknown"
],
"wasm32-wasi": [
"wasm32-wasi"
],
"x86_64-apple-darwin": [
"x86_64-apple-darwin"
],
"x86_64-apple-ios": [
"x86_64-apple-ios"
],
"x86_64-fuchsia": [
"x86_64-fuchsia"
],
"x86_64-linux-android": [
"x86_64-linux-android"
],
"x86_64-pc-windows-msvc": [
"x86_64-pc-windows-msvc"
],
"x86_64-unknown-freebsd": [
"x86_64-unknown-freebsd"
],
"x86_64-unknown-linux-gnu": [
"x86_64-unknown-linux-gnu",
"x86_64-unknown-nixos-gnu"
],
"x86_64-unknown-none": [
"x86_64-unknown-none"
]
},
"direct_deps": [
"test_data_passing_crate 0.1.0"
],
"direct_dev_deps": []
}

View File

@ -0,0 +1,9 @@
#[test]
fn out_dir() {
assert!(test_data_passing_crate::get_out_dir().contains("-dbg"));
}
#[test]
fn opt_level() {
assert_eq!(test_data_passing_crate::get_opt_level(), "0");
}

View File

@ -0,0 +1,9 @@
#[test]
fn out_dir() {
assert!(test_data_passing_crate::get_out_dir().contains("-fastbuild"));
}
#[test]
fn opt_level() {
assert_eq!(test_data_passing_crate::get_opt_level(), "0");
}

View File

@ -0,0 +1,9 @@
#[test]
fn out_dir() {
assert!(test_data_passing_crate::get_out_dir().contains("-opt"));
}
#[test]
fn opt_level() {
assert_eq!(test_data_passing_crate::get_opt_level(), "3");
}

View File

@ -1,5 +1,5 @@
{
"checksum": "d06c1d6cfea4c98073060e84569383bef0900acf96b09841e6d54c9c03dfd19c",
"checksum": "81278aac722061d149e1cecdee4fdfe614f8c42627c6e64792449f3591279102",
"crates": {
"aho-corasick 0.7.20": {
"name": "aho-corasick",

View File

@ -1,5 +1,5 @@
{
"checksum": "f933177c8a27f7ffd77f280a77defad18c7f20ad0832c50e730dc0d8066f5443",
"checksum": "7127321ba0ec6cb4529df5430d13b176bb4d31ee697c50249aa76289748c099c",
"crates": {
"autocfg 1.1.0": {
"name": "autocfg",

View File

@ -1,5 +1,5 @@
{
"checksum": "5a8aa8e17b51327567c06bb9799eeff41574714f66c9f9332ea3c6dfaf1ccb86",
"checksum": "fcd9742d74813b2b09cd013b9412095164b196a608de350ab4af22bd8e229e0a",
"crates": {
"ansi_term 0.12.1": {
"name": "ansi_term",

View File

@ -1,5 +1,5 @@
{
"checksum": "23bc2dadb3703b038eec29255a02b64270372bb41c4540dd123ec5d7a13a5d36",
"checksum": "50607b73bd3cfe0f233c7f76d1a9988b7a0d2a61da64c9595abfd71412f44a70",
"crates": {
"aho-corasick 0.7.20": {
"name": "aho-corasick",

View File

@ -1,5 +1,5 @@
{
"checksum": "b190727d2cb11df3d7220b685e2577304d59b299c97e07a8faf72fc6c9ae1647",
"checksum": "9d53d217f13cd36409835470f17d97daaca2881b591cd06ac73731540f3f4aa6",
"crates": {
"async-trait 0.1.64": {
"name": "async-trait",

View File

@ -1,5 +1,5 @@
{
"checksum": "36ccf59144d73243a0df6c7f52937cea1ef8e417a59f28c954bf97e3323e706f",
"checksum": "73438207d6c75c04bb2333c165c6c254a5cfee014fef05e5559e38343d47277f",
"crates": {
"cc 1.0.82": {
"name": "cc",

View File

@ -1,5 +1,5 @@
{
"checksum": "a612ef778a821878600d98401312787b8191796f048718d4ba4fc6b9946e61cc",
"checksum": "6494a34fe438b39d9bbcf4d0fc7f5d1f3954f99214b62b47981de74b12f5035d",
"crates": {
"anstyle 1.0.1": {
"name": "anstyle",

View File

@ -0,0 +1,6 @@
###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################

File diff suppressed because it is too large Load Diff

View File

@ -58,7 +58,7 @@ load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencie
crate_universe_dependencies(bootstrap = True)
load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "splicing_config")
load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "render_config", "splicing_config")
load("//bazel/cargo:crates_repository.bzl", CARGO_ANNOTATIONS = "ANNOTATIONS", CARGO_PACKAGES = "PACKAGES")
crates_repository(
@ -69,6 +69,9 @@ crates_repository(
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//bazel/cargo:cargo-bazel-lock.json",
packages = CARGO_PACKAGES,
render_config = render_config(
default_alias_rule = "opt",
),
splicing_config = splicing_config(
resolver_version = "2",
),

View File

@ -1,5 +1,5 @@
{
"checksum": "53423455cd14d6eef3b1e1583b8c53c7b7c99fac16da3e18626328fc5e9f074d",
"checksum": "c20bfaa6cbc9895839eb40069c79092c8ad485de88ac0054fffa2c986470430d",
"crates": {
"addr2line 0.21.0": {
"name": "addr2line",

View File

@ -71,3 +71,9 @@ rust_common = struct(
crate_group_info = CrateGroupInfo,
default_version = DEFAULT_RUST_VERSION,
)
COMMON_PROVIDERS = [
CrateInfo,
DepInfo,
DefaultInfo,
]

View File

@ -15,7 +15,7 @@
"""Rust rule implementations"""
load("@bazel_skylib//lib:paths.bzl", "paths")
load("//rust/private:common.bzl", "rust_common")
load("//rust/private:common.bzl", "COMMON_PROVIDERS", "rust_common")
load("//rust/private:providers.bzl", "BuildInfo")
load("//rust/private:rustc.bzl", "rustc_compile_action")
load(
@ -760,15 +760,9 @@ _rust_test_attrs = dict({
"_use_grep_includes": attr.bool(default = True),
}.items() + _coverage_attrs.items() + _experimental_use_cc_common_link_attrs.items())
_common_providers = [
rust_common.crate_info,
rust_common.dep_info,
DefaultInfo,
]
rust_library = rule(
implementation = _rust_library_impl,
provides = _common_providers,
provides = COMMON_PROVIDERS,
attrs = dict(_common_attrs.items() + {
"disable_pipelining": attr.bool(
default = False,
@ -961,7 +955,7 @@ _proc_macro_dep_transition = transition(
rust_proc_macro = rule(
implementation = _rust_proc_macro_impl,
provides = _common_providers,
provides = COMMON_PROVIDERS,
# Start by copying the common attributes, then override the `deps` attribute
# to apply `_proc_macro_dep_transition`. To add this transition we additionally
# need to declare `_allowlist_function_transition`, see
@ -1048,7 +1042,7 @@ _rust_binary_transition = transition(
rust_binary = rule(
implementation = _rust_binary_impl,
provides = _common_providers,
provides = COMMON_PROVIDERS,
attrs = dict(_common_attrs.items() + _rust_binary_attrs.items() + {
"platform": attr.label(
doc = "Optional platform to transition the binary to.",
@ -1192,7 +1186,7 @@ def _common_attrs_for_binary_without_process_wrapper(attrs):
# setting it to None, which the functions in rustc detect and build accordingly.
rust_binary_without_process_wrapper = rule(
implementation = _rust_binary_impl,
provides = _common_providers,
provides = COMMON_PROVIDERS,
attrs = _common_attrs_for_binary_without_process_wrapper(_common_attrs.items() + _rust_binary_attrs.items() + {
"platform": attr.label(
doc = "Optional platform to transition the binary to.",
@ -1215,7 +1209,7 @@ rust_binary_without_process_wrapper = rule(
rust_library_without_process_wrapper = rule(
implementation = _rust_library_impl,
provides = _common_providers,
provides = COMMON_PROVIDERS,
attrs = dict(_common_attrs_for_binary_without_process_wrapper(_common_attrs).items()),
fragments = ["cpp"],
host_fragments = ["cpp"],
@ -1243,7 +1237,7 @@ _rust_test_transition = transition(
rust_test = rule(
implementation = _rust_test_impl,
provides = _common_providers,
provides = COMMON_PROVIDERS,
attrs = dict(_common_attrs.items() + _rust_test_attrs.items() + {
"platform": attr.label(
doc = "Optional platform to transition the test to.",

View File

@ -14,6 +14,10 @@
"""Module with Rust definitions required to write custom Rust rules."""
load(
"//rust/private:common.bzl",
_COMMON_PROVIDERS = "COMMON_PROVIDERS",
)
load(
"//rust/private:providers.bzl",
_BuildInfo = "BuildInfo",
@ -30,3 +34,5 @@ CrateInfo = _CrateInfo
DepInfo = _DepInfo
DepVariantInfo = _DepVariantInfo
TestCrateInfo = _TestCrateInfo
COMMON_PROVIDERS = _COMMON_PROVIDERS

View File

@ -1,5 +1,5 @@
{
"checksum": "29b105854fc12fdc097f54543723b8a0b164fa3234a9d07ac76150ebd99ef2c0",
"checksum": "d7e3fe8a31794aa575a3c52503341feed25a08459d6c91bd2ac1753dbe8caf7e",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",