wscript (1491B)
1 #! /usr/bin/env python 2 # encoding: utf-8 3 # Federico Pellegrin, 2019 (fedepell) 4 5 import os 6 from waflib import Logs 7 8 top = '.' 9 out = 'build' 10 11 def options(opt): 12 opt.load('compiler_cxx java') 13 14 def configure(conf): 15 conf.load('compiler_cxx java protoc') 16 # Here you have to point to your protobuf-java JAR 17 conf.env.CLASSPATH_PROTOBUF = ['/usr/share/maven-repo/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar'] 18 19 def build(bld): 20 21 # this simulates a .proto generator. the gen.proto is generated in build 22 genp = bld( 23 rule = "cp ${SRC} ${TGT}", 24 source = "proto.source", 25 target = "inc/gen.proto" 26 ) 27 28 # cxx doesn't have a problem with this, just knows gen.proto will pop up later 29 bld( 30 features = 'cxx cxxshlib', 31 source = [ bld.path.find_or_declare(genp.target) ], 32 name = 'somelib', 33 target = 'somelib' 34 ) 35 36 # but for java: 37 38 # we either put grouping because of protoc java generations needs .proto to generate out fname (#2218) 39 # or accept that java dep is not strict on the .java file name (but relies just on explicit task ordering) 40 # bld.add_group() 41 42 # inc/gen.proto is an implicit dependency, but the file is generated at 43 # build time while protoc extra uses it before to determine the .java file 44 # name that will get generated 45 bld( 46 features = 'javac protoc', 47 name = 'pbjava', 48 srcdir = bld.path.find_or_declare(genp.target).parent, 49 source = [ bld.path.find_or_declare(genp.target) ], 50 use = 'PROTOBUF', 51 )