commit | 312df64e5bc259b039a269b738c88c752aeb8fe3 | [log] [tgz] |
---|---|---|
author | Leandro Lovisolo <lovisolo@google.com> | Tue Dec 12 01:03:11 2023 +0000 |
committer | SkCQ <skcq-be@skia-corp.google.com.iam.gserviceaccount.com> | Tue Dec 12 01:10:10 2023 +0000 |
tree | 75f47d0d27d318329c1d3ed7f9f82abae43552f6 | |
parent | 2819fe5aaf9b55d429f4801b233966f0ee3c57c1 [diff] |
[bazel] Add copy_file_from_npm_pkg macro. The goal of this CL is to prepare our repository to migrate from rules_nodejs[1] to rules_js[2]. The rules_js ruleset exposes NPM packages in a way that makes it difficult to access individual files. As discussed in this Slack thread[3], the recommended way to access individual files from NPM packages under rules_js is by creating a local copy of the file using helper rules from the aspect-build/bazel_lib[4] ruleset. Note that this does not affect JS and TS dependencies from NPM, as rules_js (and rules_ts[5]) handle those differently. Our repository has a few use cases where we pick files directly from NPM packages via Bazel labels of the form "@npm//package/path/to/file.ext". This CL replaces all such labels with local copies of those files, which are created with the copy_file_from_npm_pkg macro. This macro simply copies files with a genrule that shells out to "cp". In follow-up CLs, I will migrate our repository to rules_js and I will update copy_file_from_npm_pkg to use rules from the aspect-build/bazel_lib ruleset as recommended in the aforementioned Slack thread. Regarding Sass and CSS dependencies from NPM packages: Unfortunately the rules_sass[6] ruleset is not compatible with rules_js. The recommended way to deal with Sass dependencies is to leverage rules_js's support for binaries published to NPM[7] and write a macro that shells out to the Sass compiler from the "sass" NPM package[8]. With this approach, any Sass or CSS files from NPM packages need to be copied as previously mentioned, e.g. by using the copy_file_from_npm_pkg macro. Given that this CL replaces all references to NPM files with local copies, including Sass and CSS files from NPM, there is no longer a need for our "sass_library" wrapper macro defined in //infra-sk/sass_library.bzl, which we used to add support for NPM imports in an ad-hoc way. Thus, this CL deletes //infra-sk/sass_library.bzl. A nice side-effect of this change is that we are better positioned to drop rules_sass in favor of a custom macro as described earlier. Likewise, our Gazelle extension no longer needs to support Sass and CSS imports from NPM, so this CL deletes those features from our Gazelle extension. [1] https://github.com/bazelbuild/rules_nodejs [2] https://github.com/aspect-build/rules_js [3] https://bazelbuild.slack.com/archives/CEZUUKQ6P/p1661466555661629 [4] https://github.com/aspect-build/bazel-lib [5] https://github.com/aspect-build/rules_ts [6] https://github.com/bazelbuild/rules_sass [7] https://docs.aspect.build/rulesets/aspect_rules_js/docs/#using-binaries-published-to-npm [8] https://www.npmjs.com/package/sass Bug: b/314813928 Change-Id: I9769c13d7748807ad78e607ee722e586283f7aa1 Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/787203 Reviewed-by: Kevin Lubick <kjlubick@google.com> Commit-Queue: Leandro Lovisolo <lovisolo@google.com>
This repo contains infrastructure code for Skia.
The main source code repository is a Git repository hosted at https://skia.googlesource.com/buildbot.git. It is possible to check out this repository directly with git clone
or via go get
.
Using git clone
allows you to work in whatever directory you want. You will still need to set GOPATH in order to build some apps (recommended to put this in a cache dir). E.g.:
$ cd ${WORKDIR} $ git clone https://skia.googlesource.com/buildbot.git $ export GOPATH=${HOME}/.cache/gopath/$(basename ${WORKDIR}) $ mkdir $GOPATH $ cd buildbot
Almost all applications are built with Bazel, and bazelisk is the recommended tool to ensure you have the right version of bazel installed:
go install github.com/bazelbuild/bazelisk@latest go install github.com/bazelbuild/buildtools/buildifier@latest go install github.com/kisielk/errcheck@latest go install golang.org/x/tools/cmd/goimports@latest go install github.com/mikefarah/yq/v4@latest go install go.chromium.org/luci/client/cmd/...@latest
sudo apt-get install jq
bazelisk build --config=mayberemote //...
bazelisk test --config=mayberemote //...
To update generated code run the following in any directory:
go generate ./...
Install Cloud SDK.
Use this command to run the presubmit tests:
./run_unittests --small