bazel-contrib / bazel-contrib/bazel-lib

Usage example for path mapping feature in run_binary implementation

Open
#1,255 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
182
Forks
134
Avg merge
1d 46m
Merged PRs (30d)
1

Description

Current run_binary implementation automatically declares support for path mapping through setting `supports-path-mapping` in the ctx.actions.run execution_requirements only if there is no make variable or location expansions used in args or env attributes of the rule.
In case make variable substitution or location expansion is used then one can still forcibly set `supports-path-mapping` through run_binary execution_requirements rule attribute.
This is all very welcomed but I struggle to find real world example how to implement run_binary without using make variable substitution for at least output location. The only workaround I found so far is to hardcode output path in the `tool` script to write output to `bazel-out/cfg/bin/` but this seems to be very fragile solution because in case I decide to opt-out of path mapping feature it will break this implementation.

Please, advise how to properly use the path-mapping feature with run_binary and add sparse example for a use case where run_binary will not break by enabling or disabling path-mapping feature but still benefiting from it when enabled.

Contributor guide

Open the contributing guide

Research direction

Start by reading the run_binary implementation and its handling of supports-path-mapping, then inspect existing usage examples in the repository for patterns that avoid make-variable and location expansion. Add a sparse run_binary example showing an output path that remains valid with path mapping enabled or disabled, and document how to run or verify it.

Written by the indexing model from the issue text.

Assessment

Domain
build-system, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.