-
Notifications
You must be signed in to change notification settings - Fork 180
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
Expand template rule #191
Comments
We also have something similar internally and would like to have it in a shared lib. The code is easy, but naming is hard. Having both |
Ran across this looking for the same thing. The code's handy--certainly looks like there's popular demand to me. @laurentlb, would you be down to get your code in? P.S. I just watched your immersion demo. It's super neat! |
Would also be helpful for tensorflow, kythe, and OpenEXR |
FWIW we now have this in https://github.com/aspect-build/bazel-lib/blob/main/lib/expand_make_vars.bzl |
fyi, I'll let the code owners (@brandjon @tetromino) decide what to do here. Feel free to reuse my code sample in any way you want. |
We've used laurentlb's sketchup internally for a while now, so I look forward to vertexwahn's PR landing. I'm currently tweaking our internal version, however, to additionally accept substitution information via a Use cases:
Sketchup of a BUILD file using a provider-aware expand_template_info(
name = "foo_subinfo",
substitutions = {"%FOO%": "foo"},
)
expand_template_info(
name = "bar_subinfo",
substitutions = select({
"//condition_1": {"%BAR%": "bar1"},
"//conditions:default": {"%BAR%": "bar"},
}),
)
# Returns a `SubstitutionInfo` containing a dict of `"%RUNTIME_CLASSPATH%": ":".join([...])`.
java_runtime_classpath(
name = "libfoo_classpath",
runtime_deps = [":foo"],
marker = "%RUNTIME_CLASSPATH%",
)
expand_template(
name = "dummy_json",
template = "dummy.tpl.json",
deps = [
":foo_subinfo",
":bar_subinfo", # Or I could `select` here between a static `bar1..N_subinfo`.
":libfoo_classpath",
],
) |
I was very sad to learn that https://github.com/bazel-contrib/rules-template was not this. |
@pauldraper sorry about that 😛 |
meanwhile, I updated my PR (#330). Would be nice if anyone could review it |
Resolves: #191 An example of how this can be useful can be found here: https://github.com/catchorg/Catch2/pull/2387/files Could be also helpful here: https://github.com/AcademySoftwareFoundation/openexr/blob/8587f4eed1d396a9c545d59e7b231d9d4b2cd8ef/BUILD.bazel#L21
Resolves: bazelbuild/bazel-skylib#191 An example of how this can be useful can be found here: https://github.com/catchorg/Catch2/pull/2387/files Could be also helpful here: https://github.com/AcademySoftwareFoundation/openexr/blob/8587f4eed1d396a9c545d59e7b231d9d4b2cd8ef/BUILD.bazel#L21
It's often useful to generate a file using a template. For example, to create a launcher script (usable from
bazel run
). Having to create a new rule for this can be annoying.In the past, I've been using the following implementation and I think it could be useful to have it in Skylib. I'm pasting the code, hoping that someone will make a PR out of it. :)
The text was updated successfully, but these errors were encountered: