Skip to content

Commit

Permalink
Run buildifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinh Tran committed Sep 26, 2023
1 parent 93c0fbe commit ab05446
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions rust/private/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ CrateInfo = provider(
"owner": "Label: The label of the target that produced this CrateInfo",
"proc_macro_deps": "depset[DepVariantInfo]: This crate's rust proc_macro dependencies' providers.",
"root": "File: The source File entrypoint to this crate, eg. lib.rs",
# TODO: Remove `_rustc_env_attr` after refactoring rust_test to only rely on rustc_env
"_rustc_env_attr": "Dict[String, String]: Additional `\"key\": \"value\"` environment variables to set for rustc.",
"rustc_env": "Dict[String, String]: Additional `\"key\": \"value\"` environment variables to set for rustc.",
"rustc_env_files": "[File]: Files containing additional environment variables to set for rustc.",
"srcs": "depset[File]: All source Files that are part of the crate.",
Expand All @@ -43,6 +41,8 @@ CrateInfo = provider(
"str, optional: The original crate type for targets generated using a previously defined " +
"crate (typically tests using the `rust_test::crate` attribute)"
),
# TODO: Remove `_rustc_env_attr` after refactoring rust_test to only rely on rustc_env
"_rustc_env_attr": "Dict[String, String]: Additional `\"key\": \"value\"` environment variables to set for rustc.",
},
)

Expand Down
6 changes: 2 additions & 4 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,21 @@

"""Rust rule implementations"""

load("@bazel_skylib//lib:paths.bzl", "paths")
load("//rust/private:common.bzl", "rust_common")
load("//rust/private:providers.bzl", "BuildInfo")
load("//rust/private:rustc.bzl", "rustc_compile_action")
load(
"//rust/private:utils.bzl",
"can_build_metadata",
"compute_crate_name",
"crate_root_src",
"create_crate_info_dict",
"dedent",
"determine_output_hash",
"expand_dict_value_locations",
"find_toolchain",
"get_edition",
"get_import_macro_deps",
"transform_deps",
"create_crate_info_dict",
"get_edition",
"transform_sources",
)
# TODO(marco): Separate each rule into its own file.
Expand Down
1 change: 0 additions & 1 deletion rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

"""Functionality for constructing actions that invoke the Rust compiler"""

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load(
"@bazel_tools//tools/build_defs/cc:action_names.bzl",
Expand Down
12 changes: 9 additions & 3 deletions rust/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ def _determine_lib_name(name, crate_type, toolchain, lib_hash = None):
extension = extension,
)


def transform_sources(ctx, srcs, crate_root):
"""Creates symlinks of the source files if needed.
Expand Down Expand Up @@ -804,9 +803,8 @@ def transform_sources(ctx, srcs, crate_root):

return generated_sources, generated_root


def get_edition(attr, toolchain, label):
"""Returns the Rust edition from either the current rule's attirbutes or the current `rust_toolchain`
"""Returns the Rust edition from either the current rule's attributes or the current `rust_toolchain`
Args:
attr (struct): The current rule's attributes
Expand Down Expand Up @@ -860,6 +858,14 @@ def create_crate_info_dict(ctx, toolchain, crate_type):
The function is currently used as a callback to support constructing CrateInfo in rustc_compile_action
to ensure `CrateInfo.rustc_env` is fully loaded with all the env vars passed to rustc.
Args:
ctx (struct): The current rule's context
toolchain (toolchain): The rust toolchain
crate_type (String): one of lib|rlib|dylib|staticlib|cdylib|proc-macro
Returns:
File: The created symlink if a non-generated file, or the file itself.
"""
crate_name = compute_crate_name(ctx.workspace_name, ctx.label, toolchain, ctx.attr.crate_name)
crate_root = getattr(ctx.file, "crate_root", None)
Expand Down

0 comments on commit ab05446

Please sign in to comment.