summaryrefslogtreecommitdiffstats
path: root/build/protoc_java.py
diff options
context:
space:
mode:
authornyquist@chromium.org <nyquist@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 21:20:47 +0000
committernyquist@chromium.org <nyquist@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 21:20:47 +0000
commitd339e3cbbe150f7090f1a6463efb84e9462c210c (patch)
tree9c9d7a06b9f2997fcddd46a60363e0a98af3ffed /build/protoc_java.py
parent4010cd52d42dd1ddadcc842bf9f7cb6be05fb5ad (diff)
downloadchromium_src-d339e3cbbe150f7090f1a6463efb84e9462c210c.zip
chromium_src-d339e3cbbe150f7090f1a6463efb84e9462c210c.tar.gz
chromium_src-d339e3cbbe150f7090f1a6463efb84e9462c210c.tar.bz2
Add support for generating jars from protos and add cacheinvalidation_java.
The cacheinvalidation_java target is also added to build/all_android.gyp to ensure it is always built since nothing currently depends on it upstream. When all of Android-specific sync code is upstreamed, a target for sync should be used instead of cacheinvalidation. BUG=158382 Review URL: https://chromiumcodereview.appspot.com/11146005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167746 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/protoc_java.py')
-rwxr-xr-xbuild/protoc_java.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/build/protoc_java.py b/build/protoc_java.py
new file mode 100755
index 0000000..42e2044
--- /dev/null
+++ b/build/protoc_java.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# 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
+
+Usage:
+ protoc_java.py {protoc} {proto_path} {java_out} {stamp_file} {proto_files}
+
+This is a helper file for the genproto_java action in protoc_java.gypi.
+
+It performs the following steps:
+1. Deletes all old sources (ensures deleted classes are not part of new jars).
+2. Creates source directory.
+3. Generates Java files using protoc.
+4. Creates a new stamp file.
+"""
+
+import os
+import shutil
+import subprocess
+import sys
+
+def main(argv):
+ if len(argv) < 5:
+ usage()
+ return 1
+
+ protoc_path, proto_path, java_out, stamp_file = argv[1:5]
+ proto_files = argv[5:]
+
+ # Delete all old sources
+ if os.path.exists(java_out):
+ shutil.rmtree(java_out)
+
+ # Create source directory
+ os.makedirs(java_out)
+
+ # Generate Java files using protoc
+ ret = subprocess.call(
+ [protoc_path, '--proto_path', proto_path, '--java_out', java_out]
+ + proto_files)
+
+ if ret == 0:
+ # Create a new stamp file
+ with file(stamp_file, 'a'):
+ os.utime(stamp_file, None)
+
+ return ret
+
+def usage():
+ print(__doc__);
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))