Explorar o código

Revert "Remove ability to use_goma via autoninja."

This reverts commit 1592a89c9f98ae6a9cd757aed8b7f4cac07d5f1e.

Reason for revert:
b/325856422

Original change's description:
> Remove ability to use_goma via autoninja.
>
> Doesn't run a build if use_goma is true, point to reclient docs.  Turns
> off use_goma for linux and mac builds.  Windows will follow in 2-3 weeks.
>
> Bug: b/277197166
> Change-Id: Icf000ee5e4bdfeba82cadbbf2e02e7cd728e89b0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5272474
> Reviewed-by: Ben Segall <bentekkie@google.com>
> Reviewed-by: Ramy Medhat <abdelaal@google.com>
> Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
> Commit-Queue: Michael Savigny <msavigny@google.com>

Bug: b/277197166 b/325856422
Change-Id: Iaec83b254af002f420bfd2df1154ce94e18fac15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5308674
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Owners-Override: David Munro <davidmunro@google.com>
Reviewed-by: David Munro <davidmunro@google.com>
Takuto Ikuta hai 1 ano
pai
achega
280bb93210
Modificáronse 2 ficheiros con 40 adicións e 88 borrados
  1. 38 41
      autoninja.py
  2. 2 47
      tests/autoninja_test.py

+ 38 - 41
autoninja.py

@@ -332,46 +332,6 @@ def main(args):
         use_goma = False
 
     if use_goma:
