[go: nahoru, domu]

Reland "Reland "build/toolchain: check existence of reclient configs in GN""

This reverts commit 2363d9d2beb8e167cdac669c4ac153f2d0a25dee.

Reason for revert:
Fix for previous breakage was made as https://crrev.com/c/4941335.

Original change's description:
> Revert "Reland "build/toolchain: check existence of reclient configs in GN""
>
> This reverts commit 22acd2f1adc9cb01c0b55bf760b3f991e30f0706.
>
> Reason for revert: crbug/1492504 - Breaks chrome.ci/ci/win64-builder-perf
>
> Original change's description:
> > Reland "build/toolchain: check existence of reclient configs in GN"
> >
> > This reverts commit 4a2851adac4fd9c83cf2ed985f16c144e55c15d7.
> >
> > Reason for revert:
> >
> > Fix path in `file_dependencies` to avoid the error from `gn gen` when
> > that is ran from
> > https://source.chromium.org/chromium/chromium/src/+/main:build/android/test/incremental_javac_gn/incremental_javac_test_android_library.py
> >
> > rbe_cc_cfg_file is already rebased on root_build_dir, but paths in
> > `file_dependencies` also seem to be rebased on directory of
> > `build/toolchain/rbe.gni` automatically. So need to fix the path passed
> > to `file_dependencies` in exec_script.
> >
> > Original change's description:
> > > Revert "build/toolchain: check existence of reclient configs in GN"
> > >
> > > This reverts commit 743eba2dfd72a422a816f8d1eb948f83e48c2fae.
> > >
> > > Reason for revert:
> > > LUCI Bisection identified this CL as the culprit of a build failure. See the analysis: https://luci-bisection.appspot.com/analysis/b/8767373823290641361
> > >
> > > Sample failed build: https://ci.chromium.org/b/8767373823290641361
> > >
> > > If this is a false positive, please report it at https://bugs.chromium.org/p/chromium/issues/entry?comment=Analysis%3A+https%3A%2F%2Fluci-bisection.appspot.com%2Fanalysis%2Fb%2F8767373823290641361&components=Tools%3ETest%3EFindit&labels=LUCI-Bisection-Wrong%2CPri-3%2CType-Bug&status=Available&summary=Wrongly+blamed+https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fsrc%2F%2B%2F4930333
> > >
> > > Original change's description:
> > > > build/toolchain: check existence of reclient configs in GN
> > > >
> > > > This is to show user friendly message when user forget to set
> > > > download_remoteexec_cfg in .gclient.
> > > >
> > > > ref: https://gn.googlesource.com/gn/+/refs/heads/main/docs/reference.md#func_exec_script
> > > >
> > > > Bug: b/303174319
> > > > Change-Id: Ic3499a100ab197ea4794bcec4727b92a44ed7785
> > > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4930333
> > > > Reviewed-by: Junji Watanabe <jwata@google.com>
> > > > Reviewed-by: Fumitoshi Ukai <ukai@google.com>
> > > > Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
> > > > Cr-Commit-Position: refs/heads/main@{#1209256}
> > > >
> > >
> > > Bug: b/303174319
> > > Change-Id: I3658b0f145d96a00d54dfd3d0a63554b4240c581
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4937971
> > > Bot-Commit: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com>
> > > Owners-Override: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com>
> > > Commit-Queue: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com>
> > > Cr-Commit-Position: refs/heads/main@{#1209270}
> >
> > Bug: b/303174319
> > Change-Id: I101bdd008b2e6e999b98d894776b16db87ecc989
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4937397
> > Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
> > Reviewed-by: Junji Watanabe <jwata@google.com>
> > Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1209326}
>
> Bug: b/303174319
> Change-Id: I016302e4829b257ab85499666e57f4d1b248a807
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4939373
> Commit-Queue: Jeff Yoon <jeffyoon@google.com>
> Auto-Submit: Jeff Yoon <jeffyoon@google.com>
> Reviewed-by: Nico Weber <thakis@chromium.org>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Cr-Commit-Position: refs/heads/main@{#1209624}

Bug: chromium:1492504 b/303174319
Change-Id: I21c44f4a492df4290359ec109f368060a22e3494
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4941520
Reviewed-by: Junji Watanabe <jwata@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1210618}
diff --git a/.gn b/.gn
index 321877844..3553f09 100644
--- a/.gn
+++ b/.gn
@@ -150,6 +150,10 @@
       # in the Chromium repo outside of //build.
       "//build_overrides/build.gni",
 
+      # This is to check existence of a reclient config file and show user
+      # friendly error message.
+      "//build/toolchain/rbe.gni",
+
       "//chrome/android/webapk/shell_apk/prepare_upload_dir/BUILD.gn",
       "//chrome/version.gni",
 
diff --git a/build/toolchain/check_rewrapper_cfg.py b/build/toolchain/check_rewrapper_cfg.py
new file mode 100755
index 0000000..52ef1d1
--- /dev/null
+++ b/build/toolchain/check_rewrapper_cfg.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python3
+# Copyright 2023 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import sys
+
+
+def main():
+  if len(sys.argv) != 2:
+    print("This should have a path to reclient config file in its args.",
+          file=sys.stderr)
+    return 1
+
+  # Check path to rbe_cc_cfg_file.
+  if os.path.isfile(sys.argv[1]):
+    return 0
+
+  print("""
+  reclient config file "%s" doesn't exist, you may need to set
+  "download_remoteexec_cfg" in .gclient like
+  ```
+  solutions = [
+    {
+      "name"        : "src",
+      # ...
+      "custom_vars" : {
+        "download_remoteexec_cfg": True,
+      },
+    },
+  ]
+  ```
+  and re-run `gclient sync`.
+
+  Or you may not set appropriate `rbe_cfg_dir` value in args.gn.
+
+  See
+  https://chromium.googlesource.com/chromium/src/+/main/docs/linux/build_instructions.md#use-reclient
+  for more details.
+  """ % (sys.argv[1]),
+        file=sys.stderr)
+
+  return 1
+
+
+if __name__ == "__main__":
+  sys.exit(main())
diff --git a/build/toolchain/rbe.gni b/build/toolchain/rbe.gni
index dbf21bf..fe2cfb5 100644
--- a/build/toolchain/rbe.gni
+++ b/build/toolchain/rbe.gni
@@ -52,6 +52,15 @@
   rbe_cros_cc_wrapper = "${rbe_bin_dir}/rewrapper"
 }
 
+if (use_remoteexec && current_toolchain == default_toolchain) {
+  # Check existence of reclient configs and show user friendly error message if
+  # it doesn't.
+  exec_script(rebase_path("//build/toolchain/check_rewrapper_cfg.py"),
+              [ rbe_cc_cfg_file ],
+              "",
+              [ rebase_path(rbe_cc_cfg_file, ".", root_build_dir) ])
+}
+
 if (is_win) {
   if (use_remoteexec_links) {
     print("For now, remote linking is not available for Windows.")