Skip to content

Commit

Permalink
Add missing .o files to libiotivity-lite-jni.so
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 authored Jul 9, 2024
1 parent 4a9fad5 commit 122d8f5
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
- args: ""
# debug on, json encoder on
- args: "DEBUG=1 JSON_ENCODER=1"
# secure off
- args: "SECURE=0"
# secure off, pki off
- args: "SECURE=0 PKI=0"
# TODO: reenable when dynamic allocation is fixed
# dynamic allocation off
# - args: "DYNAMIC=0"
Expand Down
6 changes: 3 additions & 3 deletions port/android/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ WARNING_FLAGS=-Wall -Wextra -Werror -Wno-error=deprecated-declarations -pedantic
CFLAGS_CLOUD=-I../../api/cloud -DOC_CLIENT -DOC_SERVER
CFLAGS?=-fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-strict-overflow -I./ -I../../include/ -I../../deps/tinycbor/src -I../../ -std=gnu99 $(WARNING_FLAGS) -DLONG_BIT=64 -D__ANDROID_MIN_SDK_VERSION__=${ANDROID_API}
OBJ_COMMON=$(addprefix ${OBJDIR}/,$(notdir $(SRC_COMMON:.c=.o)))
OBJ_PORT_COMMON=$(addprefix obj/port/,$(notdir $(SRC_PORT_COMMON:.c=.o)))
OBJ_PORT_COMMON=$(addprefix ${OBJDIR}/port/,$(notdir $(SRC_PORT_COMMON:.c=.o)))
OBJ_CLIENT=$(addprefix ${OBJDIR}/client/,$(notdir $(SRC:.c=.o) $(SRC_CLIENT:.c=.o)))
OBJ_SERVER=$(addprefix ${OBJDIR}/server/,$(filter-out oc_obt.o oc_obt_otm_justworks.o oc_obt_otm_randompin.o oc_obt_otm_cert.o oc_obt_certs.o,$(notdir $(SRC:.c=.o))))
ifeq ($(CLOUD),1)
Expand Down Expand Up @@ -326,11 +326,11 @@ ${OBJDIR}/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS}

obj/port/%.o: ../../port/common/%.c
${OBJDIR}/port/%.o: ../../port/common/%.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS}

obj/port/%.o: ../../port/common/posix/%.c
${OBJDIR}/port/%.o: ../../port/common/posix/%.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS}

Expand Down
23 changes: 14 additions & 9 deletions port/android/ipadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#if __ANDROID_API__ >= 24
#include <ifaddrs.h>
#define OC_GETIFADDRS getifaddrs
#define OC_FREEIFADDRS freeifaddrs
#else
#include "ifaddrs-android.h"
#define OC_GETIFADDRS android_getifaddrs
#define OC_FREEIFADDRS android_freeifaddrs
#endif /* __ANDROID_API__ >= 24 */
#include <linux/ipv6.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
Expand All @@ -73,6 +64,20 @@
#include <sys/un.h>
#include <unistd.h>

#include <android/api-level.h>
#if !defined(__ANDROID_API__) || __ANDROID_API__ == 10000
#error __ANDROID_API__ not defined
#endif
#if __ANDROID_API__ >= 24
#include <ifaddrs.h>
#define OC_GETIFADDRS getifaddrs
#define OC_FREEIFADDRS freeifaddrs
#else
#include "ifaddrs-android.h"
#define OC_GETIFADDRS android_getifaddrs
#define OC_FREEIFADDRS android_freeifaddrs
#endif /* __ANDROID_API__ >= 24 */

#if __ANDROID_API__ < 30
#define OC_NETLINK_IF_CHANGE_NOTIFICATIONS_AVAILABLE
#endif /* __ANDROID_API__ < 30 */
Expand Down
13 changes: 10 additions & 3 deletions swig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ LDFLAG += -lm

INSTALL_ANDROID_LIBS =

SECURE ?= 1
PKI ?= 1

ifeq ($(DEBUG),1)
EXTRA_FLAG += -DOC_LOG_MAXIMUM_LEVEL=8 -g -O0
endif
Expand All @@ -88,6 +91,9 @@ ifeq ($(IDD), 1)
endif