-        # Display a warning that goma is being deprecated, every time a build
-        # is executed with 'use_goma.
-        # Further changes to encourage switching may follow.
-        if sys.platform.startswith("win"):
-            print(
-                "The gn arg use_goma=true will be removed on Feb 21st. "
-                "Please use `use_remoteexec=true` instead. See "
-                "https://chromium.googlesource.com/chromium/src/+/main/docs/"
-                "windows_build_instructions.md#use-reclient "
-                "for setup instructions.",
-                file=sys.stderr,
-            )
-
-            t = 5
-            while t > 0:
-                print(
-                    f"The build will start in {t} seconds.",
-                    file=sys.stderr,
-                )
-                time.sleep(1)
-                t = t - 1
-        elif sys.platform == "darwin":
-            print(
-                "The gn arg `use_goma=true` is no longer supported. "
-                "Please use `use_remoteexec=true` instead. "
-                "If you are a googler see http://go/building-chrome-mac"
-                "#using-remote-execution for setup instructions. ",
-                file=sys.stderr,
-            )
-            sys.exit(1)
-        else:
-            print(
-                "The gn arg `use_goma=true` is no longer supported. "
-                "Please use `use_remoteexec=true` instead. See "
-                "https://chromium.googlesource.com/chromium/src/+/main/docs/"
-                "linux/build_instructions.md#use-reclient for setup instructions.",
-                file=sys.stderr,
-            )
-            sys.exit(1)
-
         gomacc_file = ("gomacc.exe"
                        if sys.platform.startswith("win") else "gomacc")
         goma_dir = os.environ.get("GOMA_DIR",
@@ -401,7 +361,44 @@ def main(args):
                     # script.
                     print("false")
                 sys.exit(1)
-
+        # Display a warning that goma is being deprecated, every time a build
+        # is executed with 'use_goma.
+        # Further changes to encourage switching may follow.
+        if sys.platform.startswith("win"):
+            print(
+                "The gn arg use_goma=true will be deprecated by EOY 2023. "
+                "Please use `use_remoteexec=true` instead. See "
+                "https://chromium.googlesource.com/chromium/src/+/main/docs/"
+                "windows_build_instructions.md#use-reclient "
+                "for setup instructions.",
+                file=sys.stderr,
+            )
+        elif sys.platform == "darwin":
+            print(
+                "The gn arg use_goma=true will be removed on Feb 7th 2024. "
+                "Please use `use_remoteexec=true` instead. "
+                "If you are a googler see http://go/building-chrome-mac"
+                "#using-remote-execution for setup instructions. ",
+                file=sys.stderr,
+            )
+        else:
+            print(
+                "The gn arg use_goma=true will be removed on Feb 7th 2024. "
+                "Please use `use_remoteexec=true` instead. See "
+                "https://chromium.googlesource.com/chromium/src/+/main/docs/"
+                "linux/build_instructions.md#use-reclient for setup instructions.",
+                file=sys.stderr,
+            )
+        if not sys.platform.startswith("win"):
+            # Artificial build delay is for linux/mac for now.
+            t = 5
+            while t > 0:
+                print(
+                    f"The build will start in {t} seconds.",
+                    file=sys.stderr,
+                )
+                time.sleep(1)
+                t = t - 1
 
 
     # A large build (with or without goma) tends to hog all system resources.

+ 2 - 47
tests/autoninja_test.py

@@ -73,51 +73,6 @@ class AutoninjaTest(trial_dir.TestCase):
         self.assertEqual(args[args.index('-C') + 1], out_dir)
         self.assertIn('base', args)
 
-    @mock.patch('sys.platform', 'linux')
-    def test_autoninja_goma_not_supported_linux(self):
-        """
-        Test that when specifying use_goma=true and on linux, the
-        message that goma is not supported is displayed.
-        """
-        goma_dir = os.path.join(self.root_dir, 'goma_dir')
-        with mock.patch.dict(os.environ, {"GOMA_DIR": goma_dir}):
-            out_dir = os.path.join('out', 'dir')
-            write(os.path.join(out_dir, 'args.gn'), 'use_goma=true')
-            write(
-                os.path.join(
-                    'goma_dir', 'gomacc.exe'
-                    if sys.platform.startswith('win') else 'gomacc'), 'content')
-            with contextlib.redirect_stderr(io.StringIO()) as f:
-                with self.assertRaises(SystemExit):
-                    self.assertEqual(
-                        autoninja.main(['autoninja.py', '-C', out_dir]), 1)
-                self.assertIn(
-                    "The gn arg `use_goma=true` is no longer supported.",
-                    f.getvalue())
-
-    @mock.patch('sys.platform', 'darwin')
-    def test_autoninja_goma_not_supported_mac(self):
-        """
-        Test that when specifying use_goma=true and on mac, the
-        message that goma is not supported is displayed.
-        """
-        goma_dir = os.path.join(self.root_dir, 'goma_dir')
-        with mock.patch.dict(os.environ, {"GOMA_DIR": goma_dir}):
-            out_dir = os.path.join('out', 'dir')
-            write(os.path.join(out_dir, 'args.gn'), 'use_goma=true')
-            write(
-                os.path.join(
-                    'goma_dir', 'gomacc.exe'
-                    if sys.platform.startswith('win') else 'gomacc'), 'content')
-            with contextlib.redirect_stderr(io.StringIO()) as f:
-                with self.assertRaises(SystemExit):
-                    self.assertEqual(
-                        autoninja.main(['autoninja.py', '-C', out_dir]), 1)
-                self.assertIn(
-                    "The gn arg `use_goma=true` is no longer supported.",
-                    f.getvalue())
-
-    @mock.patch('sys.platform', 'win')
     def test_autoninja_goma(self):
         """
         Test that when specifying use_goma=true, autoninja verifies that Goma
@@ -125,8 +80,8 @@ class AutoninjaTest(trial_dir.TestCase):
         """
         goma_dir = os.path.join(self.root_dir, 'goma_dir')
         with mock.patch('subprocess.call', return_value=0), \
-            mock.patch('ninja.main', return_value=0) as ninja_main, \
-            mock.patch.dict(os.environ, {"GOMA_DIR": goma_dir}):
+             mock.patch('ninja.main', return_value=0) as ninja_main, \
+             mock.patch.dict(os.environ, {"GOMA_DIR": goma_dir}):
             out_dir = os.path.join('out', 'dir')
             write(os.path.join(out_dir, 'args.gn'), 'use_goma=true')
             write(