build: migrate determining if Ivy is enabled in typescript genrule files to use angular_ivy_enabled (#33983)

Use angular_ivy_enabled to determine if Ivy is being used for the ivy_test_selector.ts symbols.
Additionally, remove the reflect_metadata genrules as we not longer have a "jit" compile option
so all possible invocations result in the same generated file.  Instead we can just commit this
file.

PR Close #33983
This commit is contained in:
Joey Perrott
2019-11-22 12:14:39 -08:00
committed by Matias Niemelä
parent 4022376b3f
commit 807c89441a
9 changed files with 24 additions and 62 deletions

View File

@ -21,14 +21,14 @@ ng_module(
## Controls if Ivy is enabled. (Temporary target until we permanently switch over to Ivy)
##
## This file generates `src/bazel_define_compile_value.ts` file which reexports
## `--define=compile` value as `bazelDefineCompileValue` symbols so that runtime can detect
## which mode it is running in.
## This file generates `src/angular_ivy_enabled.ts` file which exports a truthy value
## whether Ivy should be enabled based on the `--defined=angular_ivy_enabled` value so
## runtime can detect which mode it is running in.
##
## See: `//.bazelrc` where `--define=ivy=legacy` is defined as default.
## See: `./src/bazel_define_compile_value.ts` for more details.
## See: `//.bazelrc` where `--define=angular_ivy_enabled=false` is defined as default.
## See: `./src/angular_ivy_enabled.ts` for more details.
genrule(
name = "bazel_define_compile_value",
outs = ["src/bazel_define_compile_value.ts"],
cmd = "echo export const bazelDefineCompileValue = \"'$(compile)'\"\; > $@",
name = "angular_ivy_enabled",
outs = ["src/angular_ivy_enabled.ts"],
cmd = "echo export const ivyEnabled = \"'True'.toString() == '$(angular_ivy_enabled)'\"\; > $@",
)

View File

@ -7,6 +7,6 @@
*/
/**
* This variable shows the `blaze --define=compile=` value to make it available to runtime.
* This variable shows if Ivy should be enabled at runtime.
*/
export const bazelDefineCompileValue = 'legacy';
export const ivyEnabled = false;

View File

@ -5,8 +5,7 @@
* 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
*/
import {bazelDefineCompileValue} from './bazel_define_compile_value';
import {ivyEnabled} from './angular_ivy_enabled';
/**
* A function to conditionally include a test or a block of tests only when tests run against Ivy.
@ -24,7 +23,7 @@ import {bazelDefineCompileValue} from './bazel_define_compile_value';
* ivyEnabled && it(...);
* ```
*/
export const ivyEnabled = 'aot' === (bazelDefineCompileValue as string);
export {ivyEnabled};
/**
* A function to conditionally skip the execution of tests that are not relevant when