File: pico_btstack_make_gatt_header.bzl

package info (click to toggle)
pico-sdk 2.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 26,552 kB
  • sloc: ansic: 146,841; asm: 13,423; python: 2,417; cpp: 2,171; yacc: 381; lex: 270; makefile: 32; sh: 13; javascript: 13
file content (59 lines) | stat: -rw-r--r-- 1,729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cpp_toolchain", "use_cc_toolchain")

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(),
)