Skip to content

Commit a970884

Browse files
lauraharkercopybara-github
authored andcommitted
Unzip runtime_libs.typedast to fix "Cannot read from TypedAST stream" crash
Fixes #4067 PiperOrigin-RevId: 515750703
1 parent e2655d6 commit a970884

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

bazel/typedast.bzl

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ def _typedast_impl(ctx):
2828
fail("name must end with _typedast")
2929

3030
typedast_file = ctx.actions.declare_file(name[:-len("_typedast")] + ".typedast")
31+
typedast_gz_file = ctx.actions.declare_file(name[:-len("_typedast")] + ".typedast.gz")
3132

32-
outputs = []
33-
inputs = []
33+
compiler_outputs = []
34+
compiler_inputs = []
3435
args = ctx.actions.args()
3536

36-
inputs.extend(ctx.files._jdk)
37+
compiler_inputs.extend(ctx.files._jdk)
3738
args.add_all([
3839
"--checks_only",
3940
"--strict_mode_input",
@@ -43,22 +44,28 @@ def _typedast_impl(ctx):
4344
"--jscomp_error=checkTypes",
4445
"--jscomp_off=uselessCode",
4546
])
46-
args.add(typedast_file, format = "--typed_ast_output_file__INTENRNAL_USE_ONLY=%s")
47-
outputs.append(typedast_file)
47+
args.add(typedast_gz_file, format = "--typed_ast_output_file__INTENRNAL_USE_ONLY=%s")
48+
compiler_outputs.append(typedast_gz_file)
4849
args.add_all(ctx.files.srcs, format_each = "--js=%s")
49-
inputs.extend(ctx.files.srcs)
50+
compiler_inputs.extend(ctx.files.srcs)
5051

5152
ctx.actions.run(
52-
outputs = outputs,
53-
inputs = inputs,
53+
outputs = compiler_outputs,
54+
inputs = compiler_inputs,
5455
executable = ctx.executable.compiler,
5556
arguments = [args],
5657
mnemonic = "TypedAST",
5758
)
5859

60+
ctx.actions.run_shell(
61+
outputs = [typedast_file],
62+
inputs = [typedast_gz_file],
63+
command = "gunzip -c '%s' > '%s'" % (typedast_gz_file.path, typedast_file.path),
64+
)
65+
5966
return [
6067
DefaultInfo(
61-
files = depset(outputs),
68+
files = depset([typedast_file]),
6269
),
6370
]
6471

0 commit comments

Comments
 (0)