build: update scripting and tooling to rely on define=angular_ivy_enabled instream of define=compile (#33983)

We need to migrate to using angular_ivy_enabled value to determine whether to use
Ivy or ViewEngine for package building scripts and for size-tracking and
symbol-extract tooling.

PR Close #33983
This commit is contained in:
Joey Perrott 2019-11-22 12:11:48 -08:00 committed by Matias Niemelä
parent 5e3f6d203d
commit 4022376b3f
10 changed files with 25 additions and 27 deletions

View File

@ -15,7 +15,7 @@
"bazelBin": {
"ngc-wrapped": {
"additionalAttributes": {
"configuration_env_vars": "[\"compile\"]"
"configuration_env_vars": "[\"angular_ivy_enabled\"]"
}
}
},

View File

@ -29,7 +29,7 @@ ts_library(
nodejs_binary(
name = "ngc-wrapped",
configuration_env_vars = ["compile"],
configuration_env_vars = ["angular_ivy_enabled"],
data = [
":ngc_lib",
"//packages/bazel/third_party/github.com/bazelbuild/bazel/src/main/protobuf:worker_protocol.proto",

View File

@ -5,4 +5,4 @@ const {buildTargetPackages} = require('./package-builder');
// Build the ivy packages.
buildTargetPackages('dist/packages-dist-ivy-aot', 'aot', 'Ivy AOT');
buildTargetPackages('dist/packages-dist-ivy-aot', true, 'Ivy AOT');

View File

@ -13,7 +13,7 @@ const {
// Build the legacy (view engine) npm packages into `dist/packages-dist/`.
buildTargetPackages('dist/packages-dist', 'legacy', 'Production');
buildTargetPackages('dist/packages-dist', false, 'Production');
// Build the `zone.js` npm package (into `dist/bin/packages/zone.js/npm_package/`), because it might
// be needed by other scripts/tests.

View File

@ -47,10 +47,10 @@ module.exports = {
*
* @param {string} destPath Path to the output directory into which we copy the npm packages.
* This path should either be absolute or relative to the project root.
* @param {'legacy' | 'aot'} compileMode Either `legacy` (view engine) or `aot` (ivy).
* @param {boolean} enableIvy True, if Ivy should be used.
* @param {string} description Human-readable description of the build.
*/
function buildTargetPackages(destPath, compileMode, description) {
function buildTargetPackages(destPath, enableIvy, description) {
console.log('##################################');
console.log(`${scriptPath}:`);
console.log(' Building @angular/* npm packages');
@ -65,7 +65,7 @@ function buildTargetPackages(destPath, compileMode, description) {
const targets = exec(getTargetsCmd, true).split(/\r?\n/);
// Use `--config=release` so that snapshot builds get published with embedded version info.
exec(`${bazelCmd} build --config=release --define=compile=${compileMode} ${targets.join(' ')}`);
exec(`${bazelCmd} build --config=release --config=${enableIvy ? 'ivy' : 'view-engine'} ${targets.join(' ')}`);
// Create the output directory.
const absDestPath = resolve(baseDir, destPath);

View File

@ -230,8 +230,7 @@ def ng_benchmark(**kwargs):
def nodejs_binary(data = [], **kwargs):
"""Default values for nodejs_binary"""
_nodejs_binary(
# Pass-thru --define=compile=foo as an environment variable
configuration_env_vars = ["compile"],
configuration_env_vars = ["angular_ivy_enabled"],
data = data + ["@npm//source-map-support"],
**kwargs
)
@ -250,8 +249,7 @@ def jasmine_node_test(deps = [], **kwargs):
]
_jasmine_node_test(
deps = deps,
# Pass-thru --define=compile=foo as an environment variable
configuration_env_vars = ["compile"],
configuration_env_vars = ["angular_ivy_enabled"],
**kwargs
)

View File

@ -18,7 +18,7 @@ def js_size_tracking_test(
golden_file,
max_percentage_diff,
max_byte_diff,
required_compile_mode = "",
angular_ivy_enabled = "False",
data = [],
**kwargs):
all_data = data + [
@ -32,7 +32,7 @@ def js_size_tracking_test(
name = name,
data = all_data,
entry_point = entry_point,
configuration_env_vars = ["compile"],
configuration_env_vars = ["angular_ivy_enabled"],
templated_args = [
src,
source_map,
@ -40,7 +40,7 @@ def js_size_tracking_test(
"%d" % max_percentage_diff,
"%d" % max_byte_diff,
"false",
required_compile_mode,
angular_ivy_enabled,
],
**kwargs
)
@ -50,7 +50,7 @@ def js_size_tracking_test(
testonly = True,
data = all_data,
entry_point = entry_point,
configuration_env_vars = ["compile"],
templated_args = [src, source_map, golden_file, "0", "0", "true", required_compile_mode],
configuration_env_vars = ["angular_ivy_enabled"],
templated_args = [src, source_map, golden_file, "0", "0", "true", angular_ivy_enabled],
**kwargs
)

View File

@ -26,14 +26,14 @@ if (require.main === module) {
export function main(
filePath: string, sourceMapPath: string, goldenSizeMapPath: string, writeGolden: boolean,
maxPercentageDiff: number, maxByteDiff: number, requiredCompileMode: string): boolean {
maxPercentageDiff: number, maxByteDiff: number, requiresIvy: string): boolean {
const {sizeResult} = new SizeTracker(filePath, sourceMapPath);
const compileMode = process.env['compile'];
const ivyEnabled = process.env['angular_ivy_enabled'] == 'True';
if (requiredCompileMode && compileMode !== requiredCompileMode) {
if (requiresIvy && ivyEnabled) {
console.error(chalk.red(
`Expected the size-tracking tool to be run with: ` +
`--define=compile=${requiredCompileMode}`));
`--config=${requiresIvy ? 'ivy' : 'view-engine'}`));
return false;
}
@ -60,9 +60,9 @@ export function main(
});
const bazelTargetName = process.env['TEST_TARGET'];
const defineFlag = (compileMode !== 'legacy') ? `--define=compile=${compileMode} ` : '';
console.error(`\nThe golden file can be updated with the following command:`);
console.error(` yarn bazel run ${defineFlag}${bazelTargetName}.accept`);
console.error(
` yarn bazel run --config=${ivyEnabled ? 'ivy' : 'view-engine'} ${bazelTargetName}.accept`);
return false;
}

View File

@ -39,11 +39,11 @@ function main(argv: [string, string, string] | [string, string]): boolean {
} else {
passed = symbolExtractor.compareAndPrintError(goldenFilePath, goldenContent);
if (!passed) {
const compile = process.env['compile'];
const defineFlag = (compile !== 'legacy') ? `--define=compile=${compile} ` : '';
const ivyEnabled = process.env['angular_ivy_enabled'] == 'True';
console.error(`TEST FAILED!`);
console.error(` To update the golden file run: `);
console.error(` yarn bazel run ${defineFlag}${process.env['TEST_TARGET']}.accept`);
console.error(
` yarn bazel run --config=${ivyEnabled ? 'ivy' : 'view-engine'} ${process.env['TEST_TARGET']}.accept`);
}
}
return passed;

View File

@ -25,7 +25,7 @@ def js_expected_symbol_test(name, src, golden, data = [], **kwargs):
data = all_data,
entry_point = entry_point,
templated_args = ["$(location %s)" % src, "$(location %s)" % golden],
configuration_env_vars = ["compile"],
configuration_env_vars = ["angular_ivy_enabled"],
**kwargs
)
@ -34,7 +34,7 @@ def js_expected_symbol_test(name, src, golden, data = [], **kwargs):
testonly = True,
data = all_data,
entry_point = entry_point,
configuration_env_vars = ["compile"],
configuration_env_vars = ["angular_ivy_enabled"],
templated_args = ["$(location %s)" % src, "$(location %s)" % golden, "--accept"],
**kwargs
)