Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: build/protoc_java.py

Issue 511283003: Add support for Java nano protocol buffers for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments from darin Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/protoc_java.gypi ('k') | third_party/android_protobuf/OWNERS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/protoc_java.py
diff --git a/build/protoc_java.py b/build/protoc_java.py
index 42e204464ac63d52e71fc8a6280b4c7c81278dc0..3ccbaa77215d197e37efb05481c3ac67bb96d3ba 100755
--- a/build/protoc_java.py
+++ b/build/protoc_java.py
@@ -3,10 +3,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""Generate java source files from protobufs
+"""Generate java source files from protobuf files.
Usage:
- protoc_java.py {protoc} {proto_path} {java_out} {stamp_file} {proto_files}
+ protoc_java.py {protoc} {proto_path} {java_out} {proto_runtime} \
+ {stamp_file} {proto_files}
This is a helper file for the genproto_java action in protoc_java.gypi.
@@ -15,6 +16,8 @@ It performs the following steps:
2. Creates source directory.
3. Generates Java files using protoc.
4. Creates a new stamp file.
+
+proto_runtime must be one of 'nano' and 'lite'.
"""
import os
@@ -23,27 +26,36 @@ import subprocess
import sys
def main(argv):
- if len(argv) < 5:
+ if len(argv) < 6:
usage()
return 1
- protoc_path, proto_path, java_out, stamp_file = argv[1:5]
- proto_files = argv[5:]
+ protoc_path, proto_path, java_out, proto_runtime, stamp_file = argv[1:6]
+ proto_files = argv[6:]
- # Delete all old sources
+ # Delete all old sources.
if os.path.exists(java_out):
shutil.rmtree(java_out)
- # Create source directory
+ # Create source directory.
os.makedirs(java_out)
- # Generate Java files using protoc
+ # Figure out which runtime to use.
+ if proto_runtime == 'nano':
+ out_arg = '--javanano_out=optional_field_style=reftypes,' + \
+ 'store_unknown_fields=true:' + java_out
+ elif proto_runtime == 'lite':
+ out_arg = '--java_out=' + java_out
+ else:
+ usage()
+ return 1
+
+ # Generate Java files using protoc.
ret = subprocess.call(
- [protoc_path, '--proto_path', proto_path, '--java_out', java_out]
- + proto_files)
+ [protoc_path, '--proto_path', proto_path, out_arg] + proto_files)
if ret == 0:
- # Create a new stamp file
+ # Create a new stamp file.
with file(stamp_file, 'a'):
os.utime(stamp_file, None)
« no previous file with comments | « build/protoc_java.gypi ('k') | third_party/android_protobuf/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698