mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2026-03-14 21:19:43 +01:00
Some checks are pending
Bazel presubmit checks / bazel-build-check (macos-latest) (push) Waiting to run
Bazel presubmit checks / bazel-build-check (ubuntu-latest) (push) Waiting to run
Bazel presubmit checks / other-bazel-checks (push) Waiting to run
Check Configs / check-configs (push) Waiting to run
CMake / build (push) Waiting to run
Build on macOS / build (push) Waiting to run
Build on Windows / build (push) Waiting to run
This is an automated change with the following commands:
$ find . -name "BUILD.bazel" -o -name "*.bzl" \
-exec buildifier -lint=fix {} \;
* Add missing `load()` statements for things provided by @rules_cc. This
is required for Bazel >9.
* Sort attributes on build targets.
* Add missing trailing commas where applicable.
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
|
|
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
|
|
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
|
|
|
|
def _pico_sdk_define_impl(ctx):
|
|
val = ctx.attr.from_flag[BuildSettingInfo].value
|
|
|
|
if type(val) == "string":
|
|
# Strings need quotes.
|
|
val = "\"{}\"".format(val)
|
|
elif type(val) == "bool":
|
|
# Convert bools to 0 or 1.
|
|
val = 1 if val else 0
|
|
cc_ctx = cc_common.create_compilation_context(
|
|
defines = depset(
|
|
direct = ["{}={}".format(ctx.attr.define_name, val)],
|
|
),
|
|
)
|
|
return [CcInfo(compilation_context = cc_ctx)]
|
|
|
|
pico_sdk_define = rule(
|
|
implementation = _pico_sdk_define_impl,
|
|
doc = """A simple rule that offers a skylib flag as a define.
|
|
|
|
These can be listed in the `deps` attribute of a `cc_library` to get access
|
|
to the value of a define.
|
|
|
|
Example:
|
|
|
|
bool_flag(
|
|
name = "my_flag",
|
|
build_setting_default = False,
|
|
)
|
|
|
|
pico_sdk_define(
|
|
name = "flag_define",
|
|
define_name = "MY_FLAG_DEFINE",
|
|
from_flag = ":my_flag",
|
|
)
|
|
""",
|
|
attrs = {
|
|
"define_name": attr.string(mandatory = True),
|
|
"from_flag": attr.label(mandatory = True),
|
|
},
|
|
)
|