Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various cleanups #1828

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ To build with a particular version of the Rust compiler, pass that version to [`
```python
rust_register_toolchains(
edition = "2021",
versions = ["1.66.1"],
versions = [
"1.66.1"
],
)
```

Expand Down
3 changes: 2 additions & 1 deletion proto/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# buildifier: disable=module-docstring
"""Dependencies for Rust proto rules"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//proto/3rdparty/crates:defs.bzl", "crate_repositories")
Expand Down
8 changes: 6 additions & 2 deletions rust/private/clippy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,12 @@ rust_clippy_aspect = aspect(
doc = "The desired `--error-format` flags for clippy",
default = "//:error_format",
),
"_extra_rustc_flag": attr.label(default = "//:extra_rustc_flag"),
"_extra_rustc_flags": attr.label(default = "//:extra_rustc_flags"),
"_extra_rustc_flag": attr.label(
default = Label("//:extra_rustc_flag"),
),
"_extra_rustc_flags": attr.label(
default = Label("//:extra_rustc_flags"),
),
"_process_wrapper": attr.label(
doc = "A process wrapper for running clippy on all platforms",
default = Label("//util/process_wrapper"),
Expand Down
3 changes: 2 additions & 1 deletion rust/private/dummy_cc_toolchain/dummy_cc_toolchain.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# buildifier: disable=module-docstring
"""Cc toolchain definitions for use on wasm platforms"""

def _dummy_cc_toolchain_impl(_ctx):
# The `all_files` attribute is referenced by rustc_compile_action().
return [platform_common.ToolchainInfo(all_files = depset([]))]
Expand Down
3 changes: 2 additions & 1 deletion rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# buildifier: disable=module-docstring
"""Rust rule implementations"""

load("@bazel_skylib//lib:paths.bzl", "paths")
load("//rust/private:common.bzl", "rust_common")
load("//rust/private:rustc.bzl", "rustc_compile_action")
Expand Down
23 changes: 2 additions & 21 deletions rust/private/transitions.bzl
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
# buildifier: disable=module-docstring
load("//rust:defs.bzl", "rust_common")

def _wasm_bindgen_transition(_settings, _attr):
"""The implementation of the `wasm_bindgen_transition` transition

Args:
_settings (dict): A dict {String:Object} of all settings declared
in the inputs parameter to `transition()`
_attr (dict): A dict of attributes and values of the rule to which
the transition is attached

Returns:
dict: A dict of new build settings values to apply
"""
return {"//command_line_option:platforms": str(Label("//rust/platform:wasm"))}
"""Internal transition implementations for core Rust rules"""

wasm_bindgen_transition = transition(
implementation = _wasm_bindgen_transition,
inputs = [],
outputs = ["//command_line_option:platforms"],
)
load("//rust:defs.bzl", "rust_common")

def _import_macro_dep_bootstrap_transition(_settings, _attr):
"""The implementation of the `import_macro_dep_bootstrap_transition` transition.
Expand Down
2 changes: 1 addition & 1 deletion rust/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ rust_toolchain = rule(
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
),
"_pipelined_compilation": attr.label(
default = "@rules_rust//rust/settings:pipelined_compilation",
default = Label("//rust/settings:pipelined_compilation"),
),
"_rename_first_party_crates": attr.label(
default = Label("//rust/settings:rename_first_party_crates"),
Expand Down
3 changes: 2 additions & 1 deletion test/load_arbitrary_tool/load_arbitrary_tool_test.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# buildifier: disable=module-docstring
"""Tests for `load_arbitrary_tool`"""

load("//rust:repositories.bzl", "load_arbitrary_tool")
load("//rust/platform:triple.bzl", "get_host_triple")
load("//rust/platform:triple_mappings.bzl", "system_to_binary_ext")
Expand Down
1 change: 1 addition & 0 deletions wasm_bindgen/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ bzl_library(
deps = [
"//rust:bzl_lib",
"//wasm_bindgen/3rdparty:bzl_lib",
"//wasm_bindgen/private:bzl_lib",
],
)

Expand Down
9 changes: 9 additions & 0 deletions wasm_bindgen/private/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

bzl_library(
name = "bzl_lib",
srcs = [
"transitions.bzl",
],
visibility = ["//wasm_bindgen:__pkg__"],
)
21 changes: 21 additions & 0 deletions wasm_bindgen/private/transitions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Transition implementations for wasm-bindgen rust Rules"""

def _wasm_bindgen_transition(_settings, _attr):
"""The implementation of the `wasm_bindgen_transition` transition

Args:
_settings (dict): A dict {String:Object} of all settings declared
in the inputs parameter to `transition()`
_attr (dict): A dict of attributes and values of the rule to which
the transition is attached

Returns:
dict: A dict of new build settings values to apply
"""
return {"//command_line_option:platforms": str(Label("//rust/platform:wasm"))}

wasm_bindgen_transition = transition(
implementation = _wasm_bindgen_transition,
inputs = [],
outputs = ["//command_line_option:platforms"],
)
3 changes: 2 additions & 1 deletion wasm_bindgen/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# buildifier: disable=module-docstring
"""Dependency definitions for wasm-bindgen rules"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//wasm_bindgen/3rdparty/crates:defs.bzl", "crate_repositories")
Expand Down
7 changes: 3 additions & 4 deletions wasm_bindgen/wasm_bindgen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# buildifier: disable=module-docstring
load("//rust:defs.bzl", "rust_common")
"""Bazel rules for [wasm-bindgen](https://crates.io/crates/wasm-bindgen)"""

# buildifier: disable=bzl-visibility
load("//rust/private:transitions.bzl", "wasm_bindgen_transition")
load("//rust:defs.bzl", "rust_common")
load(
"//wasm_bindgen:providers.bzl",
"DeclarationInfo",
"JSModuleInfo",
)
load("//wasm_bindgen/private:transitions.bzl", "wasm_bindgen_transition")

_WASM_BINDGEN_DOC = """\
Generates javascript and typescript bindings for a webassembly module using [wasm-bindgen][ws].
Expand Down