-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Description of the problem / feature request:
The Skylark linter complains that expand_make_variables() is deprecated, but the recommended replacement is not sufficient. For example: expand_make_variables will expand 'foo-$(BAR)' correctly, while the canonical use of ctx var:
version = ctx.attr.version.format(**ctx.var)
will not, because it only does %{name} expansion. We need a global method to do $(VAR) substitution, or to transform the string into something .format compatible.
Feature requests: what underlying problem are you trying to solve with this feature?
Add a global method to do $(VAR) substitution from a dictionary. E.g.
expand_variables(string, dict)
usage
expand_variables(ctx.attr.my_attr, **ctx.var)
OR, a method to convert $(X) substitutions to string format compatible text.
make_to_format(ctx.attr.my_attr).format(**ctx.var)
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
A rule with
- A string attribute, X.
- "Make style" variable substitution is required for X. E.g. $(TARGET_CPU)
What operating system are you running Bazel on?
Linux, but not applicable.
What's the output of bazel info release?
bazel-bin: /home/aiuto/.cache/bazel/_bazel_aiuto/adc5a676660c54154e7bf375b1444975/execroot/google3/bazel-out/k8-fastbuild/bin
bazel-genfiles: /home/aiuto/.cache/bazel/_bazel_aiuto/adc5a676660c54154e7bf375b1444975/execroot/google3/bazel-out/k8-fastbuild/genfiles
bazel-testlogs: /home/aiuto/.cache/bazel/_bazel_aiuto/adc5a676660c54154e7bf375b1444975/execroot/google3/bazel-out/k8-fastbuild/testlogs
character-encoding: file.encoding = ISO-8859-1, defaultCharset = ISO-8859-1
command_log: /home/aiuto/.cache/bazel/_bazel_aiuto/adc5a676660c54154e7bf375b1444975/command.log
committed-heap-size: 1277MB
execution_root: /home/aiuto/.cache/bazel/_bazel_aiuto/adc5a676660c54154e7bf375b1444975/execroot/google3
gc-count: 9
gc-time: 359ms
install_base: /home/aiuto/.cache/bazel/_bazel_aiuto/install/c25ea2c3043bcba07b93dde10595066c
java-home: /home/aiuto/.cache/bazel/_bazel_aiuto/install/c25ea2c3043bcba07b93dde10595066c/_embedded_binaries/embedded_tools/jdk
java-runtime: OpenJDK Runtime Environment (build 9.0.7.1+1) by Azul Systems, Inc.
java-vm: OpenJDK 64-Bit Server VM (build 9.0.7.1+1, mixed mode) by Azul Systems, Inc.
max-heap-size: 15014MB
output_base: /home/aiuto/.cache/bazel/_bazel_aiuto/adc5a676660c54154e7bf375b1444975
output_path: /home/aiuto/.cache/bazel/_bazel_aiuto/adc5a676660c54154e7bf375b1444975/execroot/google3/bazel-out
package_path: %workspace%
release: release 0.16.0
repository_cache: /home/aiuto/.cache/bazel/_bazel_aiuto/cache/repos/v1
server_pid: 165154
used-heap-size: 58MB
workspace: /google/src/cloud/aiuto/curl/google3