Skip to content

Commit

Permalink
Move implementation detail settings into private module
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre committed Dec 4, 2023
1 parent 01a760e commit 6b332cf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
8 changes: 0 additions & 8 deletions rust/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ load(
_extra_exec_rustc_flags = "extra_exec_rustc_flags",
_extra_rustc_flag = "extra_rustc_flag",
_extra_rustc_flags = "extra_rustc_flags",
_is_proc_macro_dep = "is_proc_macro_dep",
_is_proc_macro_dep_enabled = "is_proc_macro_dep_enabled",
_no_std = "no_std",
_per_crate_rustc_flag = "per_crate_rustc_flag",
)
Expand Down Expand Up @@ -124,12 +122,6 @@ extra_exec_rustc_flag = _extra_exec_rustc_flag
extra_exec_rustc_flags = _extra_exec_rustc_flags
# See @rules_rust//rust/private:rustc.bzl for a complete description.

is_proc_macro_dep = _is_proc_macro_dep
# See @rules_rust//rust/private:rustc.bzl for a complete description.

is_proc_macro_dep_enabled = _is_proc_macro_dep_enabled
# See @rules_rust//rust/private:rustc.bzl for a complete description.

per_crate_rustc_flag = _per_crate_rustc_flag
# See @rules_rust//rust/private:rustc.bzl for a complete description.

Expand Down
19 changes: 19 additions & 0 deletions rust/private/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//rust/private:rust_analyzer.bzl", "rust_analyzer_detect_sysroot")
load("//rust/private:rustc.bzl", "is_proc_macro_dep", "is_proc_macro_dep_enabled")
load("//rust/private:stamp.bzl", "stamp_build_setting")

bzl_library(
Expand All @@ -11,6 +12,24 @@ bzl_library(

stamp_build_setting(name = "stamp")

# This setting may be used to identify dependencies of proc-macro-s.
# This feature is only enabled if `is_proc_macro_dep_enabled` is true.
# Its value controls the BAZEL_RULES_RUST_IS_PROC_MACRO_DEP environment variable
# made available to the rustc invocation.
is_proc_macro_dep(
name = "is_proc_macro_dep",
build_setting_default = False,
visibility = ["//visibility:public"],
)

# This setting enables the feature to identify dependencies of proc-macro-s,
# see `is_proc_macro_dep`.
is_proc_macro_dep_enabled(
name = "is_proc_macro_dep_enabled",
build_setting_default = False,
visibility = ["//visibility:public"],
)

rust_analyzer_detect_sysroot(
name = "rust_analyzer_detect_sysroot",
visibility = ["//visibility:public"],
Expand Down
12 changes: 6 additions & 6 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,10 @@ _common_attrs = {
cfg = "exec",
),
"_is_proc_macro_dep": attr.label(
default = Label("//:is_proc_macro_dep"),
default = Label("//rust/private:is_proc_macro_dep"),
),
"_is_proc_macro_dep_enabled": attr.label(
default = Label("//:is_proc_macro_dep_enabled"),
default = Label("//rust/private:is_proc_macro_dep_enabled"),
),
"_per_crate_rustc_flag": attr.label(
default = Label("//:experimental_per_crate_rustc_flag"),
Expand Down Expand Up @@ -876,14 +876,14 @@ rust_shared_library = rule(
)

def _proc_macro_dep_transition_impl(settings, _attr):
if settings["//:is_proc_macro_dep_enabled"]:
return {"//:is_proc_macro_dep": True}
if settings["//rust/private:is_proc_macro_dep_enabled"]:
return {"//rust/private:is_proc_macro_dep": True}
else:
return []

_proc_macro_dep_transition = transition(
inputs = ["//:is_proc_macro_dep_enabled"],
outputs = ["//:is_proc_macro_dep"],
inputs = ["//rust/private:is_proc_macro_dep_enabled"],
outputs = ["//rust/private:is_proc_macro_dep"],
implementation = _proc_macro_dep_transition_impl,
)

Expand Down

0 comments on commit 6b332cf

Please sign in to comment.