From 047c75ff2d2f51e00b0c1b81b2f36d5f0bb74dfe Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Tue, 1 Nov 2022 08:19:53 +0100 Subject: [PATCH] Move JNI from Argeo Commons to Argeo SLC --- Makefile | 20 +--- Makefile-rcp.mk | 9 -- jni/.cproject | 68 -------------- jni/.project | 26 ------ jni/.settings/language.settings.xml | 11 --- jni/.settings/org.eclipse.cdt.core.prefs | 6 -- jni/Makefile | 14 --- jni/jni.mk | 58 ------------ jni/org_argeo_api_uuid_libuuid/.gitignore | 1 - jni/org_argeo_api_uuid_libuuid/Makefile | 8 -- ...eo_api_uuid_libuuid_DirectLibuuidFactory.c | 8 -- ...eo_api_uuid_libuuid_DirectLibuuidFactory.h | 21 ----- ...rg_argeo_api_uuid_libuuid_LibuuidFactory.c | 91 ------------------- ...rg_argeo_api_uuid_libuuid_LibuuidFactory.h | 45 --------- 14 files changed, 1 insertion(+), 385 deletions(-) delete mode 100644 jni/.cproject delete mode 100644 jni/.project delete mode 100644 jni/.settings/language.settings.xml delete mode 100644 jni/.settings/org.eclipse.cdt.core.prefs delete mode 100644 jni/Makefile delete mode 100644 jni/jni.mk delete mode 100644 jni/org_argeo_api_uuid_libuuid/.gitignore delete mode 100644 jni/org_argeo_api_uuid_libuuid/Makefile delete mode 100644 jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_DirectLibuuidFactory.c delete mode 100644 jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_DirectLibuuidFactory.h delete mode 100644 jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_LibuuidFactory.c delete mode 100644 jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_LibuuidFactory.h diff --git a/Makefile b/Makefile index 6d947e312..a19375940 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ include sdk.mk -.PHONY: clean all osgi jni +.PHONY: clean all osgi all: osgi $(MAKE) -f Makefile-rcp.mk all @@ -45,28 +45,10 @@ org.argeo.api.uuid \ org.argeo.api.acr \ org.argeo.api.cms -jni: - $(MAKE) -C jni - clean: rm -rf $(BUILD_BASE) - $(MAKE) -C jni clean $(MAKE) -f Makefile-rcp.mk clean A2_BUNDLES_CLASSPATH = $(subst $(space),$(pathsep),$(strip $(A2_BUNDLES))) -native-image: - mkdir -p $(A2_OUTPUT)/libexec/$(A2_CATEGORY) -# cd $(A2_OUTPUT)/libexec/$(A2_CATEGORY) && /opt/graalvm-ce/bin/native-image \ - -cp $(A2_CLASSPATH):$(A2_BUNDLES_CLASSPATH) org.argeo.eclipse.ui.jetty.CmsRapCli \ - --enable-url-protocols=http,https \ - -H:AdditionalSecurityProviders=sun.security.jgss.SunProvider,org.bouncycastle.jce.provider.BouncyCastleProvider,net.i2p.crypto.eddsa.EdDSASecurityProvider \ - --initialize-at-build-time=org.argeo.init.logging.ThinLogging,org.slf4j.LoggerFactory \ - --no-fallback - cd $(A2_OUTPUT)/libexec/$(A2_CATEGORY) && /opt/graalvm-ce/bin/native-image \ - -cp $(A2_CLASSPATH):$(A2_BUNDLES_CLASSPATH) org.argeo.cms.ux.cli.FileSync \ - --initialize-at-build-time=org.argeo.init.logging.ThinLogging,org.slf4j.LoggerFactory \ - --no-fallback - - include $(SDK_SRC_BASE)/sdk/argeo-build/osgi.mk \ No newline at end of file diff --git a/Makefile-rcp.mk b/Makefile-rcp.mk index 562f8b61b..02967a2b9 100644 --- a/Makefile-rcp.mk +++ b/Makefile-rcp.mk @@ -3,12 +3,6 @@ include sdk.mk all: osgi -move-rcp: osgi - mkdir -p $(A2_OUTPUT)/swt/rcp/$(A2_CATEGORY) - mv -v $(A2_OUTPUT)/$(A2_CATEGORY)/*.rcp.$(MAJOR).$(MINOR).jar $(A2_OUTPUT)/swt/rcp/$(A2_CATEGORY) - mv -v $(A2_OUTPUT)/$(A2_CATEGORY)/*.rcp.cli.$(MAJOR).$(MINOR).jar $(A2_OUTPUT)/swt/rcp/$(A2_CATEGORY) - #touch $(BUILD_BASE)/*.rcp/bnd.bnd - A2_CATEGORY = org.argeo.cms BUNDLES = \ @@ -16,9 +10,6 @@ swt/rcp/org.argeo.swt.specific.rcp \ swt/rcp/org.argeo.cms.swt.rcp \ swt/rcp/org.argeo.cms.e4.rcp \ -A2_OUTPUT = $(SDK_BUILD_BASE)/a2 -A2_BASE = $(A2_OUTPUT) - DEP_CATEGORIES = \ org.argeo.cms \ swt/org.argeo.cms \ diff --git a/jni/.cproject b/jni/.cproject deleted file mode 100644 index 259cf27db..000000000 --- a/jni/.cproject +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - - ide - true - true - true - - - - \ No newline at end of file diff --git a/jni/.project b/jni/.project deleted file mode 100644 index 492a807be..000000000 --- a/jni/.project +++ /dev/null @@ -1,26 +0,0 @@ - - - jni-commons - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/jni/.settings/language.settings.xml b/jni/.settings/language.settings.xml deleted file mode 100644 index e30ee1672..000000000 --- a/jni/.settings/language.settings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/jni/.settings/org.eclipse.cdt.core.prefs b/jni/.settings/org.eclipse.cdt.core.prefs deleted file mode 100644 index c8ec5df2d..000000000 --- a/jni/.settings/org.eclipse.cdt.core.prefs +++ /dev/null @@ -1,6 +0,0 @@ -doxygen/doxygen_new_line_after_brief=true -doxygen/doxygen_use_brief_tag=false -doxygen/doxygen_use_javadoc_tags=true -doxygen/doxygen_use_pre_tag=false -doxygen/doxygen_use_structural_commands=false -eclipse.preferences.version=1 diff --git a/jni/Makefile b/jni/Makefile deleted file mode 100644 index de2b84c19..000000000 --- a/jni/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -include ../sdk.mk - -JNIDIRS = org_argeo_api_uuid_libuuid - -.PHONY: clean all - -all: - $(foreach dir, $(JNIDIRS), $(MAKE) -C $(dir);) - -clean: - rm -rf $(BUILD_DIR) $(SDK_BUILD_BASE)/jni - - - diff --git a/jni/jni.mk b/jni/jni.mk deleted file mode 100644 index 40dde4469..000000000 --- a/jni/jni.mk +++ /dev/null @@ -1,58 +0,0 @@ -TARGET_EXEC := libJava_$(NATIVE_PACKAGE).so - -LDFLAGS = -shared -fPIC -Wl,-soname,$(TARGET_EXEC).$(MAJOR).$(MINOR) $(ADDITIONAL_LIBS) -CFLAGS = -O3 -fPIC - -SRC_DIRS := . - -# -# Generic Argeo -# -BUILD_DIR := $(SDK_BUILD_BASE)/jni/$(NATIVE_PACKAGE) - -# Every folder in ./src will need to be passed to GCC so that it can find header files -INC_DIRS := $(shell find $(SRC_DIRS) -type d) $(JAVA_HOME)/include $(JAVA_HOME)/include/linux $(ADDITIONAL_INCLUDES) - - -.PHONY: clean all ide -all: $(SDK_BUILD_BASE)/jni/$(TARGET_EXEC) - -# Find all the C and C++ files we want to compile -# Note the single quotes around the * expressions. Make will incorrectly expand these otherwise. -SRCS := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c' -or -name '*.s') - -# String substitution for every C/C++ file. -# As an example, hello.cpp turns into ./build/hello.cpp.o -OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) - -# String substitution (suffix version without %). -# As an example, ./build/hello.cpp.o turns into ./build/hello.cpp.d -DEPS := $(OBJS:.o=.d) - -# Add a prefix to INC_DIRS. So moduleA would become -ImoduleA. GCC understands this -I flag -INC_FLAGS := $(addprefix -I,$(INC_DIRS)) - -# The -MMD and -MP flags together generate Makefiles for us! -# These files will have .d instead of .o as the output. -CPPFLAGS := $(INC_FLAGS) -MMD -MP - -# The final build step. -$(SDK_BUILD_BASE)/jni/$(TARGET_EXEC): $(OBJS) - $(CC) $(OBJS) -o $@ $(LDFLAGS) - -# Build step for C source -$(BUILD_DIR)/%.c.o: %.c - mkdir -p $(dir $@) - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ - -# Build step for C++ source -$(BUILD_DIR)/%.cpp.o: %.cpp - mkdir -p $(dir $@) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@ - -# Include the .d makefiles. The - at the front suppresses the errors of missing -# Makefiles. Initially, all the .d files will be missing, and we don't want those -# errors to show up. --include $(DEPS) - -# MAKEFILE_DIR := $(dir $(firstword $(MAKEFILE_LIST))) diff --git a/jni/org_argeo_api_uuid_libuuid/.gitignore b/jni/org_argeo_api_uuid_libuuid/.gitignore deleted file mode 100644 index 84c048a73..000000000 --- a/jni/org_argeo_api_uuid_libuuid/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build/ diff --git a/jni/org_argeo_api_uuid_libuuid/Makefile b/jni/org_argeo_api_uuid_libuuid/Makefile deleted file mode 100644 index cfeb1db55..000000000 --- a/jni/org_argeo_api_uuid_libuuid/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -NATIVE_PACKAGE := org_argeo_api_uuid_libuuid - -ADDITIONAL_INCLUDES = /usr/include/uuid -ADDITIONAL_LIBS = -luuid - -include ../../sdk.mk -include ../jni.mk - diff --git a/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_DirectLibuuidFactory.c b/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_DirectLibuuidFactory.c deleted file mode 100644 index a5aeed009..000000000 --- a/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_DirectLibuuidFactory.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include -#include "org_argeo_api_uuid_libuuid_DirectLibuuidFactory.h" - -JNIEXPORT void JNICALL Java_org_argeo_api_uuid_libuuid_DirectLibuuidFactory_timeUUID( - JNIEnv *env, jobject uuidFactory, jobject uuidBuf) { - uuid_generate_time((*env)->GetDirectBufferAddress(env, uuidBuf)); -} diff --git a/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_DirectLibuuidFactory.h b/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_DirectLibuuidFactory.h deleted file mode 100644 index 5f18bf7f1..000000000 --- a/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_DirectLibuuidFactory.h +++ /dev/null @@ -1,21 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_argeo_api_uuid_libuuid_DirectLibuuidFactory */ - -#ifndef _Included_org_argeo_api_uuid_libuuid_DirectLibuuidFactory -#define _Included_org_argeo_api_uuid_libuuid_DirectLibuuidFactory -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_argeo_api_uuid_libuuid_DirectLibuuidFactory - * Method: timeUUID - * Signature: (Ljava/nio/ByteBuffer;)V - */ -JNIEXPORT void JNICALL Java_org_argeo_api_uuid_libuuid_DirectLibuuidFactory_timeUUID - (JNIEnv *, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_LibuuidFactory.c b/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_LibuuidFactory.c deleted file mode 100644 index f97b1f452..000000000 --- a/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_LibuuidFactory.c +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include -#include "org_argeo_api_uuid_libuuid_LibuuidFactory.h" - -/* - * UTILITIES - */ - -static inline jobject fromBytes(JNIEnv *env, uuid_t out) { - jlong msb = 0; - jlong lsb = 0; - - for (int i = 0; i < 8; i++) - msb = (msb << 8) | (out[i] & 0xff); - for (int i = 8; i < 16; i++) - lsb = (lsb << 8) | (out[i] & 0xff); - - jclass uuidClass = (*env)->FindClass(env, "java/util/UUID"); - jmethodID uuidConstructor = (*env)->GetMethodID(env, uuidClass, "", - "(JJ)V"); - - jobject jUUID = (*env)->AllocObject(env, uuidClass); - (*env)->CallVoidMethod(env, jUUID, uuidConstructor, msb, lsb); - - return jUUID; -} - -static inline void toBytes(JNIEnv *env, jobject jUUID, uuid_t result) { - - jclass uuidClass = (*env)->FindClass(env, "java/util/UUID"); - jmethodID getMostSignificantBits = (*env)->GetMethodID(env, uuidClass, - "getMostSignificantBits", "()J"); - jmethodID getLeastSignificantBits = (*env)->GetMethodID(env, uuidClass, - "getLeastSignificantBits", "()J"); - - jlong msb = (*env)->CallLongMethod(env, jUUID, getMostSignificantBits); - jlong lsb = (*env)->CallLongMethod(env, jUUID, getLeastSignificantBits); - - for (int i = 0; i < 8; i++) - result[i] = (unsigned char) ((msb >> ((7 - i) * 8)) & 0xff); - for (int i = 8; i < 16; i++) - result[i] = (unsigned char) ((lsb >> ((15 - i) * 8)) & 0xff); -} - -/* - * JNI IMPLEMENTATION - */ - -JNIEXPORT jobject JNICALL Java_org_argeo_api_uuid_libuuid_LibuuidFactory_timeUUID( - JNIEnv *env, jobject uuidFactory) { - uuid_t out; - - uuid_generate_time(out); - return fromBytes(env, out); -} - -JNIEXPORT jobject JNICALL Java_org_argeo_api_uuid_libuuid_LibuuidFactory_nameUUIDv5( - JNIEnv *env, jobject uuidFactory, jobject namespaceUuid, - jbyteArray name) { - uuid_t ns; - uuid_t out; - - toBytes(env, namespaceUuid, ns); - jsize length = (*env)->GetArrayLength(env, name); - jbyte *bytes = (*env)->GetByteArrayElements(env, name, 0); - - uuid_generate_sha1(out, ns, bytes, length); - return fromBytes(env, out); -} - -JNIEXPORT jobject JNICALL Java_org_argeo_api_uuid_libuuid_LibuuidFactory_nameUUIDv3( - JNIEnv *env, jobject uuidFactory, jobject namespaceUuid, - jbyteArray name) { - uuid_t ns; - uuid_t out; - - toBytes(env, namespaceUuid, ns); - jsize length = (*env)->GetArrayLength(env, name); - jbyte *bytes = (*env)->GetByteArrayElements(env, name, 0); - - uuid_generate_md5(out, ns, bytes, length); - return fromBytes(env, out); -} - -JNIEXPORT jobject JNICALL Java_org_argeo_api_uuid_libuuid_LibuuidFactory_randomUUIDStrong( - JNIEnv *env, jobject uuidFactory) { - uuid_t out; - - uuid_generate_random(out); - return fromBytes(env, out); -} diff --git a/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_LibuuidFactory.h b/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_LibuuidFactory.h deleted file mode 100644 index ad0ac5e76..000000000 --- a/jni/org_argeo_api_uuid_libuuid/org_argeo_api_uuid_libuuid_LibuuidFactory.h +++ /dev/null @@ -1,45 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_argeo_api_uuid_libuuid_LibuuidFactory */ - -#ifndef _Included_org_argeo_api_uuid_libuuid_LibuuidFactory -#define _Included_org_argeo_api_uuid_libuuid_LibuuidFactory -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_argeo_api_uuid_libuuid_LibuuidFactory - * Method: timeUUID - * Signature: ()Ljava/util/UUID; - */ -JNIEXPORT jobject JNICALL Java_org_argeo_api_uuid_libuuid_LibuuidFactory_timeUUID - (JNIEnv *, jobject); - -/* - * Class: org_argeo_api_uuid_libuuid_LibuuidFactory - * Method: nameUUIDv5 - * Signature: (Ljava/util/UUID;[B)Ljava/util/UUID; - */ -JNIEXPORT jobject JNICALL Java_org_argeo_api_uuid_libuuid_LibuuidFactory_nameUUIDv5 - (JNIEnv *, jobject, jobject, jbyteArray); - -/* - * Class: org_argeo_api_uuid_libuuid_LibuuidFactory - * Method: nameUUIDv3 - * Signature: (Ljava/util/UUID;[B)Ljava/util/UUID; - */ -JNIEXPORT jobject JNICALL Java_org_argeo_api_uuid_libuuid_LibuuidFactory_nameUUIDv3 - (JNIEnv *, jobject, jobject, jbyteArray); - -/* - * Class: org_argeo_api_uuid_libuuid_LibuuidFactory - * Method: randomUUIDStrong - * Signature: ()Ljava/util/UUID; - */ -JNIEXPORT jobject JNICALL Java_org_argeo_api_uuid_libuuid_LibuuidFactory_randomUUIDStrong - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -- 2.30.2