Create python package for jvpp generation.
Change-Id: I2254f90b2c3e423563bb91bf70877979f1e86a6b
Signed-off-by: Ed Warnicke <eaw@cisco.com>
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
diff --git a/vpp-api/java/jvpp/gen/jvpp_gen.py b/vpp-api/java/jvpp/gen/jvpp_gen.py
index 26bcea1..6f531de 100755
--- a/vpp-api/java/jvpp/gen/jvpp_gen.py
+++ b/vpp-api/java/jvpp/gen/jvpp_gen.py
@@ -17,15 +17,16 @@
import argparse
import importlib
import sys
+import os
-import callback_gen
-import notification_gen
-import dto_gen
-import jvpp_callback_facade_gen
-import jvpp_future_facade_gen
-import jvpp_impl_gen
-import jvpp_c_gen
-import util
+from jvppgen import callback_gen
+from jvppgen import notification_gen
+from jvppgen import dto_gen
+from jvppgen import jvpp_callback_facade_gen
+from jvppgen import jvpp_future_facade_gen
+from jvppgen import jvpp_impl_gen
+from jvppgen import jvpp_c_gen
+from jvppgen import util
# Invocation:
# ~/Projects/vpp/vpp-api/jvpp/gen$ mkdir -p java/org/openvpp/jvpp && cd java/org/openvpp/jvpp
@@ -36,15 +37,23 @@
#
# where
# defs_api_vpp_papi.py - vpe.api in python format (generated by vppapigen)
-from util import vpp_2_jni_type_mapping
+from jvppgen.util import vpp_2_jni_type_mapping
parser = argparse.ArgumentParser(description='VPP Java API generator')
parser.add_argument('-i', action="store", dest="inputfile")
+parser.add_argument('--base_package', action="store", dest="base_package", default='org.openvpp.jvpp')
args = parser.parse_args()
sys.path.append(".")
-inputfile = args.inputfile.replace('.py', '')
+print "args.inputfile %s" % args.inputfile
+importdir = os.path.dirname(args.inputfile)
+print "importdir %s" % importdir
+inputfile = os.path.basename(args.inputfile)
+inputfile = inputfile.replace('.py', '')
+print "inputfile %s" % inputfile
+base_package = args.base_package
+sys.path.append(importdir)
cfg = importlib.import_module(inputfile, package=None)
@@ -124,7 +133,6 @@
func_list, func_name = get_definitions()
-base_package = 'org.openvpp.jvpp'
dto_package = 'dto'
callback_package = 'callback'
notification_package = 'notification'
diff --git a/vpp-api/java/jvpp/gen/jvppgen/__init__.py b/vpp-api/java/jvpp/gen/jvppgen/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vpp-api/java/jvpp/gen/jvppgen/__init__.py
diff --git a/vpp-api/java/jvpp/gen/callback_gen.py b/vpp-api/java/jvpp/gen/jvppgen/callback_gen.py
similarity index 100%
rename from vpp-api/java/jvpp/gen/callback_gen.py
rename to vpp-api/java/jvpp/gen/jvppgen/callback_gen.py
diff --git a/vpp-api/java/jvpp/gen/dto_gen.py b/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
similarity index 100%
rename from vpp-api/java/jvpp/gen/dto_gen.py
rename to vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
diff --git a/vpp-api/java/jvpp/gen/jvpp_c_gen.py b/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py
similarity index 100%
rename from vpp-api/java/jvpp/gen/jvpp_c_gen.py
rename to vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py
diff --git a/vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py b/vpp-api/java/jvpp/gen/jvppgen/jvpp_callback_facade_gen.py
similarity index 100%
rename from vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py
rename to vpp-api/java/jvpp/gen/jvppgen/jvpp_callback_facade_gen.py
diff --git a/vpp-api/java/jvpp/gen/jvpp_future_facade_gen.py b/vpp-api/java/jvpp/gen/jvppgen/jvpp_future_facade_gen.py
similarity index 100%
rename from vpp-api/java/jvpp/gen/jvpp_future_facade_gen.py
rename to vpp-api/java/jvpp/gen/jvppgen/jvpp_future_facade_gen.py
diff --git a/vpp-api/java/jvpp/gen/jvpp_impl_gen.py b/vpp-api/java/jvpp/gen/jvppgen/jvpp_impl_gen.py
similarity index 100%
rename from vpp-api/java/jvpp/gen/jvpp_impl_gen.py
rename to vpp-api/java/jvpp/gen/jvppgen/jvpp_impl_gen.py
diff --git a/vpp-api/java/jvpp/gen/notification_gen.py b/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py
similarity index 84%
rename from vpp-api/java/jvpp/gen/notification_gen.py
rename to vpp-api/java/jvpp/gen/jvppgen/notification_gen.py
index 4ca3c07..df6407f 100644
--- a/vpp-api/java/jvpp/gen/notification_gen.py
+++ b/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py
@@ -135,30 +135,30 @@
dto_package=dto_package,
notification=notification_dto,
callback=callback_ifc))
+ if(callbacks):
+ callback_file = open(os.path.join(notification_package, "NotificationRegistry.java"), 'w')
+ callback_file.write(notification_registry_template.substitute(inputfile=inputfile,
+ register_callback_methods="\n ".join(register_callback_methods),
+ base_package=base_package,
+ notification_package=notification_package))
+ callback_file.flush()
+ callback_file.close()
- callback_file = open(os.path.join(notification_package, "NotificationRegistry.java"), 'w')
- callback_file.write(notification_registry_template.substitute(inputfile=inputfile,
- register_callback_methods="\n ".join(register_callback_methods),
- base_package=base_package,
- notification_package=notification_package))
- callback_file.flush()
- callback_file.close()
+ callback_file = open(os.path.join(notification_package, "GlobalNotificationCallback.java"), 'w')
+ callback_file.write(global_notification_callback_template.substitute(inputfile=inputfile,
+ callbacks=", ".join(callbacks),
+ base_package=base_package,
+ notification_package=notification_package))
+ callback_file.flush()
+ callback_file.close()
- callback_file = open(os.path.join(notification_package, "GlobalNotificationCallback.java"), 'w')
- callback_file.write(global_notification_callback_template.substitute(inputfile=inputfile,
- callbacks=", ".join(callbacks),
+ callback_file = open(os.path.join(notification_package, "NotificationRegistryImpl.java"), 'w')
+ callback_file.write(notification_registry_impl_template.substitute(inputfile=inputfile,
+ callback_package=callback_package,
+ dto_package=dto_package,
+ register_callback_methods="".join(register_callback_methods_impl),
+ handler_methods="".join(handler_methods),
base_package=base_package,
notification_package=notification_package))
- callback_file.flush()
- callback_file.close()
-
- callback_file = open(os.path.join(notification_package, "NotificationRegistryImpl.java"), 'w')
- callback_file.write(notification_registry_impl_template.substitute(inputfile=inputfile,
- callback_package=callback_package,
- dto_package=dto_package,
- register_callback_methods="".join(register_callback_methods_impl),
- handler_methods="".join(handler_methods),
- base_package=base_package,
- notification_package=notification_package))
- callback_file.flush()
- callback_file.close()
+ callback_file.flush()
+ callback_file.close()
diff --git a/vpp-api/java/jvpp/gen/util.py b/vpp-api/java/jvpp/gen/jvppgen/util.py
similarity index 100%
rename from vpp-api/java/jvpp/gen/util.py
rename to vpp-api/java/jvpp/gen/jvppgen/util.py