Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 0 additions & 19 deletions rust/private/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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")

# Exported for docs
exports_files(["providers.bzl"])
Expand Down Expand Up @@ -32,24 +31,6 @@ bzl_library(
],
)

# 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
38 changes: 1 addition & 37 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,6 @@ RUSTC_ATTRS = {
"_extra_rustc_flags": attr.label(
default = Label("//rust/settings:extra_rustc_flags"),
),
"_is_proc_macro_dep": attr.label(
default = Label("//rust/private:is_proc_macro_dep"),
),
"_is_proc_macro_dep_enabled": attr.label(
default = Label("//rust/private:is_proc_macro_dep_enabled"),
),
"_per_crate_rustc_flag": attr.label(
default = Label("//rust/settings:experimental_per_crate_rustc_flag"),
),
Expand Down Expand Up @@ -1108,40 +1102,10 @@ rust_shared_library = rule(
"""),
)

def _proc_macro_dep_transition_impl(settings, _attr):
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 = ["//rust/private:is_proc_macro_dep_enabled"],
outputs = ["//rust/private:is_proc_macro_dep"],
implementation = _proc_macro_dep_transition_impl,
)

rust_proc_macro = rule(
implementation = _rust_proc_macro_impl,
provides = COMMON_PROVIDERS,
# Start by copying the common attributes, then override the `deps` attribute
# to apply `_proc_macro_dep_transition`. To add this transition we additionally
# need to declare `_allowlist_function_transition`, see
# https://docs.bazel.build/versions/main/skylark/config.html#user-defined-transitions.
attrs = dict(
_COMMON_ATTRS.items(),
_allowlist_function_transition = attr.label(
default = Label("//tools/allowlists/function_transition_allowlist"),
),
deps = attr.label_list(
doc = dedent("""\
List of other libraries to be linked to this library target.

These can be either other `rust_library` targets or `cc_library` targets if
linking a native library.
"""),
cfg = _proc_macro_dep_transition,
),
),
attrs = _COMMON_ATTRS,
fragments = ["cpp"],
toolchains = [
str(Label("//rust:toolchain_type")),
Expand Down
33 changes: 0 additions & 33 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -101,34 +101,6 @@ PerCrateRustcFlagsInfo = provider(
fields = {"per_crate_rustc_flags": "List[string] Extra flags to pass to rustc in non-exec configuration"},
)

IsProcMacroDepInfo = provider(
doc = "Records if this is a transitive dependency of a proc-macro.",
fields = {"is_proc_macro_dep": "Boolean"},
)

def _is_proc_macro_dep_impl(ctx):
return IsProcMacroDepInfo(is_proc_macro_dep = ctx.build_setting_value)

is_proc_macro_dep = rule(
doc = "Records if this is a transitive dependency of a proc-macro.",
implementation = _is_proc_macro_dep_impl,
build_setting = config.bool(flag = True),
)

IsProcMacroDepEnabledInfo = provider(
doc = "Enables the feature to record if a library is a transitive dependency of a proc-macro.",
fields = {"enabled": "Boolean"},
)

def _is_proc_macro_dep_enabled_impl(ctx):
return IsProcMacroDepEnabledInfo(enabled = ctx.build_setting_value)

is_proc_macro_dep_enabled = rule(
doc = "Enables the feature to record if a library is a transitive dependency of a proc-macro.",
implementation = _is_proc_macro_dep_enabled_impl,
build_setting = config.bool(flag = True),
)

def _get_rustc_env(attr, toolchain, crate_name):
"""Gathers rustc environment variables

Expand Down Expand Up @@ -161,11 +133,6 @@ def _get_rustc_env(attr, toolchain, crate_name):
"CARGO_PKG_VERSION_PATCH": patch,
"CARGO_PKG_VERSION_PRE": pre,
}
if hasattr(attr, "_is_proc_macro_dep_enabled") and attr._is_proc_macro_dep_enabled[IsProcMacroDepEnabledInfo].enabled:
is_proc_macro_dep = "0"
if hasattr(attr, "_is_proc_macro_dep") and attr._is_proc_macro_dep[IsProcMacroDepInfo].is_proc_macro_dep:
is_proc_macro_dep = "1"
result["BAZEL_RULES_RUST_IS_PROC_MACRO_DEP"] = is_proc_macro_dep
return result

def get_compilation_mode_opts(ctx, toolchain):
Expand Down
5 changes: 0 additions & 5 deletions test/unit/is_proc_macro_dep/BUILD.bazel

This file was deleted.

175 changes: 0 additions & 175 deletions test/unit/is_proc_macro_dep/is_proc_macro_dep_test.bzl

This file was deleted.

11 changes: 0 additions & 11 deletions test/unit/is_proc_macro_dep/proc_macro_crate.rs

This file was deleted.

3 changes: 0 additions & 3 deletions test/unit/is_proc_macro_dep/proc_macro_dep.rs

This file was deleted.

Loading