A previous commit implemented a streamlined performance metric reporting system for the compiler-cli, controlled via the compiler option `tracePerformance`. This commit adds a custom Bazel flag rule //packages/compiler-cli:ng_perf to the repository, and wires it through to the `ng_module` implementation such that if the flag is set, `ng_module` will produce perf results as part of the build. The underlying mechanism of `//:ng_perf` is not exported from `@angular/bazel` as a public rule that consumers can use, so there is little risk of accidental dependency on the contents of these perf traces. An alias is added so that `--ng_perf` is a Bazel flag which works in our repository. PR Close #41125
21 lines
829 B
Python
21 lines
829 B
Python
# Copyright Google LLC All Rights Reserved.
|
|
#
|
|
# Use of this source code is governed by an MIT-style license that can be
|
|
# found in the LICENSE file at https://angular.io/license
|
|
|
|
load(":ng_module.bzl", "NgPerfInfo")
|
|
|
|
def _ng_perf_flag_impl(ctx):
|
|
return NgPerfInfo(enable_perf_logging = ctx.build_setting_value)
|
|
|
|
# `ng_perf_flag` is a special `build_setting` rule which ultimately enables a command-line boolean
|
|
# flag to control whether the `ng_module` rule produces performance tracing JSON files (in Ivy mode)
|
|
# as declared outputs.
|
|
#
|
|
# It does this via the `NgPerfInfo` provider and the `perf_flag` attriubute on `ng_module`. For more
|
|
# details, see: https://docs.bazel.build/versions/master/skylark/config.html
|
|
ng_perf_flag = rule(
|
|
implementation = _ng_perf_flag_impl,
|
|
build_setting = config.bool(flag = True),
|
|
)
|