python program run via bazel unable to see stlink_cli.exe installed on host

20 views
Skip to first unread message

Uma Patil

unread,
Oct 3, 2022, 7:24:46 PM10/3/22
to bazel-discuss
Hi,

I have python program that uses STLink_CI.EXE installed on my host machine. I have created custom rule to run py_binary. 
Custom rule:
load('//tools/flash:rules.bzl', 'flash_tool')
flash_tool(
    name = "run",
    device_type="stm32",
    srcs = ":cc_binary",
    visibility = ["//visibility:public"],
)

rules.bzl:
def _impl(ctx):
    args= ctx.actions.args()
    args.add(ctx.attr.device_type)
    ........

    ctx.actions.run(
        inputs = [ctx.file.srcs],
        arguments = [args],
        outputs = [ctx.outputs.text],
        executable = ctx.executable.runner)

flash_tool = rule(
    implementation = _impl,
    attrs = {
        "runner": attr.label(
            executable = True,
            cfg = "host",
            default=Label("//tools/flash")),
        "device_type":attr.string(mandatory = True),
        "srcs":attr.label(mandatory = True, allow_single_file = True,),
    },
    outputs = {
        "text": "%{name}.txt"},
)

When I run 
bazel build //examples/application:run --platforms=//stm32f4

It throws me error as STLInk_cli.exe is missing. How can i make custom rule to run on host so that it identifies the stlink_cli.exe? Or am I understanding it differently and  missing something different?

Please guide me on this.
Reply all
Reply to author
Forward
0 new messages