diff --git a/rust/defs.bzl b/rust/defs.bzl index 7c9724399e..8702027ad2 100644 --- a/rust/defs.bzl +++ b/rust/defs.bzl @@ -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", ) @@ -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. diff --git a/rust/private/BUILD.bazel b/rust/private/BUILD.bazel index 3c963cdcb5..99d0fd79fd 100644 --- a/rust/private/BUILD.bazel +++ b/rust/private/BUILD.bazel @@ -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( @@ -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"], diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index 484e35d34e..402addaf16 100644 --- a/rust/private/rust.bzl +++ b/rust/private/rust.bzl @@ -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"), @@ -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, )