pico-sdk/bazel/pico_btstack_make_gatt_header.bzl
armandomontanez 6262b49c74
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
[bazel] Run buildifier on Bazel build files (#2825)
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.
2026-03-02 10:24:17 +00:00

60 lines
1.8 KiB
Python

load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cpp_toolchain", "use_cc_toolchain")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
def _pico_btstack_make_gatt_header_impl(ctx):
cc_toolchain = find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
)
out = ctx.actions.declare_file(
"{}_gatt_generated/{}.h".format(ctx.label.name, ctx.file.src.basename.removesuffix(".gatt")),
)
ctx.actions.run(
executable = ctx.executable._make_gat_header_tool,
arguments = [
ctx.file.src.path,
out.path,
"-I",
ctx.file._btstack_hdr.dirname,
] + [
],
inputs = [
ctx.file.src,
ctx.file._btstack_hdr,
],
outputs = [out],
)
cc_ctx = cc_common.create_compilation_context(
headers = depset(direct = [out]),
includes = depset(direct = [out.dirname]),
)
return [
DefaultInfo(files = depset(direct = [out])),
CcInfo(compilation_context = cc_ctx),
]
pico_btstack_make_gatt_header = rule(
implementation = _pico_btstack_make_gatt_header_impl,
attrs = {
"src": attr.label(mandatory = True, allow_single_file = True),
"_btstack_hdr": attr.label(
default = "@btstack//:src/bluetooth_gatt.h",
allow_single_file = True,
),
"_make_gat_header_tool": attr.label(
default = "@btstack//:compile_gatt",
cfg = "exec",
executable = True,
),
},
fragments = ["cpp"],
toolchains = use_cc_toolchain(),
)