From b8c0565788ef5c8341e90007846e221bc9419951 Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Mon, 4 Dec 2023 07:48:23 -0800 Subject: [PATCH] Move implementation detail settings into private module --- BUILD.bazel | 20 ------------------- rust/defs.bzl | 8 -------- rust/private/BUILD.bazel | 19 ++++++++++++++++++ rust/private/rust.bzl | 12 +++++------ .../is_proc_macro_dep_test.bzl | 14 +++++++++---- 5 files changed, 35 insertions(+), 38 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 2eb9e03a25..d531bd5a2f 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -9,8 +9,6 @@ load( "extra_exec_rustc_flags", "extra_rustc_flag", "extra_rustc_flags", - "is_proc_macro_dep", - "is_proc_macro_dep_enabled", "no_std", "per_crate_rustc_flag", ) @@ -40,24 +38,6 @@ clippy_flags( visibility = ["//visibility:public"], ) -# 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"], -) - # This setting may be used to pass extra options to rustc from the command line # in non-exec configuration. # It applies across all targets whereas the rustc_flags option on targets applies only 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, ) diff --git a/test/unit/is_proc_macro_dep/is_proc_macro_dep_test.bzl b/test/unit/is_proc_macro_dep/is_proc_macro_dep_test.bzl index eb947bde22..26e2dcd7a1 100644 --- a/test/unit/is_proc_macro_dep/is_proc_macro_dep_test.bzl +++ b/test/unit/is_proc_macro_dep/is_proc_macro_dep_test.bzl @@ -31,19 +31,25 @@ attach_dep_actions_aspect = rule( ) def _enable_is_proc_macro_dep_transition_impl(_settings, _attr): - return {"//:is_proc_macro_dep_enabled": True} + return {"//rust/private:is_proc_macro_dep_enabled": True} enable_is_proc_macro_dep_transition = transition( inputs = [], - outputs = ["//:is_proc_macro_dep_enabled"], + outputs = ["//rust/private:is_proc_macro_dep_enabled"], implementation = _enable_is_proc_macro_dep_transition_impl, ) attach_dep_actions_and_enable_is_proc_macro_dep_aspect = rule( implementation = _attach_dep_actions_aspect_impl, attrs = { - "dep": attr.label(aspects = [collect_dep_actions_aspect]), - "_allowlist_function_transition": attr.label(default = Label("//tools/allowlists/function_transition_allowlist")), + "dep": attr.label( + aspects = [collect_dep_actions_aspect], + ), + "_allowlist_function_transition": attr.label( + default = Label( + "//tools/allowlists/function_transition_allowlist", + ), + ), }, cfg = enable_is_proc_macro_dep_transition, )