ifneq ($(PKI),0)
ifeq ($(SECURE),0)
$(error PKI is enabled, but security is disabled)
endif
EXTRA_FLAG += -DOC_PKI
SWIG_CFLAG += -DOC_PKI
endif
Expand Down Expand Up @@ -131,14 +137,14 @@ ifeq ($(OS),linux)
SWIG_CFLAG += -D__linux__
EXTRA_FLAG += -fno-strict-aliasing
HEADER_FILE += -I../port/linux
LDFLAG += -lpthread -lrt
LDFLAG += -lpthread -lrt -Wl,--no-undefined
endif
ifeq ($(OS),android)
EXTRA_HEADER_FILE = -I"$(ANDROID_BASE)/sysroot/usr/include/"
PORT_OBJ_DIR = ../port/android/${ANDROID_HOST}obj/
SWIG_CFLAG += -D__linux__
HEADER_FILE += -I../port/android
LDFLAG += -llog
LDFLAG += -llog -Wl,--no-undefined
INSTALL_ANDROID_LIBS = install_android_libs
ifeq ($(ANDROID_API),)
EXTRA_FLAG += -D__ANDROID_MIN_SDK_VERSION__=23
Expand All @@ -147,6 +153,7 @@ else
endif
endif

PORT_COMMON_OBJ_DIR = $(PORT_OBJ_DIR)port/
JAVA_LANG_OBJ_DIR += $(PORT_OBJ_DIR)swig/

all: clean build_swig build_jar build_jni_so $(INSTALL_ANDROID_LIBS)
Expand Down Expand Up @@ -177,7 +184,7 @@ build_jar: copy_java
$(JAR) -cfv $(IOTIVITY_LITE_JAVA_LIBS_DIR)$(JAR_NAME) -C $(IOTIVITY_LITE_JAVA_BIN_DIR) .

build_jni_so: $(JNI_SRC)
$(CC) -shared $(JAVA_LANG_OBJ_DIR)*.o $(PORT_OBJ_DIR)*.o $(CLIENT_SERVER_OBJ_DIR)*.o $(CLOUD_OBJ_DIR) $(LDFLAG) -o $(IOTIVITY_LITE_JAVA_LIBS_DIR)$(JNI_SO_NAME)
$(CC) -shared $(JAVA_LANG_OBJ_DIR)*.o $(PORT_COMMON_OBJ_DIR)*.o $(PORT_OBJ_DIR)*.o $(CLIENT_SERVER_OBJ_DIR)*.o $(CLOUD_OBJ_DIR) $(LDFLAG) -o $(IOTIVITY_LITE_JAVA_LIBS_DIR)$(JNI_SO_NAME)

install_android_libs: build_swig build_jar build_jni_so
# copy so and jar files to samples
Expand Down
2 changes: 1 addition & 1 deletion swig/swig_interfaces/iotivity.swg
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
%typemap(javain) oc_sp_types_t "$javainput"
%typemap(javaout) oc_sp_types_t { return $jnicall; }

%typemap(in) oc_cloud_status_t "$1 = (oc_sp_types_t)$input;"
%typemap(in) oc_cloud_status_t "$1 = (oc_cloud_status_t)$input;"
%typemap(out) oc_cloud_status_t "$result = (jint)$1;"
%typemap(jni) oc_cloud_status_t "jint";
%typemap(jtype) oc_cloud_status_t "int";
Expand Down
16 changes: 16 additions & 0 deletions swig/swig_interfaces/oc_api.i
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ void jni_set_random_pin_callback(oc_random_pin_cb_t cb, jni_callback_data *jcb)
*/
public";
%rename(setConResAnnounced) oc_set_con_res_announced;

%ignore oc_reset;
%rename(reset) jni_reset;
%inline %{
Expand All @@ -539,6 +540,19 @@ void jni_reset(void) {
}
%}

%ignore oc_reset_v1;
%rename(resetV1) jni_reset_v1;
%inline %{
void jni_reset_v1(bool force) {
OC_DBG("JNI: %s\n", __func__);
#ifdef OC_SECURITY
oc_reset_v1(force);
#else /* !OC_SECURITY */
(void)force;
#endif /* OC_SECURITY */
}
%}

