-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add $(location_dirname) template for resolving the directory of a label #23516
Comments
In the case of an output directory, you should be able to use this instead of a custom rule today:
I would still like to see a way to support expansions to directory paths more easily, especially for multiple files. |
I just tried the run_binary(
name = "javacc_java_jj",
tool = "@javacc//:javacc",
srcs = ["src/main/javacc/java.jj"],
outs = [
"GeneratedJavaParserConstants.java",
"GeneratedJavaParser.java",
"GeneratedJavaParserTokenManager.java",
],
args = [
"-OUTPUT_DIRECTORY:$(BINDIR)/javaparser-core",
"$(location src/main/javacc/java.jj)",
],
)
There is a comment to this effect within the skylib sources, so it seems like the behavior is intentional-ish:
|
Also expanding make variables in |
The proposed PR to Bazel is #23518 -- it adds I'm hesitant to add make variable expansions in places where they're currently not enabled, because I've had builds break in the past from unexpected expansions. I'll leave the skylib changes to someone else who might have stronger preference for it. |
Description of the feature request:
Allow
$(location_dirname //some:target)
to resolve to the directory that contains//some:target
.For example, if
$(location //foo:bar)
resolves tobazel-out/k8-fastbuild/bin/foo/bar.txt
, then$(location_dirname //foo:bar)
should resolve tobazel-out/k8-fastbuild/bin/foo
.Which category does this issue belong to?
Rules API
What underlying problem are you trying to solve with this feature?
This is useful when interacting with tools that write outputs to a named directory. Currently wrapping such a tool requires writing a custom build rule, but a
$(location_dirname)
template expanded byctx.expand_location()
would let them be wrapped in a genrule or Skylib'srun_binary()
.The text was updated successfully, but these errors were encountered: