diff options
author | Jakob Odersky <jodersky@gmail.com> | 2015-12-06 17:03:08 -0800 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2015-12-06 17:09:40 -0800 |
commit | e2505d1d9e2e49554057a8cd5fb71b0ac0e3ba63 (patch) | |
tree | f4fec79ba707aa9b2dec903d54a164f357961f19 /examples/demo | |
parent | 3e90312b3f2d912bf27e91b454a6ef21a81a2fc5 (diff) | |
download | sbt-jni-e2505d1d9e2e49554057a8cd5fb71b0ac0e3ba63.tar.gz sbt-jni-e2505d1d9e2e49554057a8cd5fb71b0ac0e3ba63.tar.bz2 sbt-jni-e2505d1d9e2e49554057a8cd5fb71b0ac0e3ba63.zip |
Use separate project for native libraries
Diffstat (limited to 'examples/demo')
-rw-r--r-- | examples/demo/build.sbt | 16 | ||||
-rw-r--r-- | examples/demo/native/CMakeLists.txt | 45 | ||||
-rw-r--r-- | examples/demo/native/main.c | 16 | ||||
-rw-r--r-- | examples/demo/native/org_example_jni_demo_Library__.h | 21 | ||||
-rw-r--r-- | examples/demo/project/plugins.sbt | 1 | ||||
-rw-r--r-- | examples/demo/src/main/scala/org/example/jni/demo/Library.scala | 8 | ||||
-rw-r--r-- | examples/demo/src/main/scala/org/example/jni/demo/Main.scala | 12 |
7 files changed, 0 insertions, 119 deletions
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 <stdio.h> -#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 <jni.h> -/* 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!") - } - -} |