Skip to content

Commit 1d3e227

Browse files
alexeaglealxhub
authored andcommittedJul 3, 2019
fix(bazel): revert location of xi18n outputs to bazel-genfiles (#31410)
This is needed in g3 where the translation system is sensitive to the full path of the output. For Bazel users, we don't want this because it would force them to disable a Bazel option that prevents using the deprecated ctx.new_file API PR Close #31410
1 parent c095597 commit 1d3e227

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

‎packages/bazel/src/ng_module.bzl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,11 @@ def _expected_outs(ctx):
267267

268268
# TODO(alxhub): i18n is only produced by the legacy compiler currently. This should be re-enabled
269269
# when ngtsc can extract messages
270-
if is_legacy_ngc:
270+
if is_legacy_ngc and _is_bazel():
271271
i18n_messages_files = [ctx.actions.declare_file(ctx.label.name + "_ngc_messages.xmb")]
272+
elif is_legacy_ngc:
273+
# write the xmb file to blaze-genfiles since that path appears in the translation console keys
274+
i18n_messages_files = [ctx.new_file(ctx.genfiles_dir, ctx.label.name + "_ngc_messages.xmb")]
272275
else:
273276
i18n_messages_files = []
274277

@@ -425,13 +428,19 @@ def ngc_compile_action(
425428
)
426429

427430
if is_legacy_ngc and messages_out != None:
431+
# The base path is bin_dir because of the way the ngc
432+
# compiler host is configured. Under Blaze, we need to explicitly
433+
# point to genfiles/ to redirect the output.
434+
# See _expected_outs above, where the output path for the message file
435+
# is conditional on whether we are in Bazel.
436+
message_file_path = messages_out[0].short_path if _is_bazel() else "../genfiles/" + messages_out[0].short_path
428437
ctx.actions.run(
429438
inputs = inputs,
430439
outputs = messages_out,
431440
executable = ctx.executable.ng_xi18n,
432441
arguments = (_EXTRA_NODE_OPTIONS_FLAGS +
433442
[tsconfig_file.path] +
434-
[messages_out[0].short_path]),
443+
[message_file_path]),
435444
progress_message = "Extracting Angular 2 messages (ng_xi18n)",
436445
mnemonic = "Angular2MessageExtractor",
437446
)

0 commit comments

Comments
 (0)
Please sign in to comment.