Patchwork [3/3] jni-library.bbclass: Add helper class for jni libraries

login
register
mail settings
Submitter Stefan Schmidt
Date Jan. 12, 2011, 9:13 a.m.
Message ID <1294823599-2669-3-git-send-email-stefan@buglabs.net>
Download mbox | patch
Permalink /patch/253/
State Accepted
Headers show

Comments

Stefan Schmidt - Jan. 12, 2011, 9:13 a.m.
Signed-off-by: Stefan Schmidt <stefan@buglabs.net>
---
 classes/jni-library.bbclass |   54 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)
 create mode 100644 classes/jni-library.bbclass

Patch

diff --git a/classes/jni-library.bbclass b/classes/jni-library.bbclass
new file mode 100644
index 0000000..fefbace
--- /dev/null
+++ b/classes/jni-library.bbclass
@@ -0,0 +1,54 @@ 
+# we need javah
+DEPENDS += "openjdk-langtools-native zip-native"
+
+JNI_LIB_DIR = "/usr/lib/jni"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+EXTRA_OEMAKE +=" \
+	JAVAH_OUT=${D}${JNI_LIB_DIR} \
+	LIB_DIR=${D}${JNI_LIB_DIR} \
+	JAVAH_CLASSPATH=${S}/build --debug \
+	COMMON_CLASSPATH=${STAGING_LIBDIR}/com.buglabs.bug.jni.common.jar \
+	STAGING_BUG_INCDIR=${STAGING_INCDIR}/bug \
+	BUG_LINUX_SRC=${STAGING_KERNEL_DIR} \
+	STAGING_INCDIR=${STAGING_INCDIR} \
+	CLASSPATH_INCDIR=${STAGING_INCDIR}/classpath \
+	ROOTFS_BUG=${STAGING_LIBDIR}/../../ \
+"
+
+addtask jni_compile after do_compile before do_install
+do_jni_compile() {
+        cd ${S}/src/c
+        oe_runmake jni
+}
+
+addtask jni_install after do_install before do_package
+do_jni_install() {
+  install -d ${D}${JNI_LIB_DIR}
+  cd ${S}/src/c
+  oe_runmake libs
+}
+
+addtask jni_update_jar after do_jni_install before do_package
+do_jni_update_jar(){
+  cd ${S}/src/c/
+  install -d lib/
+  cp *.so lib/
+  zip -u ${D}${datadir_java}/${JARFILENAME} lib/*.so
+}
+
+addtask jni_staging after do_jni_install before do_package
+do_jni_staging() {
+  if test -e ${S}/src/c/*.so; then
+	install -d ${STAGING_LIBDIR}/bug
+	cp -r ${S}/src/c/*.so ${STAGING_LIBDIR}/bug
+	cp -r ${S}/src/c/*.so ${STAGING_LIBDIR}/
+  fi
+
+  if test -e ${S}/src/c/include/*.h; then
+	  install -d ${STAGING_INCDIR}/bug
+	  cp -r ${S}/src/c/include/*.h ${STAGING_INCDIR}/bug
+	  cp -r ${S}/src/c/include/*.h ${STAGING_INCDIR}/
+  fi
+}