-
Notifications
You must be signed in to change notification settings - Fork 949
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
08ea1d8
commit 338f99f
Showing
21 changed files
with
535 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""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"}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.