cbuildbot: Add ChromeSDK stage.

Adds a ChromeSDK stage that:

1. Generates artifacts required for chrome-sdk for the board being
built.
2. Runs chrome-sdk against the newly generated artifacts, and builds
Chrome with it (using ninja and goma).
3. Runs deploy_chrome on the artifacts with --staging-only.

BUG=chromium:242998
TEST=Local, trybots

Change-Id: I6789fd1e842cbc72d0a72f9fdf1a8a90ea591a0b
Reviewed-on: https://gerrit.chromium.org/gerrit/63844
Commit-Queue: David James <davidjames@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 8c9f384..b558217 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -390,11 +390,14 @@
                      config=config)
       self._RunStage(stages.UnitTestStage, board, config=config)
       return
-    stage_list = [[stages.VMTestStage, board, archive_stage],
-                  [stages.SignerTestStage, board, archive_stage],
-                  [stages.UnitTestStage, board],
-                  [stages.UploadPrebuiltsStage, board, archive_stage],
-                  [stages.DevInstallerPrebuiltsStage, board, archive_stage]]
+    stage_list = []
+    if self.options.chrome_sdk and self.build_config['chrome_sdk']:
+      stage_list.append([stages.ChromeSDKStage, board, archive_stage])
+    stage_list += [[stages.VMTestStage, board, archive_stage],
+                   [stages.SignerTestStage, board, archive_stage],
+                   [stages.UnitTestStage, board],
+                   [stages.UploadPrebuiltsStage, board, archive_stage],
+                   [stages.DevInstallerPrebuiltsStage, board, archive_stage]]
 
     # We can not run hw tests without archiving the payloads.
     if self.options.archive:
@@ -987,6 +990,10 @@
   group.add_remote_option('--nocgroups', action='store_false', dest='cgroups',
                           default=True,
                           help='Disable cbuildbots usage of cgroups.')
+  group.add_remote_option('--nochromesdk', action='store_false',
+                          dest='chrome_sdk', default=True,
+                          help="Don't run the ChromeSDK stage which builds "
+                               "Chrome outside of the chroot.")
   group.add_remote_option('--noprebuilts', action='store_false',
                           dest='prebuilts', default=True,
                           help="Don't upload prebuilts.")