Skip to content

Commit

Permalink
build: Use Ivy compiler for bazel builds by default (angular#43862)
Browse files Browse the repository at this point in the history
Setting the angular_ivy_enabled environment variable to True will default Bazel builds to use the Ivy
compiler rather than defaulting to ViewEngine.

PR Close angular#43862
  • Loading branch information
josephperrott authored and AndrewKushnir committed Oct 19, 2021
1 parent 9f40d2a commit 00d8011
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 51 deletions.
5 changes: 2 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ query --deleted_packages=integration/bazel,integration/bazel/src,integration/baz
################################
# Temporary Settings for Ivy #
################################
# To determine if the compiler used should be Ivy instead of ViewEngine, one can use `--config=ivy`
# on any bazel target. This is a temporary flag until codebase is permanently switched to Ivy.
build --define=angular_ivy_enabled=False
# Set the default compiler used for bazel builds to be Ivy.
build --define=angular_ivy_enabled=True

build:view-engine --define=angular_ivy_enabled=False
build:ivy --define=angular_ivy_enabled=True
Expand Down
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ jobs:
command: |
yarn bazel run //tools/saucelabs:sauce_service_setup
TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)')
yarn bazel test --config=saucelabs ${TESTS}
yarn bazel test --config=saucelabs --config=view-engine ${TESTS}
yarn bazel run //tools/saucelabs:sauce_service_stop
no_output_timeout: 40m
- notify_webhook_on_fail:
Expand All @@ -382,7 +382,7 @@ jobs:
command: |
yarn bazel run //tools/saucelabs:sauce_service_setup
TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)')
yarn bazel test --config=saucelabs --config=ivy ${TESTS}
yarn bazel test --config=saucelabs ${TESTS}
yarn bazel run //tools/saucelabs:sauce_service_stop
no_output_timeout: 40m
- notify_webhook_on_fail:
Expand Down Expand Up @@ -776,11 +776,11 @@ jobs:
- setup_win
- run:
name: Build all windows CI targets
command: bazel build --build_tag_filters=-ivy-only //packages/compiler-cli/...
command: bazel build --config=view-engine --build_tag_filters=-ivy-only //packages/compiler-cli/...
no_output_timeout: 15m
- run:
name: Test all windows CI targets
command: bazel test --test_tag_filters="-ivy-only,-browser:chromium-local" //packages/compiler-cli/...
command: bazel test --config=view-engine --test_tag_filters="-ivy-only,-browser:chromium-local" //packages/compiler-cli/...
no_output_timeout: 15m

