pico-sdk/bazel/toolchain/objcopy.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

47 lines
1.4 KiB
Python

load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "OBJ_COPY_ACTION_NAME")
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cpp_toolchain", "use_cc_toolchain")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
def _objcopy_to_bin_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,
)
objcopy_tool_path = cc_common.get_tool_for_action(
feature_configuration = feature_configuration,
action_name = OBJ_COPY_ACTION_NAME,
)
ctx.actions.run(
inputs = depset(
direct = [ctx.file.src],
transitive = [cc_toolchain.all_files],
),
executable = objcopy_tool_path,
outputs = [ctx.outputs.out],
arguments = [
ctx.file.src.path,
"-Obinary",
ctx.outputs.out.path,
],
)
objcopy_to_bin = rule(
implementation = _objcopy_to_bin_impl,
attrs = {
"src": attr.label(
allow_single_file = True,
mandatory = True,
doc = "File to use as input to objcopy command",
),
"out": attr.output(
mandatory = True,
doc = "Destination file for objcopy command",
),
},
fragments = ["cpp"],
toolchains = use_cc_toolchain(),
)