Regenerate proto bindings, with required fixes to compilation script.
- protoc doesn't generate bindings for imports that aren't passed to
"--proto_path". In this case, this means there are no bindings for
protos under src/config, leading to errors like "ImportError: cannot
import name 'storage_path_pb2' from 'chromite.api.gen.chromiumos'"
Include src/config protos in "--proto_path" to generate bindings for
these protos.
BUG=b:187793427
BUG=b:182898188
TEST=./run_tests
Change-Id: I3c7c2e3f6a53f9f76eeb2b7df52f9464be35ea7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3055273
Commit-Queue: Andrew Lamb <andrewlamb@chromium.org>
Tested-by: Andrew Lamb <andrewlamb@chromium.org>
Reviewed-by: Alex Klein <saklein@chromium.org>
diff --git a/api/compile_build_api_proto.py b/api/compile_build_api_proto.py
index 1605c7c..01aa0ba 100644
--- a/api/compile_build_api_proto.py
+++ b/api/compile_build_api_proto.py
@@ -128,22 +128,6 @@
targets = []
- # Only compile the subset we need for the API.
- subdirs = [
- os.path.join(source, 'chromite'),
- os.path.join(source, 'chromiumos'),
- os.path.join(source, 'client'),
- os.path.join(source, 'config'),
- os.path.join(source, 'test_platform'),
- os.path.join(source, 'device')
- ]
- for basedir in subdirs:
- for dirpath, _dirnames, filenames in os.walk(basedir):
- for filename in filenames:
- if filename.endswith('.proto'):
- # We have a match, add the file.
- targets.append(os.path.join(dirpath, filename))
-
chromeos_config_path = os.path.realpath(
os.path.join(constants.SOURCE_ROOT, 'src/config'))
@@ -157,6 +141,23 @@
depth=1
)
+ # Only compile the subset we need for the API.
+ subdirs = [
+ os.path.join(source, 'chromite'),
+ os.path.join(source, 'chromiumos'),
+ os.path.join(source, 'client'),
+ os.path.join(source, 'config'),
+ os.path.join(source, 'test_platform'),
+ os.path.join(source, 'device'),
+ os.path.join(chromeos_config_path, 'proto/chromiumos'),
+ ]
+ for basedir in subdirs:
+ for dirpath, _dirnames, filenames in os.walk(basedir):
+ for filename in filenames:
+ if filename.endswith('.proto'):
+ # We have a match, add the file.
+ targets.append(os.path.join(dirpath, filename))
+
cmd = [
_get_protoc_command(protoc_version),
'-I',