test_ivy_aot_win:
Expand All @@ -789,11 +789,11 @@ jobs:
- setup_win
- run:
name: Build all windows CI targets
command: bazel build --config=ivy --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot //packages/compiler-cli/...
command: bazel build --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot //packages/compiler-cli/...
no_output_timeout: 15m
- run:
name: Test all windows CI targets
command: bazel test --config=ivy --test_tag_filters="-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local" //packages/compiler-cli/... //packages/localize/...
command: bazel test --test_tag_filters="-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local" //packages/compiler-cli/... //packages/localize/...
no_output_timeout: 15m
# Save dependencies to use on subsequent runs.
- save_cache:
Expand Down
3 changes: 0 additions & 3 deletions .vscode/recommended-launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"program": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [
"test",
"--config=ivy",
"packages/core/test/acceptance",
"--config=debug"
],
Expand All @@ -57,7 +56,6 @@
"program": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [
"test",
"--config=ivy",
"packages/core/test/render3",
"--config=debug"
],
Expand All @@ -75,7 +73,6 @@
"program": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [
"test",
"--config=ivy",
"packages/core/test",
"--config=debug"
],
Expand Down
4 changes: 0 additions & 4 deletions .vscode/recommended-tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"command": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [
"test",
"--config=ivy",
"packages/core/test",
"packages/core/test/acceptance",
"packages/core/test/render3",
Expand Down Expand Up @@ -42,7 +41,6 @@
"command": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [
"test",
"--config=ivy",
"packages/core/test/acceptance",
],
"group": "test",
Expand Down Expand Up @@ -71,7 +69,6 @@
"command": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [
"test",
"--config=ivy",
"packages/core/test",
],
"group": "test",
Expand Down Expand Up @@ -100,7 +97,6 @@
"command": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [
"test",
"--config=ivy",
"packages/core/test/render3",
],
"group": "test",
Expand Down
8 changes: 2 additions & 6 deletions docs/BAZEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ See also: [`//.bazelrc`](https://github.com/angular/angular/blob/master/.bazelrc

- `--config=debug`: build and launch in debug mode (see [debugging](#debugging) instructions below)
- `--test_arg=--node_options=--inspect=9228`: change the inspector port.
- `--config=ivy` Enables ivy mode if present, otherwise ViewEngine is used. This switches which compiler is used (ngc or ngtsc)
- `--config=view-engine` Enables ViewEngine mode if present, currently this the default mode. This switches which compiler is used (ngc or ngtsc)
- `--config=view-engine` Enables ViewEngine mode if present, otherwise Ivy is used. This switches which compiler is used (ngc or ngtsc)
- `--test_tag_filters=<tag>`: filter tests down to tags defined in the `tag` config of your rules in any given `BUILD.bazel`.
- `no-ivy-aot`: Useful for excluding build and test targets that are not meant to be executed in Ivy AOT mode (`--config=ivy`).
- `ivy-only`: Useful for excluding all Ivy build and tests targets with `--config=view-engine`.
- `fixme-ivy-aot`: Useful for including/excluding build and test targets that are currently broken in Ivy AOT mode (`--config=ivy`).


### Debugging a Node Test
Expand Down Expand Up @@ -276,7 +272,7 @@ Require stack:

`bazel run` only works in Bazel Windows with non-test targets. Ensure that you are using `bazel test` instead.

e.g: `yarn bazel test packages/core/test/bundling/forms:symbol_test --config=ivy`
e.g: `yarn bazel test packages/core/test/bundling/forms:symbol_test`

#### mkdir missing
If you see the following error::
Expand Down
2 changes: 1 addition & 1 deletion docs/DEBUG_COMPONENTS_REPO_IVY.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ node ./scripts/ci/update-framework-deps-to-dist-packages.js {COMPONENTS_REPO}/pa
following command:

```bash
yarn test --deleted_packages=//src/dev-app --config=ivy
yarn test --deleted_packages=//src/dev-app
```

### Running tests for individual entry-points
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/render3/util/global_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import {getComponent, getContext, getDirectiveMetadata, getDirectives, getHostEl
*
* To see this in action run the following command:
*
* bazel run --config=ivy
* //packages/core/test/bundling/todo:devserver
* bazel run //packages/core/test/bundling/todo:devserver
*
* Then load `localhost:5432` and start using the console tools.
*/
Expand Down
12 changes: 6 additions & 6 deletions packages/core/test/bundling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ This is asserted by keeping gold files of all symbols which are expected to be r
When doing renaming it is often necessary to update the gold files, to do so use these commands:

```
yarn bazel run --config=ivy //packages/core/test/bundling/injection:symbol_test.accept
yarn bazel run --config=ivy //packages/core/test/bundling/cyclic_import:symbol_test.accept
yarn bazel run --config=ivy //packages/core/test/bundling/forms:symbol_test.accept
yarn bazel run --config=ivy //packages/core/test/bundling/hello_world:symbol_test.accept
yarn bazel run --config=ivy //packages/core/test/bundling/router:symbol_test.accept
yarn bazel run --config=ivy //packages/core/test/bundling/todo:symbol_test.accept
yarn bazel run //packages/core/test/bundling/injection:symbol_test.accept
yarn bazel run //packages/core/test/bundling/cyclic_import:symbol_test.accept
yarn bazel run //packages/core/test/bundling/forms:symbol_test.accept
yarn bazel run //packages/core/test/bundling/hello_world:symbol_test.accept
yarn bazel run //packages/core/test/bundling/router:symbol_test.accept
yarn bazel run //packages/core/test/bundling/todo:symbol_test.accept
```

## Running all symbol tests
Expand Down
3 changes: 0 additions & 3 deletions packages/core/test/bundling/core_all/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ ng_rollup_bundle(
js_size_tracking_test(
name = "size_test",
src = "angular/packages/core/test/bundling/core_all/bundle.min.js",
# Ensures that this target runs with "--config=ivy" (aka Ivy). This is necessary
# because we don't run this test on CI currently, but if we run it manually, we need to
# ensure that it runs with Ivy for proper size comparisons.
angular_ivy_enabled = "True",
data = [
"bundle.golden_size_map_ivy.json",
Expand Down
8 changes: 4 additions & 4 deletions packages/core/test/render3/perf/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Build

```
yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}_lib.min_debug.js --config=ivy
yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}_lib.min_debug.js
```

### Run
Expand Down Expand Up @@ -72,15 +72,15 @@ The resulting output should look something like this:
### Notes

To run the benchmark use `bazel run <benchmark_target>`, example:
- `yarn bazel run --config=ivy //packages/core/test/render3/perf:noop_change_detection`
- `yarn bazel run //packages/core/test/render3/perf:noop_change_detection`

To profile, append `_profile` to the target name and attach a debugger via chrome://inspect, example:
- `yarn bazel run --config=ivy //packages/core/test/render3/perf:noop_change_detection_profile`
- `yarn bazel run //packages/core/test/render3/perf:noop_change_detection_profile`

To interactively edit/rerun benchmarks use `ibazel` instead of `bazel`.

To debug
- Follow the directions in `profile_in_browser.html`
OR
- `yarn bazel build --config=ivy //packages/core/test/render3/perf:noop_change_detection`
- `yarn bazel build //packages/core/test/render3/perf:noop_change_detection`
- `node --inspect-brk bazel-out/darwin-fastbuild/bin/packages/core/test/render3/perf/noop_change_detection.min_debug.js`
2 changes: 1 addition & 1 deletion packages/core/test/render3/perf/profile_all.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const profileTests =

// build tests
shell.exec(
`yarn bazel build --config=ivy ` +
`yarn bazel build ` +
profileTests.map((name) => `//packages/core/test/render3/perf:${name}_lib.min_debug.js`)
.join(' '));

Expand Down
3 changes: 1 addition & 2 deletions packages/core/test/render3/perf/profile_in_browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

<body>
<ol>
<li>Build the benchmark using <tt>yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}.min_debug.js
--config=ivy</tt></li>
<li>Build the benchmark using <tt>yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}.min_debug.js</tt></li>
<li>Open this file using the <tt>file://</tt> protocol and add <tt>?benchmark=BENCHMARK</tt> to the URL.</li>
<li>
Note: You should likely run this in an incognito browser with the "no-turbo-inlining" flag.<br />
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/angular-in-memory-web-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function buildAngularInMemoryWebApiPackage(destDir) {
console.info(`${scriptPath}:`);
console.info(' Building angular-in-memory-web-api npm package');
console.info('##############################');
exec(`${bazelCmd} build //packages/misc/angular-in-memory-web-api:npm_package --config=ivy`);
exec(`${bazelCmd} build //packages/misc/angular-in-memory-web-api:npm_package`);

// Create the output directory.
const absDestDir = resolve(baseDir, destDir);
Expand Down
3 changes: 1 addition & 2 deletions scripts/build/package-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ function buildTargetPackages(destDir, description, isRelease = false) {

// Use either `--config=snapshot` or `--config=release` so that builds are created with the
// correct embedded version info.
exec(`${bazelCmd} build --config=${isRelease ? 'release' : 'snapshot'} --config=ivy ${
targets.join(' ')}`);
exec(`${bazelCmd} build --config=${isRelease ? 'release' : 'snapshot'} ${targets.join(' ')}`);

// Create the output directory.
const absDestDir = resolve(baseDir, destDir);
Expand Down
8 changes: 3 additions & 5 deletions tools/saucelabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ yarn bazel run //tools/saucelabs:sauce_service_setup
For example, `packages/core/test:test_web` becomes `packages/core/test:saucelabs_test_web`.

```
yarn bazel test //packages/core/test:saucelabs_test_web --config=saucelabs --config=ivy
yarn bazel test //packages/core/test:saucelabs_test_web --config=saucelabs
```

Remove the `--config=ivy` if you want to run through View Engine instead.

5. Sauce service log may be tailed or dumped with the following targets:

``` bash
Expand All @@ -54,15 +52,15 @@ Running all ViewEngine karma tests in Saucelabs:
``` bash
yarn bazel run //tools/saucelabs:sauce_service_setup
TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)')
yarn bazel test --config=saucelabs ${TESTS}
yarn bazel test --config=saucelabs --config=view-engine ${TESTS}
```

Running all Ivy karma tests in Saucelabs:

``` bash
yarn bazel run //tools/saucelabs:sauce_service_setup
TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)')
yarn bazel test --config=saucelabs --config=ivy ${TESTS}
yarn bazel test --config=saucelabs ${TESTS}
```

## Under the hood
Expand Down
3 changes: 1 addition & 2 deletions tools/symbol-extractor/run_all_symbols_extractor_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ const ALL_ACCEPT_TARGETS = ALL_TEST_TARGETS.map(test => `${test}.accept`);
function runBazelCommandOnTargets(command, targets, present) {
for (const target of targets) {
process.stdout.write(`${present}: ${target}`);
const commandResult =
spawnSync('yarn', ['-s', 'bazel', command, '--config=ivy', target], {encoding: 'utf8'});
const commandResult = spawnSync('yarn', ['-s', 'bazel', command, target], {encoding: 'utf8'});
process.stdout.clearLine();
process.stdout.cursorTo(0);
if (commandResult.status) {
Expand Down

0 comments on commit 00d8011

Please sign in to comment.