[roll] Roll fuchsia [bazel] Generate @gn_targets repository at regeneration time.

This is a reland of [1], which was reverted due to flakes in
our consistency-checking builders, which were addressed by
[2] separately since.

[1] https://fuchsia-review.googlesource.com/c/fuchsia/+/1399534
[2] https://fuchsia-review.googlesource.com/c/fuchsia/+/1427674

=== original commit message

Each bazel_action() GN target has a corresponding directory that
contains the content of its @gn_targets external repository,
consisting of BUILD.bazel files and symlinks to actual Ninja
artifact locations.

Before this CL, each @gn_target directory was populated at build
time, before invoking the bazel_action.py script to invoke Bazel
and process results / outputs.

After this CL, the directories are populated by //build/regenerator,
which allows performing Bazel queries just after `fx set` / `fint set`
on a clean checkout, before building anything. This will be used
in future CLs to implement advanced //build/api/client commands.

Note that, as a special case, a placeholder file for
@gn_targets//:all_licenses.spdx.json is created by regenerator with
a timestamp of 0 (!). This is to ensure that the file exists when
performing Bazel queries before the build.

However, that specific file will be updated by Ninja with proper
content, as it is the output of a GN action() dependency of the
corresponding parent GN bazel_action() target.

As a special consistency check, ActionsMap.update_gn_targets_symlink()
is updated with a new optional argument 'check_license_timestamp' to
verify that the file's timestamp is no longer 0, and panic otherwise.

This is invoked by bazel_action.py to catch any failure to properly
update the license file.

Benchmarking with `build/regenerator -v` shows that this new
regeneration step, named @gn_targets, has negligible cost.

```
Timing results for all regeneration steps:
 6.22s   gn gen
 0.02s   patching build.ninja
 0.48s   generate_prebuild_idk
 0.69s   @fuchsia_in_tree_idk
 0.00s   product_bundles.json
 0.00s   tests.json
 0.05s   bazel_content_hash_files
 0.00s   prebuilt_build_ids
 0.00s   remote_services.bazelrc
 0.00s   @fuchsia_build_info
 0.01s   bazel_workspace
 0.01s   @gn_targets
 0.00s   ninja_edge_weights.csv
 0.00s   regenerator_inputs.txt
 0.00s   build.ninja.d
```

NO_IFTTT=No need to change BUILD.gn as the schema didn't change.

Original-Bug: 427455042
Original-Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1428655
Original-Revision: d0b07a6def1673f67a58b6606e7790d2948b4593
GitOrigin-RevId: 8b36656797ae7b61fee461cb9c68523609e54839
Change-Id: I85e558a40032c0f917e06cc693cda0533c33ec9d
1 file changed
tree: f1f890c7fa32c11d29e689658b6ffdf56823a8c0
  1. ctf/
  2. git-hooks/
  3. infra/
  4. third_party/
  5. flower
  6. jiri.lock
  7. MILESTONE
  8. minimal
  9. prebuilts
  10. README.md
  11. stem
  12. test_durations
README.md

Integration

This repository contains Fuchsia's Global Integration manifest files.

Making changes

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.

Obtaining the source

First install Jiri.

Next run:

$ jiri init
$ jiri import minimal https://fuchsia.googlesource.com/integration
$ jiri update

Third party

Third party projects should have their own subdirectory in ./third_party.