jvpp: use Python's logging API
Change-Id: Iec437e4672af1f0d1a24458afb977ba6fbeba4ed Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
This commit is contained in:
Marek Gradzki
committed by
Damjan Marion
parent
2f8d8fa501
commit
568cc60b70
@ -68,7 +68,7 @@ JAR_FILES += jvpp-registry-$(PACKAGE_VERSION).jar
|
||||
jvpp_registry_ok = jvpp-registry/io_fd_vpp_jvpp_VppJNIConnection.h
|
||||
|
||||
jvpp-registry/io_fd_vpp_jvpp_VppJNIConnection.h: $(jvpp_registry_src_files)
|
||||
@echo " JAPIGEN $@"
|
||||
@echo " JVPP GEN $@"
|
||||
@rm -rf jvpp-registry/target
|
||||
@mkdir -p jvpp-registry/target
|
||||
@$(JAVAC) -d jvpp-registry/target $^
|
||||
@ -77,7 +77,7 @@ jvpp-registry/io_fd_vpp_jvpp_VppJNIConnection.h: $(jvpp_registry_src_files)
|
||||
@touch jvpp-registry.ok
|
||||
|
||||
define japigen
|
||||
@echo " JAPIGEN $@"
|
||||
@echo " JVPP GEN $@"
|
||||
@rm -rf jvpp-$(1)/target
|
||||
@ @srcdir@/jvpp/gen/jvpp_gen.py --plugin_name $(1) --root_dir jvpp-$(1) \
|
||||
-i $(jvpp_$(1)_json_files)
|
||||
|
@ -18,6 +18,7 @@ import argparse
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
|
||||
from jvppgen import types_gen
|
||||
from jvppgen import callback_gen
|
||||
@ -48,17 +49,33 @@ args = parser.parse_args()
|
||||
sys.path.append(".")
|
||||
cwd = os.getcwd()
|
||||
|
||||
print "Generating Java API for %s" % args.inputfiles
|
||||
print "inputfiles %s" % args.inputfiles
|
||||
# Initialize logger
|
||||
try:
|
||||
verbose = int(os.getenv("V", 0))
|
||||
except:
|
||||
verbose = 0
|
||||
|
||||
log_level = logging.WARNING
|
||||
if verbose == 1:
|
||||
log_level = logging.INFO
|
||||
elif verbose >= 2:
|
||||
log_level = logging.DEBUG
|
||||
|
||||
logging.basicConfig(stream=sys.stdout, level=log_level)
|
||||
logger = logging.getLogger("JVPP GEN")
|
||||
logger.setLevel(log_level)
|
||||
|
||||
|
||||
logger.info("Generating Java API for %s" % args.inputfiles)
|
||||
plugin_name = args.plugin_name
|
||||
print "plugin_name %s" % plugin_name
|
||||
logger.debug("plugin_name: %s" % plugin_name)
|
||||
|
||||
cfg = {}
|
||||
|
||||
base_package = 'io.fd.vpp.jvpp'
|
||||
plugin_package = base_package + '.' + plugin_name
|
||||
root_dir = os.path.abspath(args.root_dir)
|
||||
print "root_dir %s" % root_dir
|
||||
logger.debug("root_dir: %s" % root_dir)
|
||||
work_dir = root_dir + "/target/" + plugin_package.replace(".","/")
|
||||
|
||||
try:
|
||||
@ -168,16 +185,23 @@ callback_facade_package = 'callfacade'
|
||||
|
||||
types_list, types_name = get_definitions(cfg['types'])
|
||||
|
||||
types_gen.generate_types(types_list, plugin_package, types_package, args.inputfiles)
|
||||
types_gen.generate_types(types_list, plugin_package, types_package, args.inputfiles, logger)
|
||||
|
||||
func_list, func_name = get_definitions(cfg['messages'])
|
||||
|
||||
dto_gen.generate_dtos(func_list, base_package, plugin_package, plugin_name.title(), dto_package, args.inputfiles)
|
||||
jvpp_impl_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name, dto_package, args.inputfiles)
|
||||
callback_gen.generate_callbacks(func_list, base_package, plugin_package, plugin_name.title(), callback_package, dto_package, args.inputfiles)
|
||||
notification_gen.generate_notification_registry(func_list, base_package, plugin_package, plugin_name.title(), notification_package, callback_package, dto_package, args.inputfiles)
|
||||
jvpp_c_gen.generate_jvpp(func_list, plugin_name, args.inputfiles, root_dir)
|
||||
jvpp_future_facade_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name.title(), dto_package, callback_package, notification_package, future_package, args.inputfiles)
|
||||
jvpp_callback_facade_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name.title(), dto_package, callback_package, notification_package, callback_facade_package, args.inputfiles)
|
||||
dto_gen.generate_dtos(func_list, base_package, plugin_package, plugin_name.title(), dto_package, args.inputfiles,
|
||||
logger)
|
||||
jvpp_impl_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name, dto_package, args.inputfiles, logger)
|
||||
callback_gen.generate_callbacks(func_list, base_package, plugin_package, plugin_name.title(), callback_package,
|
||||
dto_package, args.inputfiles, logger)
|
||||
notification_gen.generate_notification_registry(func_list, base_package, plugin_package, plugin_name.title(),
|
||||
notification_package, callback_package, dto_package, args.inputfiles,
|
||||
logger)
|
||||
jvpp_c_gen.generate_jvpp(func_list, plugin_name, args.inputfiles, root_dir, logger)
|
||||
jvpp_future_facade_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name.title(), dto_package,
|
||||
callback_package, notification_package, future_package, args.inputfiles, logger)
|
||||
jvpp_callback_facade_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name.title(), dto_package,
|
||||
callback_package, notification_package, callback_facade_package, args.inputfiles,
|
||||
logger)
|
||||
|
||||
print "Java API for %s generated successfully" % args.inputfiles
|
||||
logger.info("Java API for %s generated successfully" % args.inputfiles)
|
||||
|
@ -49,9 +49,10 @@ public interface JVpp${plugin_name}GlobalCallback extends $base_package.$callbac
|
||||
""")
|
||||
|
||||
|
||||
def generate_callbacks(func_list, base_package, plugin_package, plugin_name, callback_package, dto_package, inputfile):
|
||||
def generate_callbacks(func_list, base_package, plugin_package, plugin_name, callback_package, dto_package, inputfile,
|
||||
logger):
|
||||
""" Generates callback interfaces """
|
||||
print "Generating Callback interfaces"
|
||||
logger.debug("Generating Callback interfaces for %s" % inputfile)
|
||||
|
||||
if not os.path.exists(callback_package):
|
||||
os.mkdir(callback_package)
|
||||
|
@ -60,9 +60,9 @@ send_template = Template(""" @Override
|
||||
}""")
|
||||
|
||||
|
||||
def generate_dtos(func_list, base_package, plugin_package, plugin_name, dto_package, inputfile):
|
||||
def generate_dtos(func_list, base_package, plugin_package, plugin_name, dto_package, inputfile, logger):
|
||||
""" Generates dto objects in a dedicated package """
|
||||
print "Generating DTOs"
|
||||
logger.debug("Generating DTOs for %s" % inputfile)
|
||||
|
||||
if not os.path.exists(dto_package):
|
||||
os.mkdir(dto_package)
|
||||
|
@ -366,9 +366,9 @@ $handler_registration
|
||||
""")
|
||||
|
||||
|
||||
def generate_jvpp(func_list, plugin_name, inputfile, path):
|
||||
def generate_jvpp(func_list, plugin_name, inputfile, path, logger):
|
||||
""" Generates jvpp C file """
|
||||
print "Generating jvpp C"
|
||||
logger.debug("Generating jvpp C for %s" % inputfile)
|
||||
|
||||
class_cache = generate_class_cache(func_list, plugin_name)
|
||||
jni_impl = generate_jni_impl(func_list, plugin_name, inputfile)
|
||||
|
@ -98,9 +98,10 @@ no_arg_method_impl_template = Template(""" public final void $name($plugin_pa
|
||||
""")
|
||||
|
||||
|
||||
def generate_jvpp(func_list, base_package, plugin_package, plugin_name, dto_package, callback_package, notification_package, callback_facade_package, inputfile):
|
||||
def generate_jvpp(func_list, base_package, plugin_package, plugin_name, dto_package, callback_package,
|
||||
notification_package, callback_facade_package, inputfile, logger):
|
||||
""" Generates callback facade """
|
||||
print "Generating JVpp callback facade"
|
||||
logger.debug("Generating JVpp callback facade for %s" % inputfile)
|
||||
|
||||
if os.path.exists(callback_facade_package):
|
||||
util.remove_folder(callback_facade_package)
|
||||
|
@ -156,9 +156,10 @@ jvpp_facade_details_callback_method_template = Template("""
|
||||
""")
|
||||
|
||||
|
||||
def generate_jvpp(func_list, base_package, plugin_package, plugin_name, dto_package, callback_package, notification_package, future_facade_package, inputfile):
|
||||
def generate_jvpp(func_list, base_package, plugin_package, plugin_name, dto_package, callback_package,
|
||||
notification_package, future_facade_package, inputfile, logger):
|
||||
""" Generates JVpp interface and JNI implementation """
|
||||
print "Generating JVpp future facade"
|
||||
logger.debug("Generating JVpp future facade for %s" % inputfile)
|
||||
|
||||
if not os.path.exists(future_facade_package):
|
||||
os.mkdir(future_facade_package)
|
||||
|
@ -165,9 +165,9 @@ no_arg_method_impl_template = Template(""" public final int $name() throws io
|
||||
""")
|
||||
|
||||
|
||||
def generate_jvpp(func_list, base_package, plugin_package, plugin_name_underscore, dto_package, inputfile):
|
||||
def generate_jvpp(func_list, base_package, plugin_package, plugin_name_underscore, dto_package, inputfile, logger):
|
||||
""" Generates JVpp interface and JNI implementation """
|
||||
print "Generating JVpp"
|
||||
logger.debug("Generating JVpp interface implementation for %s" % inputfile)
|
||||
plugin_name = util.underscore_to_camelcase_upper(plugin_name_underscore)
|
||||
|
||||
methods = []
|
||||
|
@ -123,9 +123,10 @@ public interface ${plugin_name}EventRegistryProvider extends $base_package.$noti
|
||||
""")
|
||||
|
||||
|
||||
def generate_notification_registry(func_list, base_package, plugin_package, plugin_name, notification_package, callback_package, dto_package, inputfile):
|
||||
def generate_notification_registry(func_list, base_package, plugin_package, plugin_name, notification_package,
|
||||
callback_package, dto_package, inputfile, logger):
|
||||
""" Generates notification registry interface and implementation """
|
||||
print "Generating Notification interfaces and implementation"
|
||||
logger.debug("Generating Notification interfaces and implementation for %s" % inputfile)
|
||||
|
||||
if not os.path.exists(notification_package):
|
||||
os.mkdir(notification_package)
|
||||
|
@ -142,17 +142,16 @@ def generate_type_setter(handler_name, type_def, c_name_prefix, object_name, ind
|
||||
return indent + type_initialization.replace('\n', '\n' + indent)
|
||||
|
||||
|
||||
def generate_types(types_list, plugin_package, types_package, inputfile):
|
||||
def generate_types(types_list, plugin_package, types_package, inputfile, logger):
|
||||
"""
|
||||
Generates Java representation of custom types defined in api file.
|
||||
"""
|
||||
|
||||
#
|
||||
if not types_list:
|
||||
print "Skipping custom types generation (%s does not define custom types)." % inputfile
|
||||
logger.debug("Skipping custom types generation (%s does not define custom types)." % inputfile)
|
||||
return
|
||||
|
||||
print "Generating custom types"
|
||||
logger.debug("Generating custom types for %s" % inputfile)
|
||||
|
||||
if not os.path.exists(types_package):
|
||||
os.mkdir(types_package)
|
||||
|
Reference in New Issue
Block a user