Build API: Add logic to handle toolchain changes

Updated chromite build API protos to include new toolchain_change field

BUG=b:147589410
TEST=None

Change-Id: I51eafa718d3e59ab6abe78d5873f43670fb064a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1997261
Tested-by: Chris McDonald <cjmcdonald@chromium.org>
Reviewed-by: Alex Klein <saklein@chromium.org>
Auto-Submit: Chris McDonald <cjmcdonald@chromium.org>
diff --git a/api/controller/sysroot.py b/api/controller/sysroot.py
index f620a69..6fe5bee 100644
--- a/api/controller/sysroot.py
+++ b/api/controller/sysroot.py
@@ -88,7 +88,8 @@
 @validate.validation_complete
 def InstallToolchain(input_proto, output_proto, _config):
   """Install the toolchain into a sysroot."""
-  compile_source = input_proto.flags.compile_source
+  compile_source = (
+      input_proto.flags.compile_source or input_proto.flags.toolchain_changed)
 
   sysroot_path = input_proto.sysroot.path
   build_target_name = input_proto.sysroot.build_target.name
@@ -120,9 +121,13 @@
 @metrics.collect_metrics
 def InstallPackages(input_proto, output_proto, _config):
   """Install packages into a sysroot, building as necessary and permitted."""
-  compile_source = input_proto.flags.compile_source
+  compile_source = (
+      input_proto.flags.compile_source or input_proto.flags.toolchain_changed)
   event_file = input_proto.flags.event_file
-  use_goma = input_proto.flags.use_goma
+  # A new toolchain version will not yet have goma support, so goma must be
+  # disabled when we are testing toolchain changes.
+  use_goma = (
+      input_proto.flags.use_goma and not input_proto.flags.toolchain_changed)
 
   target_sysroot = sysroot_lib.Sysroot(input_proto.sysroot.path)
   build_target = controller_util.ParseBuildTarget(