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

Side by Side Diff: build/protoc_java.py

Issue 11146005: Add support for generating jars from protos and add cacheinvalidation_java. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated crbug link to use http:// Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/protoc_java.gypi ('k') | third_party/cacheinvalidation/cacheinvalidation.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Generate java source files from protobufs
7
8 Usage:
9 protoc_java.py {protoc} {proto_path} {java_out} {stamp_file} {proto_files}
10
11 This is a helper file for the genproto_java action in protoc_java.gypi.
12
13 It performs the following steps:
14 1. Deletes all old sources (ensures deleted classes are not part of new jars).
15 2. Creates source directory.
16 3. Generates Java files using protoc.
17 4. Creates a new stamp file.
18 """
19
20 import os
21 import shutil
22 import subprocess
23 import sys
24
25 def main(argv):
26 if len(argv) < 5:
27 usage()
28 return 1
29
30 protoc_path = argv[1]
Isaac (away) 2012/10/31 21:32:48 nit: lines 30-33 can be shortened to: protoc_path
nyquist 2012/10/31 23:14:20 Done.
31 proto_path = argv[2]
32 java_out = argv[3]
33 stamp_file = argv[4]
34 proto_files = argv[5:]
35
36 # Delete all old sources
37 if os.path.exists(java_out):
38 shutil.rmtree(java_out)
39
40 # Create source directory
41 os.makedirs(java_out)
42
43 # Generate Java files using protoc
44 protoc_command = [protoc_path,
Isaac (away) 2012/10/31 21:32:48 nit: you could inline this: subprocess.call( [p
nyquist 2012/10/31 23:14:20 Done.
45 '--proto_path', proto_path,
46 '--java_out', java_out]
47 protoc_command.extend(proto_files)
48 ret = subprocess.call(protoc_command)
49 if ret != 0:
50 return ret
51
52 # Create a new stamp file
53 with file(stamp_file, 'a'):
Isaac (away) 2012/10/31 21:32:48 nit, you could always return ret (delete lines 49/
nyquist 2012/10/31 23:14:20 Done.
54 os.utime(stamp_file, None)
55
56 return 0
57
58 def usage():
59 print(__doc__);
60
61 if __name__ == '__main__':
62 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/protoc_java.gypi ('k') | third_party/cacheinvalidation/cacheinvalidation.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698