Skip to content

Commit 048fdb2

Browse files
authored
build: update to bazel v2.1.0 (#18457)
* Updates to Bazel v2.1.0 * Updates to latest rules_nodejs version. * Migrates from the no longer supported `@bazel/bazel` package to `@bazel/bazelisk`.
1 parent 411d048 commit 048fdb2

18 files changed

+70
-93
lines changed

.bazelrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,4 @@ try-import .bazelrc.user
119119

120120
# TODO: check if we can enable these deprecations.
121121
build --incompatible_new_actions_api=false
122-
build --incompatible_depset_is_not_iterable=false
123122
build --incompatible_no_support_tools_in_action_inputs=false

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.1.0

.circleci/config.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ var_2: &docker-firefox-image circleci/node:12.9.1-browsers
1313
# **Note**: When updating the beginning of the cache key, also update the cache key to match
1414
# the new cache key prefix. This allows us to take advantage of CircleCI's fallback caching.
1515
# Read more here: https://circleci.com/docs/2.0/caching/#restoring-cache.
16-
var_3: &cache_key v5-ng-mat-{{ checksum "tools/bazel/postinstall-patches.js" }}-{{ checksum "WORKSPACE" }}-{{ checksum "yarn.lock" }}
16+
var_3: &cache_key v6-ng-mat-{{ checksum ".bazelversion" }}-{{ checksum "tools/postinstall/apply-patches.js" }}-{{ checksum "WORKSPACE" }}-{{ checksum "yarn.lock" }}
1717
# We want to invalidate the cache if the postinstall patches change. In order to apply new
18-
# patches, a clean version of the node modules is needed.
19-
var_4: &cache_fallback_key v5-ng-mat-{{ checksum "tools/bazel/postinstall-patches.js" }}-
18+
# patches, a clean version of the node modules is needed. Additionally, we invalidate the cache
19+
# if the Bazel version changes. We do this because otherwise the `bazelisk` cache folder will
20+
# contain all previously used versions and ultimately cause the cache restoring to be slower.
21+
var_4: &cache_fallback_key v6-ng-mat-{{ checksum ".bazelversion" }}-{{ checksum "tools/postinstall/apply-patches.js" }}-
2022

2123
# Settings common to each job
2224
var_5: &job_defaults
@@ -47,6 +49,7 @@ var_8: &save_cache
4749
key: *cache_key
4850
paths:
4951
- "node_modules"
52+
- "~/.cache/bazelisk"
5053
- "~/bazel_repository_cache"
5154

5255
# Decryption token that is used to decode the GCP credentials file in ".circleci/gcp_token".

WORKSPACE

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
88
# Add NodeJS rules
99
http_archive(
1010
name = "build_bazel_rules_nodejs",
11-
sha256 = "3887b948779431ac443e6a64f31b9e1e17b8d386a31eebc50ec1d9b0a6cabd2b",
12-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.0.0/rules_nodejs-1.0.0.tar.gz"],
11+
sha256 = "b6670f9f43faa66e3009488bbd909bc7bc46a5a9661a33f6bc578068d1837f37",
12+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.3.0/rules_nodejs-1.3.0.tar.gz"],
1313
)
1414

1515
# Add sass rules
@@ -18,7 +18,7 @@ http_archive(
1818
# Patch `rules_sass` to work around a bug that causes error messages to be not
1919
# printed in worker mode: https://github.com/bazelbuild/rules_sass/issues/96.
2020
# TODO(devversion): remove this patch once the Sass Node entry-point returns a `Promise`.
21-
patches = ["//tools/bazel:sass_worker_async.patch"],
21+
patches = ["//tools/postinstall:sass_worker_async.patch"],
2222
sha256 = "c78be58f5e0a29a04686b628cf54faaee0094322ae0ac99da5a8a8afca59a647",
2323
strip_prefix = "rules_sass-1.25.0",
2424
urls = [
@@ -28,8 +28,8 @@ http_archive(
2828

2929
load("@build_bazel_rules_nodejs//:index.bzl", "check_bazel_version", "node_repositories", "yarn_install")
3030

31-
# The minimum bazel version to use with this repo is v1.1.0.
32-
check_bazel_version("1.1.0")
31+
# The minimum bazel version to use with this repo is v2.0.0.
32+
check_bazel_version("2.0.0")
3333

3434
node_repositories(
3535
node_repositories = {
@@ -52,8 +52,8 @@ yarn_install(
5252
# We add the postinstall patches file, and ngcc main fields update script here so
5353
# that Yarn will rerun whenever one of these files has been modified.
5454
data = [
55-
"//:tools/bazel/postinstall-patches.js",
56-
"//:tools/bazel/update-ngcc-main-fields.js",
55+
"//:tools/postinstall/apply-patches.js",
56+
"//:tools/postinstall/update-ngcc-main-fields.js",
5757
],
5858
package_json = "//:package.json",
5959
yarn_lock = "//:yarn.lock",
@@ -100,9 +100,9 @@ sass_repositories()
100100
# Bring in bazel_toolchains for RBE setup configuration.
101101
http_archive(
102102
name = "bazel_toolchains",
103-
sha256 = "3c1299efcf64a4ecf4f6def7564db28879ad2870632144d77932e7910686d3f3",
104-
strip_prefix = "bazel-toolchains-1.1.2",
105-
url = "https://github.com/bazelbuild/bazel-toolchains/archive/1.1.2.tar.gz",
103+
sha256 = "4d348abfaddbcee0c077fc51bb1177065c3663191588ab3d958f027cbfe1818b",
104+
strip_prefix = "bazel-toolchains-2.1.0",
105+
url = "https://github.com/bazelbuild/bazel-toolchains/archive/2.1.0.tar.gz",
106106
)
107107

108108
load("@bazel_toolchains//repositories:repositories.bzl", bazel_toolchains_repositories = "repositories")
@@ -116,8 +116,8 @@ rbe_autoconfig(
116116
# Need to specify a base container digest in order to ensure that we can use the checked-in
117117
# platform configurations for the "ubuntu16_04" image. Otherwise the autoconfig rule would
118118
# need to pull the image and run it in order determine the toolchain configuration.
119-
# See: https://github.com/bazelbuild/bazel-toolchains/blob/master/rules/rbe_repo.bzl#L229
120-
base_container_digest = "sha256:1ab40405810effefa0b2f45824d6d608634ccddbf06366760c341ef6fbead011",
119+
# See: https://github.com/bazelbuild/bazel-toolchains/blob/master/configs/ubuntu16_04_clang/versions.bzl#L9
120+
base_container_digest = "sha256:fd5690d000da5759121f28ccbc19ebb4545841d816bbf6a72de482cf3e7ce491",
121121
digest = "sha256:0b8fa87db4b8e5366717a7164342a029d1348d2feea7ecc4b18c780bc2507059",
122122
registry = "marketplace.gcr.io",
123123
# We can't use the default "ubuntu16_04" RBE image provided by the autoconfig because we need

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
"yarn": ">= 1.19.1"
1414
},
1515
"scripts": {
16-
"postinstall": "node tools/bazel/postinstall-patches.js && ngcc --properties main --create-ivy-entry-points && node tools/bazel/update-ngcc-main-fields.js",
16+
"postinstall": "node tools/postinstall/apply-patches.js && ngcc --properties main --create-ivy-entry-points && node tools/postinstall/update-ngcc-main-fields.js",
1717
"build": "node ./scripts/build-packages-dist.js",
18+
"bazel": "bazelisk",
1819
"bazel:buildifier": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,output-group,package-name,package-on-top,redefined-variable,repository-name,same-origin-load,string-iteration,unused-variable,unsorted-dict-items,out-of-order-load",
1920
"bazel:format-lint": "yarn -s bazel:buildifier --lint=warn --mode=check",
2021
"dev-app": "ibazel run //src/dev-app:devserver",
@@ -69,13 +70,13 @@
6970
"@angular/platform-browser-dynamic": "^9.0.0",
7071
"@angular/platform-server": "^9.0.0",
7172
"@angular/router": "^9.0.0",
72-
"@bazel/bazel": "^1.1.0",
73+
"@bazel/bazelisk": "^1.3.0",
7374
"@bazel/buildifier": "^0.29.0",
74-
"@bazel/ibazel": "^0.10.3",
75-
"@bazel/jasmine": "1.0.0",
76-
"@bazel/karma": "1.0.0",
77-
"@bazel/protractor": "1.0.0",
78-
"@bazel/typescript": "1.0.0",
75+
"@bazel/ibazel": "^0.11.1",
76+
"@bazel/jasmine": "^1.3.0",
77+
"@bazel/karma": "^1.3.0",
78+
"@bazel/protractor": "^1.3.0",
79+
"@bazel/typescript": "^1.3.0",
7980
"@firebase/app-types": "^0.3.2",
8081
"@octokit/rest": "^16.28.7",
8182
"@schematics/angular": "^9.0.0",

scripts/circleci/setup_bazel_binary.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
bazelBin=$(node -p "require('@bazel/bazel').getNativeBinary()")
5+
bazelBin=$(node -p "require('@bazel/bazelisk/bazelisk.js').getNativeBinary()")
66

77
# Provide the bazel binary globally. We don't want to access the binary
88
# through Node as it could result in limited memory.

tools/BUILD.bazel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
package(default_visibility = ["//visibility:public"])
22

3+
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
4+
35
exports_files([
46
"system-config-tmpl.js",
57
"system-rxjs-operators.js",
68
])
79

10+
# Custom "tsc_wrapped" binary that has "tsickle" available as runtime dependency.
11+
# This is needed as the default compiler for a "ts_library" does not have a dependency
12+
# on "tsickle" by default.
13+
nodejs_binary(
14+
name = "tsc_wrapped_with_tsickle",
15+
data = [
16+
"@npm//@bazel/typescript",
17+
"@npm//tsickle",
18+
],
19+
entry_point = "@npm//:node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js",
20+
install_source_map_support = False,
21+
)
22+
823
# Workaround for https://github.com/bazelbuild/bazel-toolchains/issues/356. We need the
924
# "SYS_ADMIN" capability in order to run browsers with sandbox enabled.
1025
platform(

tools/bazel/BUILD.bazel

Lines changed: 0 additions & 16 deletions
This file was deleted.

tools/create-system-config.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS")
33
load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_ENTRYPOINTS")
44
load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS", "MATERIAL_TESTING_ENTRYPOINTS")
55
load("//src/material-experimental:config.bzl", "MATERIAL_EXPERIMENTAL_ENTRYPOINTS")
6-
load("//tools/bazel:expand_template.bzl", "expand_template")
6+
load("//tools:expand_template.bzl", "expand_template")
77

88
"""
99
Macro that builds a SystemJS configuration for all packages and entry-points

tools/defaults.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def ts_library(tsconfig = None, deps = [], testonly = False, **kwargs):
4444
# The default "ts_library" compiler does not come with "tsickle" available. Since
4545
# we have targets that use "tsickle" decorator processing, we need to ensure that
4646
# the compiler could load "tsickle" if needed.
47-
compiler = "//tools/bazel:tsc_wrapped_with_tsickle",
47+
compiler = "//tools:tsc_wrapped_with_tsickle",
4848
deps = local_deps,
4949
**kwargs
5050
)
File renamed without changes.

tools/postinstall/BUILD.bazel

Whitespace-only changes.

tools/bazel/postinstall-patches.js renamed to tools/postinstall/apply-patches.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ searchAndReplace(
4040
// that tsickle is available for esm5 output re-compilations.
4141
searchAndReplace(
4242
'@npm//@bazel/typescript/bin:tsc_wrapped',
43-
'@angular_material//tools/bazel:tsc_wrapped_with_tsickle',
43+
'@angular_material//tools:tsc_wrapped_with_tsickle',
4444
'node_modules/@angular/bazel/src/esm5.bzl');
4545

4646
// Workaround for: https://github.com/angular/angular/issues/32651. We just do not

yarn.lock

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -230,31 +230,10 @@
230230
lodash "^4.17.11"
231231
to-fast-properties "^2.0.0"
232232

233-
234-
version "1.1.0"
235-
resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-1.1.0.tgz#9402ecadfaf0383bc366ef5b37b933e0d0e804fc"
236-
integrity sha512-/dnpkjqnl2Qrcy+qFerOe+lV9QZ2HoUHtTplQgRxa+OH8AtQ7mcopdJ9/3Y10GqgT2Kp+AR6G99R59/Si+BOMg==
237-
238-
239-
version "1.1.0"
240-
resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-1.1.0.tgz#98d75240e3e9ff5ba14fa48d6241d5d741e89926"
241-
integrity sha512-yDR1URphRQTkXYjl4U2NLmbGR8ar8imhytK3txZZqlPf5pfWI/7wa7gSg0H4VbRRLIGAy/nD2eXZpgSj1eUiqA==
242-
243-
244-
version "1.1.0"
245-
resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-1.1.0.tgz#e9c80a8c6495834ee7fc6184c425284d1151ac38"
246-
integrity sha512-mj3ujcifKO+hjAjHvLoutYxzs90YWuc/fYJuVaEQrk4YFrRW5g70OpjN74zzBHRstObOjSZ3cOj+HDB19SIFKw==
247-
248-
"@bazel/bazel@^1.1.0":
249-
version "1.1.0"
250-
resolved "https://registry.yarnpkg.com/@bazel/bazel/-/bazel-1.1.0.tgz#9ce8308e44d76132812e908fcbc9e9051c7c2e1a"
251-
integrity sha512-3NOWRHG1i/tAVQWuStIUuliFLVfjcKMbqIlc2Q206VWQ5pjlKgo0qa+qrWb0G6BYq+N3hxT4IwBz+Z17A8dbbg==
252-
dependencies:
253-
"@bazel/hide-bazel-files" latest
254-
optionalDependencies:
255-
"@bazel/bazel-darwin_x64" "1.1.0"
256-
"@bazel/bazel-linux_x64" "1.1.0"
257-
"@bazel/bazel-win32_x64" "1.1.0"
233+
"@bazel/bazelisk@^1.3.0":
234+
version "1.3.0"
235+
resolved "https://registry.yarnpkg.com/@bazel/bazelisk/-/bazelisk-1.3.0.tgz#dc312dd30ad01e9af86e53b40795ab6e545fa55b"
236+
integrity sha512-73H1nq3572tTf+dhDT86aWQN+LCyfxrh05jabqPXp6cpR8soxte3gS5oUqkN36fUe+J2HzNiV4CXZTz4Xytd3Q==
258237

259238
260239
version "0.29.0"
@@ -280,41 +259,36 @@
280259
"@bazel/buildifier-linux_x64" "0.29.0"
281260
"@bazel/buildifier-win32_x64" "0.29.0"
282261

283-
"@bazel/hide-bazel-files@latest":
284-
version "0.35.0"
285-
resolved "https://registry.yarnpkg.com/@bazel/hide-bazel-files/-/hide-bazel-files-0.35.0.tgz#66ff148c1076534204d755024557609492718b7f"
286-
integrity sha512-+96mfEfoIpo2LNyN0929IwKpn50AXO04PZfonscvu3yV+3DVG1JLyq6W63zl/yGP1DAdgCPlRg5scNhkOzNpJw==
262+
"@bazel/ibazel@^0.11.1":
263+
version "0.11.1"
264+
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.11.1.tgz#c07ceaded388f1e39d6aa732953e0dd04f3dbdf0"
265+
integrity sha512-qAdEquFAudYyN+CYfLzvuRWNubdsh6C8+o5CiViUEfchq1HQM5Rs8xAOE3fzGsTZ1EUsvgca/PY0kn0VIxckBA==
287266

288-
"@bazel/ibazel@^0.10.3":
289-
version "0.10.3"
290-
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.10.3.tgz#2e2b8a1d3e885946eac41db2b1aa6801fb319887"
291-
integrity sha512-v1nXbMTHVlMM4z4uWp6XiRoHAyUlYggF1SOboLLWRp0+D22kWixqArWqnozLw2mOtnxr97BdLjluWiho6A8Hjg==
292-
293-
294-
version "1.0.0"
295-
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-1.0.0.tgz#12aa82c0e4b7b5658e9e496b73c0cf660df2b0ae"
296-
integrity sha512-cheQWMYs0PaS4kYwJC9tmAiyd0tLbPNcgoM+S8plNUp5k0gUVosCvQ0TOrxvRlKEY0ni1hdn9owPx2rUO1J+Wg==
267+
"@bazel/jasmine@^1.3.0":
268+
version "1.3.0"
269+
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-1.3.0.tgz#1d03aa67c18f122ffed4eb88e85455a797a8121d"
270+
integrity sha512-HY633xVy83eyLWt4o6CT8zHDxzVk+UfXCWCCWgJXWqpkB2BoYlq0Bvvpqcuj7Ilzn9vNX6w8gVeddRckIdBa/Q==
297271
dependencies:
298272
jasmine "~3.4.0"
299273
jasmine-core "~3.4.0"
300274
v8-coverage "1.0.9"
301275

302-
"@bazel/karma@1.0.0":
303-
version "1.0.0"
304-
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-1.0.0.tgz#6f1e31bc2cb698e50d76f43ec9f1ee095d8e72b8"
305-
integrity sha512-esfsHRVWVcp6OyTk/QI1sBV7bcygFiXY6LUMPLPYqVZkQvJ0x+/L1weiwuRrqFf+FCwCajhYjwiR6S9kX2Z9LA==
276+
"@bazel/karma@^1.3.0":
277+
version "1.3.0"
278+
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-1.3.0.tgz#8d4c336f04357ccc9633b9b6cdf8c79b15793ef1"
279+
integrity sha512-TyGoLBGTt9Mlp/FhwAytYaolUfrwMYuhNNzOYQ0lNzF73oEXOD1G9vIYLn2NvxQLPAaa2guBmNWSf0EkLhMuiw==
306280
dependencies:
307281
tmp "0.1.0"
308282

309-
"@bazel/protractor@1.0.0":
310-
version "1.0.0"
311-
resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-1.0.0.tgz#b77fde3bb53a008c330c13a953a0bf93aa06b5f1"
312-
integrity sha512-8kGuM3NkFfokjzKBlYxK9rUwJO/ICnYTHC567KJk6T4pjm4kfyh6iVI3Df3K+ONRCEYmiuZrQ37U06lzMMGN9g==
283+
"@bazel/protractor@^1.3.0":
284+
version "1.3.0"
285+
resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-1.3.0.tgz#050edc3480a6b5cf2b4c96daeced5cb871839298"
286+
integrity sha512-EwTlHbMwHIyPy7FhDiKLum2nlmmy27p/yQzWzN8dRnCIjmq4ezTfgNMnyZ5Z9HiQ2HM4kyzNx1f65eKNXXZK7w==
313287

314-
"@bazel/typescript@1.0.0":
315-
version "1.0.0"
316-
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-1.0.0.tgz#2c7318b9a3aaa730f282b094ddf41dd16fda7b5a"
317-
integrity sha512-caNOKz7EjVMgbedjVTreao9++9Sb9oYlU2nqDOMIK8MyoOUQvgGQWhFwF65XXGSb79Tzv8kaFQskoaH/iAs4ng==
288+
"@bazel/typescript@^1.3.0":
289+
version "1.3.0"
290+
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-1.3.0.tgz#6df7409ad8b2fcd80dfe859904fe91aacfb1a2cf"
291+
integrity sha512-F1Cjnjby+b3cO+rVuZY/9tzepf8wgoXZP9PtFmVWTQ+NtBkKEYx6IQ3AXZJl33mYVoN/Zb5qBTrGW/QfHUvakw==
318292
dependencies:
319293
protobufjs "6.8.8"
320294
semver "5.6.0"

0 commit comments

Comments
 (0)