| commit | f697c10164c23bf2e5993b563e9b290f37f39f70 | [log] [tgz] |
|---|---|---|
| author | David 'Digit' Turner <digit@fuchsia.infra.roller.google.com> | Tue Feb 18 23:48:25 2025 -0800 |
| committer | Copybara-Service <copybara-worker@google.com> | Tue Feb 18 23:49:47 2025 -0800 |
| tree | 6a27affe7e008ffa17b691d51c12f68f9de70aba | |
| parent | 98813caf9340c15ef0ef56453c567a6194cf0719 [diff] |
[roll] Roll fuchsia [build][bazel] Avoid unnecessary Bazel invocations on args.gn updates. This CL fixes the second issue described in the associated bug, namely that any change to `args.json` (generated by GN after parsing `args.gn`) will trigger Bazel rebuilds, even if the changes are not used by the Bazel build graph. The reason why was that the @fuchsia_build_info repository used to treat `args.json` as an input, and filtered it based on the content of //build/bazel/gn_build_args.txt and any //vendor/*/build/bazel/gn_build_args.txt file, in order to generate @fuchsia_build_info//:args.bzl and @fuchsia_build_info//:vendor_*_args.bzl. But since the filtering happened entirely in Bazel, Ninja could not know which values in args.json are needed by Bazel, and would just re-run any bazel_action() target when that file changes. To solve this, the filtering logic is moved to `fx gen` time instead. So a Bazel repository rule is removed, in favor of generating the repository content through a Python function invoked by build/regenerator.py. - args.json and the gn_build_args.txt are all read at 'fx gen' time to perform the filtering and computing all results as a JSON manifest, which is compared to its last-generated value stored at: $BUILD_DIR/regenerator_outputs/fuchsia_build_info.generator-info.json - If the manifest's content has changed, the directory at $BUILD_DIR/regenerator_outputs/fuchsia_build_info/ is entirely regenerated. Otherwise, it is kept untouched, leaving the timestamps of args.bzl and vendor_*_args.bzl there intact. - Update toplevel.WORKSPACE.bazel to use local_repository() to point @fuchsia_build_info directly to the generated manifest. The Python logic is added to workspace_utils.py, which allows better unit-tests than a Bazel repository rule: + Add GeneratedWorkspaceFiles.update_if_needed() method to perform the conditional update of the output directory when the manifest changes only. + Add GnBuildArgs class to workspace_utils.py to generate the parsing of gn_build_args.txt files and the generation of args.bzl files out of it. After this change, adding new lines to `args.gn` will not re-trigger a Ninja `bazel_action()` target on the next incremental `fx build`, unless the new values modify one of the variables listed in the `gn_build_args.txt` files, or the Ninja artifacts that serve as input to said actions. A simple way to test it is the following, after applying this CL: 1. Do a regular minimal.x64 full build with `fx set minimal.x64 && fx build`. 2. Add `build_only_labels = [ "//build/bazel/scripts:tests" ]` to your args.gn, then run `fx build`, and verify that this does *not* trigger Bazel actions (it did before the CL). 3. Add `delegated_network_provisioning = true` to your args.gn, which changes one of the argument described by //build/bazel/gn_build_args.txt. 4. Verify that this will trigger a Bazel action with the following command that explains that this is due to the change in @fuchsia_build_info/args.bzl. ```sh $ fx build //products/microfuchsia:microfuchsia_eng.pkvm-x64_bazel_build_group -- -n -d explain 2>&1 ninja: Entering directory `/work/fx-better-build/out/default' ninja explain: recorded mtime of obj/products/microfuchsia/microfuchsia_eng.pkvm-x64_bazel_build_group.path_mapping older than most recent input regenerator_outputs/fuchsia_build_info/args.bzl (1739892968744669159 vs 1739893047710016640) ``` Original-Bug: 396958139 Original-Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1207949 Original-Revision: 25b344279a1aa42916158cd2da2e89b1c32870d5 GitOrigin-RevId: 6b4031e672a89f994da3ce58f3bfb60257dd41e6 Change-Id: I156b131f7251ff942d8fcc42e29d7161d1e5e18c
This repository contains Fuchsia's Global Integration manifest files.
All changes should be made to the internal version of this repository. Our infrastructure automatically updates this version when the internal one changes.
Currently all changes must be made by a Google employee. Non-Google employees wishing to make a change can ask for assistance in one of the communication channels documented at get involved.
First install Jiri.
Next run:
$ jiri init $ jiri import minimal https://fuchsia.googlesource.com/integration $ jiri update
Third party projects should have their own subdirectory in ./third_party.