From 1ae15db62628e61bd602e05792226836bcdbcf8f Mon Sep 17 00:00:00 2001 From: pavl_g Date: Sat, 21 Jan 2023 15:07:52 +0200 Subject: [PATCH] jme-alloc: refactored to jme native modular style --- {native-alloc => jme3-alloc-native}/build.gradle | 4 ++-- jme3-alloc-native/src/c/c.cpp | 7 +++++++ .../src}/include/com_jme3_alloc_BufferUtils.h | 0 .../src}/include/gradle-jni-template.h | 0 {jvm-alloc => jme3-alloc}/build.gradle | 2 +- .../src/main/java/com/jme3/alloc/BufferUtils.java | 0 .../src/test/java/temp/AppTest.java | 0 native-alloc/src/main/c/hello.cpp | 11 ----------- settings.gradle | 4 ++-- 9 files changed, 12 insertions(+), 16 deletions(-) rename {native-alloc => jme3-alloc-native}/build.gradle (84%) create mode 100644 jme3-alloc-native/src/c/c.cpp rename {native-alloc/src/main => jme3-alloc-native/src}/include/com_jme3_alloc_BufferUtils.h (100%) rename {native-alloc/src/main => jme3-alloc-native/src}/include/gradle-jni-template.h (100%) rename {jvm-alloc => jme3-alloc}/build.gradle (94%) rename {jvm-alloc => jme3-alloc}/src/main/java/com/jme3/alloc/BufferUtils.java (100%) rename {jvm-alloc => jme3-alloc}/src/test/java/temp/AppTest.java (100%) delete mode 100644 native-alloc/src/main/c/hello.cpp diff --git a/native-alloc/build.gradle b/jme3-alloc-native/build.gradle similarity index 84% rename from native-alloc/build.gradle rename to jme3-alloc-native/build.gradle index 57b2eba..8a91684 100644 --- a/native-alloc/build.gradle +++ b/jme3-alloc-native/build.gradle @@ -12,8 +12,8 @@ plugins { } final String version = "0.1-A" -final String buildDirectory="${project.rootDir}/jvm-alloc/build/classes/java/main/" -final String nativeObjects="${project.rootDir}/native-alloc/build/lib/main/debug/" +final String buildDirectory="${project.rootDir}/jme3-alloc/build/classes/java/main/" +final String nativeObjects="${project.rootDir}/jme3-alloc-native/build/lib/main/debug/" task copyNatives(type: Copy) { from "${nativeObjects}" diff --git a/jme3-alloc-native/src/c/c.cpp b/jme3-alloc-native/src/c/c.cpp new file mode 100644 index 0000000..8ab6d8c --- /dev/null +++ b/jme3-alloc-native/src/c/c.cpp @@ -0,0 +1,7 @@ +#include + +int main(int argc, char **argv) +{ + printf("give me a bottle of rum!\n"); + return 0; +} diff --git a/native-alloc/src/main/include/com_jme3_alloc_BufferUtils.h b/jme3-alloc-native/src/include/com_jme3_alloc_BufferUtils.h similarity index 100% rename from native-alloc/src/main/include/com_jme3_alloc_BufferUtils.h rename to jme3-alloc-native/src/include/com_jme3_alloc_BufferUtils.h diff --git a/native-alloc/src/main/include/gradle-jni-template.h b/jme3-alloc-native/src/include/gradle-jni-template.h similarity index 100% rename from native-alloc/src/main/include/gradle-jni-template.h rename to jme3-alloc-native/src/include/gradle-jni-template.h diff --git a/jvm-alloc/build.gradle b/jme3-alloc/build.gradle similarity index 94% rename from jvm-alloc/build.gradle rename to jme3-alloc/build.gradle index 40e72dd..876f049 100644 --- a/jvm-alloc/build.gradle +++ b/jme3-alloc/build.gradle @@ -21,7 +21,7 @@ tasks.named('test') { tasks.withType(JavaCompile) { // compile-time options [javac ] //options.compilerArgs << '-Xlint:deprecation' // to show deprecation warnings options.compilerArgs << '-Xlint:unchecked' - options.compilerArgs += ["-h", "${project.rootDir}/native-alloc/src/main/include"] + options.compilerArgs += ["-h", "${project.rootDir}/jme3-alloc-native/src/include/"] options.encoding = 'UTF-8' if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_1_10)) { options.release = 8 diff --git a/jvm-alloc/src/main/java/com/jme3/alloc/BufferUtils.java b/jme3-alloc/src/main/java/com/jme3/alloc/BufferUtils.java similarity index 100% rename from jvm-alloc/src/main/java/com/jme3/alloc/BufferUtils.java rename to jme3-alloc/src/main/java/com/jme3/alloc/BufferUtils.java diff --git a/jvm-alloc/src/test/java/temp/AppTest.java b/jme3-alloc/src/test/java/temp/AppTest.java similarity index 100% rename from jvm-alloc/src/test/java/temp/AppTest.java rename to jme3-alloc/src/test/java/temp/AppTest.java diff --git a/native-alloc/src/main/c/hello.cpp b/native-alloc/src/main/c/hello.cpp deleted file mode 100644 index c15e4a3..0000000 --- a/native-alloc/src/main/c/hello.cpp +++ /dev/null @@ -1,11 +0,0 @@ -/* - * This C++ source file was generated by the Gradle 'init' task. - */ - -#include -#include -#include "../include/gradle-jni-template.h" - -std::string gradle_jni_template::Greeter::greeting() { - return std::string("Hello, World!"); -} diff --git a/settings.gradle b/settings.gradle index 9bd4e31..35a8b7f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,5 +8,5 @@ */ rootProject.name = 'jme-alloc' -include('jvm-alloc') -include('native-alloc') +include('jme3-alloc') +include('jme3-alloc-native')