1
0
mirror of https://github.com/raspberrypi/pico-sdk.git synced 2025-09-17 09:42:10 +03:00
Files
pico-sdk/bazel/util/label_flag_matches.bzl
armandomontanez 338f99ff1c Initial Pico/2 W Bazel support (#2049)
* Initial Pico 2 W Bazel support

Improves compatibility with Pico W and Pico 2 W by fixing issues that
prevented correct linking of wireless libraries.

* Improve correctness and configurability

* Require newer rules_python

* Require rules_python@0.36.0

* Fix missing compatibility expressions

* Minor tweaks

* Minor cleanup

* Update suggested version in Bazel README

* More README tweaks

* Improve Bazel btstack build correctness
2024-11-21 16:58:02 -06:00

38 lines
1.1 KiB
Python

"""A wrapper that enables a `config_setting` matcher for label_flag flags."""
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
def _match_label_flag_impl(ctx):
matches = str(ctx.attr.expected_value.label) == str(ctx.attr.flag.label)
return [
config_common.FeatureFlagInfo(value = str(matches)),
BuildSettingInfo(value = matches),
]
_match_label_flag = rule(
implementation = _match_label_flag_impl,
attrs = {
"expected_value": attr.label(
mandatory = True,
doc = "The expected flag value",
),
"flag": attr.label(
mandatory = True,
doc = "The flag to extract a value from",
),
},
)
def label_flag_matches(*, name, flag, value):
_match_label_flag(
name = name + "._impl",
expected_value = native.package_relative_label(value),
flag = flag,
)
native.config_setting(
name = name,
flag_values = {":{}".format(name + "._impl"): "True"},
)