%ignore oc_reset_device;
%rename(resetDevice) jni_reset_device;
%inline %{
Expand Down Expand Up @@ -996,6 +1010,8 @@ SWIGEXPORT jobject JNICALL Java_org_iotivity_OCMainJNI_getQueryValues(JNIEnv *je
%ignore oc_get_response_payload_raw;
%ignore oc_send_diagnostic_message;
%ignore oc_get_diagnostic_message;
%ignore oc_reset_device_v1;
%ignore oc_is_owned_device;

// client side
%{
Expand Down
16 changes: 16 additions & 0 deletions swig/swig_interfaces/oc_core_res.i
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,21 @@
%rename (filterResourceByRt) oc_filter_resource_by_rt;
%rename (isDCR) oc_core_is_DCR;

%ignore oc_core_is_SVR;
%rename(isSVR) jni_core_is_SVR;
%inline %{
bool jni_core_is_SVR(const oc_resource_t *resource, size_t device)
{
OC_DBG("JNI: %s\n", __func__);
#if defined(OC_SECURITY)
return oc_core_is_SVR(resource, device);
#else
(void)resource;
(void)device;
return false;
#endif /* OC_SECURITY */
}
%}

#define OC_NONNULL(...)
%include "oc_core_res.h"
13 changes: 11 additions & 2 deletions swig/swig_interfaces/oc_cred.i
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ typedef struct role role;
#ifdef OC_PKI
return &(self->publicdata);
#else
(void)self;
return NULL;
#endif /* OC_PKI */
}
Expand All @@ -68,6 +69,7 @@ typedef struct role role;
#ifdef OC_PKI
return self->credusage;
#else
(void)self;
return OC_CREDUSAGE_NULL;
#endif /* OC_PKI */
}
Expand All @@ -76,15 +78,17 @@ typedef struct role role;
#ifdef OC_PKI
return self->chain;
#else
(void)self;
return NULL;
#endif /* OC_PKI */
}

struct oc_sec_cred_t *getChild() {
#ifdef OC_PKI
return self->child;
return self->child;
#else
return NULL;
(void)self;
return NULL;
#endif /* OC_PKI */
}
}
Expand Down Expand Up @@ -184,6 +188,11 @@ const char *jni_cred_credtype_string(oc_sec_credtype_t credType)
}
%}

%ignore oc_sec_get_creds;
%ignore oc_sec_remove_cred;
%ignore oc_sec_get_cred_by_credid;
%ignore oc_sec_remove_cred_by_credid;

// TODO: implement oc_cred_verify_certificate_chain
%ignore oc_sec_certs_data_t;
%ignore oc_verify_sec_certs_data_fn_t;
Expand Down
5 changes: 4 additions & 1 deletion swig/swig_interfaces/oc_obt.i
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
%nodefaultctor oc_sec_ace_t;
%nodefaultdtor oc_sec_ace_t;

// TODO: implement oc_sec_acl_clear, oc_sec_remove_ace, oc_sec_get_ace_by_aceid, oc_sec_remove_ace_by_aceid, oc_sec_acl_add_bootstrap_acl
// TODO: implement oc_sec_get_acl, oc_sec_acl_clear, oc_sec_remove_ace, oc_sec_get_ace_by_aceid, oc_sec_remove_ace_by_aceid, oc_sec_acl_add_bootstrap_acl
%ignore oc_sec_get_acl;
%ignore oc_sec_ace_filter_t;
%ignore oc_sec_acl_clear;
%ignore oc_sec_remove_ace;
Expand Down Expand Up @@ -113,6 +114,8 @@ void jni_resource_set_access_in_RFOTM(oc_resource_t *resource, bool state,

/*******************End oc_acl.h*****************/

%ignore oc_obt_set_sd_info;

%ignore oc_obt_init;
%rename(init) jni_obt_init;
%inline %{
Expand Down
1 change: 1 addition & 0 deletions swig/swig_interfaces/oc_pki.i
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

%{
#include "oc_pki.h"
#include "oc_sp.h"
#include "port/oc_log_internal.h"
%}

Expand Down

0 comments on commit 122d8f5

Please sign in to comment.