build api: Local protobuf version warning

The protobuf compile script requires v3.6.1 installed locally,
add a warning message to the script to make the requirement
clear until we are able to run it in the chroot.

BUG=chromium:912361
TEST=manual

Change-Id: Ia42014dff75e8c8ee138e844f446962eb34d9263
Reviewed-on: https://chromium-review.googlesource.com/1431697
Commit-Ready: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Alec Thilenius <athilenius@google.com>
diff --git a/api/compile_build_api_proto.py b/api/compile_build_api_proto.py
index 3fc527c..e14afdd 100644
--- a/api/compile_build_api_proto.py
+++ b/api/compile_build_api_proto.py
@@ -11,6 +11,7 @@
 
 from chromite.lib import commandline
 from chromite.lib import cros_build_lib
+from chromite.lib import cros_logging as logging
 
 
 def GetParser():
@@ -35,6 +36,26 @@
   source = os.path.join(base_dir, 'proto')
   targets = os.path.join(source, '*.proto')
 
+  # TODO(crbug.com/924660) Update compile to run in the chroot and remove
+  # the warning.
+  protoc_version = ['protoc', '--version']
+  result = cros_build_lib.RunCommand(protoc_version, print_cmd=False,
+                                     redirect_stdout=True,
+                                     combine_stdout_stderr=True,
+                                     error_code_ok=True)
+  if not result.returncode == 0 or not '3.6.1' in result.output:
+    logging.warning('You must have libprotoc 3.6.1 installed locally to '
+                    'compile the protobuf correctly.')
+    logging.warning('This will be run in the chroot in the future '
+                    '(see crbug.com/924660).')
+    if not result.returncode == 0:
+      logging.warning('protoc could not be found on your system.')
+    else:
+      logging.warning('"%s" was found on your system.', result.output.strip())
+
+    logging.warning("We won't stop you from running it for now, but be very "
+                    "weary of your changes.")
+
   cmd = ('protoc --python_out %(output)s --proto_path %(source)s %(targets)s'
          % {'output': output, 'source': source, 'targets': targets})