From 4022376b3f206368c3ef52b336bcc8a3aa907078 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Fri, 22 Nov 2019 12:11:48 -0800 Subject: [PATCH] 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 --- packages/bazel/package.json | 2 +- packages/bazel/src/ngc-wrapped/BUILD.bazel | 2 +- scripts/build-ivy-npm-packages.js | 2 +- scripts/build-packages-dist.js | 2 +- scripts/package-builder.js | 6 +++--- tools/defaults.bzl | 6 ++---- tools/size-tracking/index.bzl | 10 +++++----- tools/size-tracking/index.ts | 12 ++++++------ tools/symbol-extractor/cli.ts | 6 +++--- tools/symbol-extractor/index.bzl | 4 ++-- 10 files changed, 25 insertions(+), 27 deletions(-) diff --git a/packages/bazel/package.json b/packages/bazel/package.json index 19ed0e951c..86b02ae744 100644 --- a/packages/bazel/package.json +++ b/packages/bazel/package.json @@ -15,7 +15,7 @@ "bazelBin": { "ngc-wrapped": { "additionalAttributes": { - "configuration_env_vars": "[\"compile\"]" + "configuration_env_vars": "[\"angular_ivy_enabled\"]" } } }, diff --git a/packages/bazel/src/ngc-wrapped/BUILD.bazel b/packages/bazel/src/ngc-wrapped/BUILD.bazel index f9088bcb44..5c1195239c 100644 --- a/packages/bazel/src/ngc-wrapped/BUILD.bazel +++ b/packages/bazel/src/ngc-wrapped/BUILD.bazel @@ -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", diff --git a/scripts/build-ivy-npm-packages.js b/scripts/build-ivy-npm-packages.js index cce4a0624a..f132ae7ce1 100755 --- a/scripts/build-ivy-npm-packages.js +++ b/scripts/build-ivy-npm-packages.js @@ -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'); diff --git a/scripts/build-packages-dist.js b/scripts/build-packages-dist.js index 45bd7c4d4d..af3d03bb31 100755 --- a/scripts/build-packages-dist.js +++ b/scripts/build-packages-dist.js @@ -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. diff --git a/scripts/package-builder.js b/scripts/package-builder.js index 2abb299887..da8a58167d 100755 --- a/scripts/package-builder.js +++ b/scripts/package-builder.js @@ -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); diff --git a/tools/defaults.bzl b/tools/defaults.bzl index 8837855963..7156efc6c4 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -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 ) diff --git a/tools/size-tracking/index.bzl b/tools/size-tracking/index.bzl index 409fc0a974..e80a55299b 100644 --- a/tools/size-tracking/index.bzl +++ b/tools/size-tracking/index.bzl @@ -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 ) diff --git a/tools/size-tracking/index.ts b/tools/size-tracking/index.ts index 8e467ef114..3750a245e0 100644 --- a/tools/size-tracking/index.ts +++ b/tools/size-tracking/index.ts @@ -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; } diff --git a/tools/symbol-extractor/cli.ts b/tools/symbol-extractor/cli.ts index ebd294051f..bbecd3756d 100644 --- a/tools/symbol-extractor/cli.ts +++ b/tools/symbol-extractor/cli.ts @@ -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; diff --git a/tools/symbol-extractor/index.bzl b/tools/symbol-extractor/index.bzl index 8c0a04cb72..f361b3c6f4 100644 --- a/tools/symbol-extractor/index.bzl +++ b/tools/symbol-extractor/index.bzl @@ -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 )