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 $^
@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)
import sys
import os
import json
+import logging
from jvppgen import types_gen
from jvppgen import callback_gen
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:
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)
-
-print "Java API for %s generated successfully" % 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)
+
+logger.info("Java API for %s generated successfully" % args.inputfiles)
""")
-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)
}""")
-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)
""")
-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)
""")
-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)
""")
-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)
""")
-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 = []
""")
-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)
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)