2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-25 03:09:30 +01:00
waf/playground/protoc/wscript
Federico Pellegrin a02b71a163 protoc: add java support for protobuffers (#2049)
* protoc: added java support

Modified protoc to support also .proto -> .java generation. the .java file
name generated is not obvious as in C++/Python but follows a couple of rules
that were implemented.

As cxx/python and javaw Tools are quite different the implementation is not
as clean as for cxx/python but is hopefully fine (ie. protoc still uses
sources for input files while javac uses src_dir).

In javaw a small detail was added: a new attribute was added (gencode) that
instructs javac to look for source files also in the build directory. This
are realistically generated code (and .proto -> .java is an example) and
are therefore in the build. Default is false keeping all the previous
behaviour.

* protoc for java enhanchments (protoc version, regex, docs)

In configure stage get protoc version as java naming changes depending on the
version. Implement the version differences between version < 2 and > 2

Improve regex for option catching and implement a mix of them in playground
to verify it.

Add some documentation on how java filenames and paths are generated.

* protoc: build dir with generated code is automatically added, so no need to explicitly use gencode in javac
2017-09-26 19:17:40 +02:00

42 lines
1.0 KiB
Python

#! /usr/bin/env python
top = '.'
out = 'build'
def options(opt):
opt.load('compiler_cxx python java')
def configure(conf):
conf.load('compiler_cxx python java protoc')
conf.check_python_version(minver=(2, 5, 0))
# Here you have to point to your protobuf-java JAR
conf.env.CLASSPATH_PROTOBUF = ['/tmp/cp/protobuf-java-2.5.0.jar']
def build(bld):
bld(
features = 'cxx cxxshlib',
source = ['inc/message_inc.proto','inc/message.proto'],
target = 'somelib',
includes = ['inc'])
bld(
features = 'py',
name = 'pbpy',
source = ['inc/message_inc.proto','inc/message.proto'],
protoc_includes = ['inc'])
bld(
features = 'cxx py',
name = 'pbboth',
source = ['incboth/messageboth_inc.proto', 'incboth/messageboth.proto'],
protoc_includes = ['incboth']) # either protoc_includes or includes would work in this case
bld(
features = 'javac protoc',
name = 'pbjava',
srcdir = 'inc/',
source = ['inc/message_inc.proto', 'inc/message.proto'],
use = 'PROTOBUF',
protoc_includes = ['inc'])