From e2505d1d9e2e49554057a8cd5fb71b0ac0e3ba63 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Sun, 6 Dec 2015 17:03:08 -0800 Subject: Use separate project for native libraries --- examples/demo/build.sbt | 16 -------- examples/demo/native/CMakeLists.txt | 45 ---------------------- examples/demo/native/main.c | 16 -------- .../demo/native/org_example_jni_demo_Library__.h | 21 ---------- examples/demo/project/plugins.sbt | 1 - .../main/scala/org/example/jni/demo/Library.scala | 8 ---- .../src/main/scala/org/example/jni/demo/Main.scala | 12 ------ 7 files changed, 119 deletions(-) delete mode 100644 examples/demo/build.sbt delete mode 100644 examples/demo/native/CMakeLists.txt delete mode 100644 examples/demo/native/main.c delete mode 100644 examples/demo/native/org_example_jni_demo_Library__.h delete mode 100644 examples/demo/project/plugins.sbt delete mode 100644 examples/demo/src/main/scala/org/example/jni/demo/Library.scala delete mode 100644 examples/demo/src/main/scala/org/example/jni/demo/Main.scala (limited to 'examples/demo') diff --git a/examples/demo/build.sbt b/examples/demo/build.sbt deleted file mode 100644 index 8cd1419..0000000 --- a/examples/demo/build.sbt +++ /dev/null @@ -1,16 +0,0 @@ -enablePlugins(JniPlugin) - -name := "jni-demo" - -organization := "org.example" - -baseDirectory in jni := (baseDirectory in ThisBuild).value / "native" - -javahObjects in javah += "org.example.jni.demo.Library" - -libraryDependencies += "ch.jodersky" %% "jni-library" % "0.1-SNAPSHOT" - -//exportJars in run := true - -//librearDependencies += "org.example" %% "demo" % "0.1" -//librearDependencies += "org.example" % "demo" % "0.1" % "runtime" classifier "native" diff --git a/examples/demo/native/CMakeLists.txt b/examples/demo/native/CMakeLists.txt deleted file mode 100644 index 059a0dd..0000000 --- a/examples/demo/native/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -# Define project and related variables -# -project (demo) - -# Set versions and library name -# Note: major version will be appended to library name -# -set (VERSION_MAJOR 1) -set (VERSION_MINOR 2) -set (VERSION_PATCH 3) -set (LIB_NAME demo${VERSION_MAJOR}) - -# Command-line options -# -# required by sbt-jni to install binaries to correct places -set (LIB_INSTALL_DIR lib CACHE PATH "Path in which to install libraries (Autoconf equivalent to --libdir).") -# required by sbt-jni to disable versioned libraries -set (ENABLE_VERSIONED_LIB ON CACHE BOOLEAN "Generate versioned library files and symlinks.") - -# Setup JNI -find_package(JNI REQUIRED) -if (JNI_FOUND) - message (STATUS "JNI include directories: ${JNI_INCLUDE_DIRS}") -endif() - -# Include directories -include_directories(.) -include_directories(${JNI_INCLUDE_DIRS}) - -# Setup main shared library -# Note: major version is appended to library name -add_library(${LIB_NAME} SHARED main.c) -if (ENABLE_VERSIONED_LIB) - set_target_properties( - ${LIB_NAME} - PROPERTIES - VERSION 0.${VERSION_MINOR}.${VERSION_PATCH} # major version always 0, it is included in name - SOVERSION 0 - ) -endif() - -# Installation targets -install(TARGETS ${LIB_NAME} LIBRARY DESTINATION ${LIB_INSTALL_DIR}) diff --git a/examples/demo/native/main.c b/examples/demo/native/main.c deleted file mode 100644 index 5916c48..0000000 --- a/examples/demo/native/main.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include "org_example_jni_demo_Library__.h" - -/* - * Class: org_example_jni_demo_Library__ - * Method: print - * Signature: (Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_example_jni_demo_Library_00024_print -(JNIEnv *env, jobject clazz, jstring message) { - const char* msg = (*env)->GetStringUTFChars(env, message, 0); - fprintf(stdout, "Printing from native library: %s", msg); - fflush(stdout); - (*env)->ReleaseStringUTFChars(env, message, msg); - return 0; -} diff --git a/examples/demo/native/org_example_jni_demo_Library__.h b/examples/demo/native/org_example_jni_demo_Library__.h deleted file mode 100644 index 06a7fa4..0000000 --- a/examples/demo/native/org_example_jni_demo_Library__.h +++ /dev/null @@ -1,21 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_example_jni_demo_Library__ */ - -#ifndef _Included_org_example_jni_demo_Library__ -#define _Included_org_example_jni_demo_Library__ -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_example_jni_demo_Library__ - * Method: print - * Signature: (Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_example_jni_demo_Library_00024_print - (JNIEnv *, jobject, jstring); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/examples/demo/project/plugins.sbt b/examples/demo/project/plugins.sbt deleted file mode 100644 index ab5617e..0000000 --- a/examples/demo/project/plugins.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("ch.jodersky" % "sbt-jni" % "0.1-SNAPSHOT") diff --git a/examples/demo/src/main/scala/org/example/jni/demo/Library.scala b/examples/demo/src/main/scala/org/example/jni/demo/Library.scala deleted file mode 100644 index c157b5d..0000000 --- a/examples/demo/src/main/scala/org/example/jni/demo/Library.scala +++ /dev/null @@ -1,8 +0,0 @@ -package org.example.jni.demo - -/** A demo object, mapping to a native library. */ -object Library { - - @native def print(message: String): Int - -} diff --git a/examples/demo/src/main/scala/org/example/jni/demo/Main.scala b/examples/demo/src/main/scala/org/example/jni/demo/Main.scala deleted file mode 100644 index 7306104..0000000 --- a/examples/demo/src/main/scala/org/example/jni/demo/Main.scala +++ /dev/null @@ -1,12 +0,0 @@ -package org.example.jni.demo - -import ch.jodersky.jni.NativeLoader - -object Main { - - def main(args: Array[String]): Unit = { - NativeLoader.load("demo1", "/org/example/jni/demo") - Library.print("Hello world!") - } - -} -- cgit v1.2.3