Link java api into shared library by specifying features

This commit is contained in:
Jeremy Lakeman 2018-04-03 16:25:22 +09:30
parent d844b0f6bd
commit 4809d7d585
7 changed files with 26 additions and 18 deletions

View File

@ -53,10 +53,10 @@ SERVAL_DAEMON_OBJS = \
ifeq (@HAVE_JNI_H@,yes)
SERVAL_DAEMON_JNI_OBJS = \
$(addprefix $(OBJSDIR_SERVALD)/, $(SERVAL_DAEMON_JNI_SOURCES:.c=.o))
SERVAL_DAEMON_JNI_OBJS = $(OBJSDIR_SERVALD)/servald_jni_features.o
SERVAL_DAEMON_OBJS += $(SERVAL_DAEMON_JNI_OBJS)
SERVAL_DAEMON_OBJS += \
$(addprefix $(OBJSDIR_SERVALD)/, $(SERVAL_DAEMON_JNI_SOURCES:.c=.o))
endif
@ -366,7 +366,6 @@ libservaldaemon.a: _servald.a $(LIBSODIUM_A)
libservaldaemon.so: \
$(OBJSDIR_SERVALD)/servald_features.o \
$(OBJSDIR_SERVALD)/log_output_console.o \
$(OBJSDIR_SERVALD)/log_output_file.o \
$(SERVAL_DAEMON_JNI_OBJS) \
_servald.a \
$(LIBSODIUM_A)
@ -379,7 +378,6 @@ libservaldaemon.so: \
# to be pulled into the link.
servald: $(OBJSDIR_SERVALD)/servald_features.o \
$(OBJSDIR_SERVALD)/log_output_console.o \
$(OBJSDIR_SERVALD)/log_output_file.o \
libservaldaemon.a
@echo LINK $@
@$(CC) -Wall -o $@ $^ $(LDFLAGS)
@ -393,7 +391,6 @@ ifneq ($(SWIFTC),) # Only provide Swift targets if the Swift compiler is availab
# package.
servaldswift: $(srcdir)/servaldswift.swift \
$(OBJSDIR_SERVALD)/servald_features.o \
$(OBJSDIR_SERVALD)/log_output_file.o \
libservaldaemon.a \
$(SWIFT_MODULE_NAME).swiftmodule \
libServalDNA.a
@ -410,7 +407,6 @@ servaldwrap: $(OBJSDIR_SERVALD)/servalwrap.o
@$(CC) -Wall -o $@ $^ $(LDFLAGS)
serval-tests: $(OBJSDIR_SERVALD)/test_features.o \
$(OBJSDIR_SERVALD)/log_output_console.o \
libservaldaemon.a
@echo LINK $@
@$(CC) -Wall -o $@ $^ $(LDFLAGS)

View File

@ -27,6 +27,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "strbuf_helpers.h"
#include "conf.h"
#include "debug.h"
#include "instance.h"
#include "feature.h"
DEFINE_FEATURE(jni_commandline);
static struct cli_vtable cli_vtable_jni;
@ -194,6 +198,15 @@ static int initJniTypes(JNIEnv *env)
return 0;
}
JNIEXPORT jint JNICALL Java_org_servalproject_servaldna_ServalDCommand_setInstancePath(
JNIEnv *env, jobject UNUSED(this), jobject path)
{
const char *cpath = (*env)->GetStringUTFChars(env, path, NULL);
set_instance_path(cpath);
(*env)->ReleaseStringUTFChars(env, path, cpath);
return (jint)0;
}
/* JNI entry point to command line. See org.servalproject.servald.ServalD class for the Java side.
JNI method descriptor: "(Ljava/util/List;[Ljava/lang/String;)I"
*/

View File

@ -26,6 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "conf.h"
#include "instance.h"
#include "httpd.h"
#include "feature.h"
DEFINE_FEATURE(jni_server);
static JNIEnv *server_env=NULL;
static jclass IJniServer= NULL;

View File

@ -52,6 +52,7 @@ void servald_features()
USE_FEATURE(dna_helper);
USE_FEATURE(directory_client);
USE_FEATURE(log_output_file);
USE_FEATURE(http_server);
USE_FEATURE(http_rhizome);

View File

@ -1,5 +1,5 @@
/*
Serval DNA JNI instance directory path
Serval DNA daemon features
Copyright (C) 2016 Flinders University
This program is free software; you can redistribute it and/or
@ -17,15 +17,10 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <assert.h>
#include "jni_common.h"
#include "instance.h"
#include "feature.h"
JNIEXPORT jint JNICALL Java_org_servalproject_servaldna_ServalDCommand_setInstancePath(
JNIEnv *env, jobject UNUSED(this), jobject path)
void servald_jni_features()
{
const char *cpath = (*env)->GetStringUTFChars(env, path, NULL);
set_instance_path(cpath);
(*env)->ReleaseStringUTFChars(env, path, cpath);
return (jint)0;
USE_FEATURE(jni_commandline);
USE_FEATURE(jni_server);
}

View File

@ -130,7 +130,6 @@ SERVAL_DAEMON_SOURCES = \
SERVAL_DAEMON_JNI_SOURCES = \
jni_common.c \
jni_commandline.c \
jni_instance.c \
jni_server.c
SERVAL_DAEMON_SWIFT_SOURCES = \

View File

@ -26,6 +26,7 @@ void test_features()
USE_FEATURE(cli_log);
USE_FEATURE(cli_vomp_console);
USE_FEATURE(cli_tests);
USE_FEATURE(log_output_console);
}
void command_cleanup() {}