feat(kzip): thread encoding into kzip_extractor bazel rule
@@ -27,6 +27,7 @@ def kzip_extractor(
sources = "",
source_args = "",
scoped = True,
+ encoding = None,
extractor = "//kythe/go/extractors/cmd/bazel:extract_kzip"):
"""This macro creates extra_action and action_listener for extract_kzip.
@@ -46,6 +47,7 @@ def kzip_extractor(
source_args: optional RE2 matching arguments to consider source files in
kzip extractor
scoped: optional boolean whether to match source paths only in target pkg
+ encoding: optional encoding (proto|json) for the generated kzip
extractor: optional label of the extract_kzip tool to use
"""
@@ -75,14 +77,16 @@ def kzip_extractor(
xa_args["args"] = _quote_re(source_args)
if rules:
xa_args["rules"] = "$(location %s)" % rules
-
+ cmdprefix = ""
+ if encoding:
+ cmdprefix = "env KYTHE_KZIP_ENCODING=%s " % encoding
native.extra_action(
name = xa_name,
data = [rules] if rules else [],
out_templates = [xa_output],
tools = [extractor],
cmd = (
- "$(location %s) " % extractor + " ".join(sorted([
+ cmdprefix + "$(location %s) " % extractor + " ".join(sorted([
"--%s=%s" % (key, value)
for key, value in xa_args.items()
]))
