0
Files
src/build/protoc_java.py
nyquist cca2bcd58f Remove protobuf lite for java.
Since the introduction of nano protobufs for Java in
https://codereview.chromium.org/532303003 (and updated in
https://codereview.chromium.org/549543002), there is no need for the
lite protocol buffers anymore.

This CL removes the checked out files initially introduced when
protobuf lite support for Java was added in
https://chromiumcodereview.appspot.com/11347026 and cleans up the
infrastructure regarding generating protocol buffers.

Since lite is not supported anymore, this also removes the requirement
for setting the 'proto_runtime' variable for targets using
build/protoc_java.gypi.

BUG=377891
TBR=zea@chromium.org

Review URL: https://codereview.chromium.org/556933002

Cr-Commit-Position: refs/heads/master@{#294453}
2014-09-11 20:17:18 +00:00

61 lines
1.5 KiB
Python
Executable File

#!/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 protobuf files.
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)
# Specify arguments to the generator.
generator_args = ['optional_field_style=reftypes',
'store_unknown_fields=true']
out_arg = '--javanano_out=' + ','.join(generator_args) + ':' + java_out
# Generate Java files using protoc.
ret = subprocess.call(
[protoc_path, '--proto_path', proto_path, out_arg] + 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))