From e393474c8c5e0e8c7437574379709915e55b14f2 Mon Sep 17 00:00:00 2001 From: Mohamed Heikal Date: Fri, 6 Mar 2020 02:48:50 +0000 Subject: [PATCH] Roll protobuf javalite runtime + fix gn package name This rolls in the new version 3.11.4 of the protobuf javalite runtime. The package name changed so this also fixes all references in gn files. A similar internal commit exists at crrev.com/i/1676922 This also changes how protoc is called to ask for the java lite runtime. The protoc javalite code gen plugin is no longer needed and will be removed in a followup cl. but reduces them per generated proto. Binary-Size: new runtime increases the number of methods in the runtime Bug: 988512 Change-Id: I8dd2ba97badea0b7dbaa8282afeb1da40636aee5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762684 Commit-Queue: Mohamed Heikal Reviewed-by: Andrew Grieve Reviewed-by: Yaron Friedman Reviewed-by: Peter Wen Reviewed-by: John Budorick Cr-Original-Commit-Position: refs/heads/master@{#747540} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0221b0c7ff5ad956c6a2ef1e247ed41625ee92b2 --- config/android/rules.gni | 9 +-------- protoc_java.py | 25 +++++++------------------ 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/config/android/rules.gni b/config/android/rules.gni index 1069a42c1..3c644b68d 100644 --- a/config/android/rules.gni +++ b/config/android/rules.gni @@ -4005,9 +4005,7 @@ if (enable_java_templates) { } else { # Use the regular proto library to generate lite protos. _protoc_bin = "//third_party/android_protoc/protoc" - _proto_runtime = - "//third_party/android_deps:com_google_protobuf_protobuf_lite_java" - _protoc_javalite_plugin_dir = "//third_party/protoc_javalite/" + _proto_runtime = "//third_party/android_deps:com_google_protobuf_protobuf_javalite_java" } _proto_path = invoker.proto_path _template_name = target_name @@ -4049,11 +4047,6 @@ if (enable_java_templates) { if (_generate_nano) { args += [ "--nano" ] - } else { - args += [ - "--protoc-javalite-plugin-dir", - rebase_path(_protoc_javalite_plugin_dir, root_build_dir), - ] } } diff --git a/protoc_java.py b/protoc_java.py index a56128dc6..f5db3b838 100755 --- a/protoc_java.py +++ b/protoc_java.py @@ -37,8 +37,6 @@ 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.") parser.add_option("--import-dir", action="append", default=[], help="Extra import directory for protos, can be repeated.") options, args = parser.parse_args(argv) @@ -48,10 +46,6 @@ 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 - proto_path_args = ['--proto_path', options.proto_path] for path in options.import_dir: proto_path_args += ["--proto_path", path] @@ -63,21 +57,16 @@ def main(argv): 'store_unknown_fields=true'] out_arg = '--javanano_out=' + ','.join(generator_args) + ':' + temp_dir else: - 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']) + out_arg = '--java_out=lite:' + temp_dir # Generate Java files using protoc. build_utils.CheckOutput( - [options.protoc] + proto_path_args + [out_arg] - + args, env=custom_env) + [options.protoc] + proto_path_args + [out_arg] + args, + # protoc generates superfluous warnings about LITE_RUNTIME deprecation + # even though we are using the new non-deprecated method. + stderr_filter=lambda output: + build_utils.FilterLines(output, + '|'.join([r'optimize_for = LITE_RUNTIME', r'java/lite\.md']))) if options.java_out_dir: build_utils.DeleteDirectory(options.java_out_dir)