summaryrefslogtreecommitdiff
path: root/chromium/build/protoc_java.py
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-13 16:23:34 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-14 10:37:21 +0000
commit38a9a29f4f9436cace7f0e7abf9c586057df8a4e (patch)
treec4e8c458dc595bc0ddb435708fa2229edfd00bd4 /chromium/build/protoc_java.py
parente684a3455bcc29a6e3e66a004e352dea4e1141e7 (diff)
downloadqtwebengine-chromium-38a9a29f4f9436cace7f0e7abf9c586057df8a4e.tar.gz
BASELINE: Update Chromium to 73.0.3683.37
Change-Id: I08c9af2948b645f671e5d933aca1f7a90ea372f2 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/build/protoc_java.py')
-rwxr-xr-xchromium/build/protoc_java.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/chromium/build/protoc_java.py b/chromium/build/protoc_java.py
index 5227bf94999..09cd8082b65 100755
--- a/chromium/build/protoc_java.py
+++ b/chromium/build/protoc_java.py
@@ -35,6 +35,8 @@ def main(argv):
parser.add_option("--stamp", help="File to touch on success.")
parser.add_option("--nano",
help="Use to generate nano protos.", action='store_true')
+ parser.add_option("--protoc-javalite-plugin-dir",
+ help="Path to protoc java lite plugin directory.")
options, args = parser.parse_args(argv)
build_utils.CheckOptions(options, parser, ['protoc', 'proto_path'])
@@ -42,6 +44,10 @@ def main(argv):
print 'One of --java-out-dir or --srcjar must be specified.'
return 1
+ if not options.nano and not options.protoc_javalite_plugin_dir:
+ print 'One of --nano or --protoc-javalite-plugin-dir must be specified.'
+ return 1
+
with build_utils.TempDir() as temp_dir:
if options.nano:
# Specify arguments to the generator.
@@ -49,23 +55,19 @@ def main(argv):
'store_unknown_fields=true']
out_arg = '--javanano_out=' + ','.join(generator_args) + ':' + temp_dir
else:
- out_arg = '--java_out=' + temp_dir
+ out_arg = '--javalite_out=' + temp_dir
+
+ custom_env = os.environ.copy()
+ if options.protoc_javalite_plugin_dir:
+ # if we are generating lite protos, then the lite plugin needs to be in the path when protoc
+ # is called. See https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md
+ custom_env['PATH'] = '{}:{}'.format(
+ os.path.abspath(options.protoc_javalite_plugin_dir), custom_env['PATH'])
- # Check if all proto files (which are listed in the args) are opting to
- # use the lite runtime, otherwise we'd have to include the much heavier
- # regular proto runtime in Chrome.
- # TODO(jkrcal): Replace this check by '--java_lite_out=' for the out_arg
- # above once this works on the master branch of the protobuf library,
- # expected in version 4.0 (see https://crbug.com/800281).
- for proto_file in args:
- if not 'LITE_RUNTIME' in open(proto_file).read():
- raise Exception(
- 'Chrome only supports lite protos. Please add "optimize_for = '
- 'LITE_RUNTIME" to your proto file to enable the lite runtime.')
# Generate Java files using protoc.
build_utils.CheckOutput(
[options.protoc, '--proto_path', options.proto_path, out_arg]
- + args)
+ + args, env=custom_env)
if options.java_out_dir:
build_utils.DeleteDirectory(options.java_out_dir)