-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: reduce manual setup for entry-points of packages (#17460)
Reduces the manual setup for entry-poitns of packages. With this change, we no longer need to update the dev-app system config if we add/remove entry-points. We basically only need to configure entry-points in the `config.bzl` file. Though this is not 100% complete yet, because we still have legacy karma tests which need another system config. The bazel karma tests do not need this anymore.
- Loading branch information
1 parent
c6bcce9
commit 16d2eb8
Showing
4 changed files
with
57 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Implementation of the expand_template rule """ | ||
|
||
def expand_template_impl(ctx): | ||
replacements = dict(**ctx.attr.substitutions) | ||
|
||
for k in ctx.attr.configuration_env_vars: | ||
if k in ctx.var.keys(): | ||
replacements["$%s_TMPL" % k.upper()] = ctx.var[k] | ||
|
||
ctx.actions.expand_template( | ||
template = ctx.file.template, | ||
output = ctx.outputs.output_name, | ||
substitutions = replacements, | ||
) | ||
|
||
""" | ||
Rule that can be used to output a file from a specified | ||
template by applying given substitutions. | ||
""" | ||
expand_template = rule( | ||
implementation = expand_template_impl, | ||
attrs = { | ||
"configuration_env_vars": attr.string_list(default = []), | ||
"output_name": attr.output(mandatory = True), | ||
"substitutions": attr.string_dict(mandatory = True), | ||
"template": attr.label(mandatory = True, allow_single_file = True), | ||
}, | ||
) |