forked from cory/tildefriends
Make a JNI call.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4200 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
28d73f5b37
commit
f736756b20
16
Makefile
16
Makefile
@ -29,6 +29,7 @@ ANDROID_NDK_TARGET_TRIPLE := aarch64-linux-android
|
|||||||
|
|
||||||
debug windebug androiddebug: CFLAGS += -Og
|
debug windebug androiddebug: CFLAGS += -Og
|
||||||
debug release androidrelease: LDFLAGS += -rdynamic
|
debug release androidrelease: LDFLAGS += -rdynamic
|
||||||
|
androiddebug androidrelease: CFLAGS += --sysroot $(ANDROID_SDK)/ndk-bundle/sysroot -fPIC
|
||||||
release winrelease: CFLAGS += -DNDEBUG -O3
|
release winrelease: CFLAGS += -DNDEBUG -O3
|
||||||
windebug winrelease: CC = x86_64-w64-mingw32-gcc-win32
|
windebug winrelease: CC = x86_64-w64-mingw32-gcc-win32
|
||||||
windebug winrelease: AS = $(CC)
|
windebug winrelease: AS = $(CC)
|
||||||
@ -321,7 +322,9 @@ windebug winrelease: LDFLAGS += \
|
|||||||
androiddebug androidrelease: LDFLAGS += \
|
androiddebug androidrelease: LDFLAGS += \
|
||||||
-ldl \
|
-ldl \
|
||||||
-lssl \
|
-lssl \
|
||||||
-lcrypto
|
-lcrypto \
|
||||||
|
-shared \
|
||||||
|
-fPIC
|
||||||
|
|
||||||
unix: debug release
|
unix: debug release
|
||||||
win: windebug winrelease
|
win: windebug winrelease
|
||||||
@ -343,10 +346,10 @@ DEPS = $(ALL_APP_OBJS:.o=.d)
|
|||||||
-include $(DEPS)
|
-include $(DEPS)
|
||||||
|
|
||||||
define build_rules
|
define build_rules
|
||||||
$(1): $(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe)
|
$(1): $(BUILD_DIR)/$(1)/$(if $(filter android%,$(1)),lib)$(PROJECT)$(if $(filter win%,$(1)),.exe)$(if $(filter android%,$(1)),.so)
|
||||||
.PHONY: $(1)
|
.PHONY: $(1)
|
||||||
|
|
||||||
$(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe): $(filter $(BUILD_DIR)/$(1)/%,$(ALL_APP_OBJS))
|
$(BUILD_DIR)/$(1)/$(if $(filter android%,$(1)),lib)$(PROJECT)$(if $(filter win%,$(1)),.exe)$(if $(filter android%,$(1)),.so): $(filter $(BUILD_DIR)/$(1)/%,$(ALL_APP_OBJS))
|
||||||
@echo [link] $$@
|
@echo [link] $$@
|
||||||
@$$(CC) -o $$@ $$^ $$(LDFLAGS)
|
@$$(CC) -o $$@ $$^ $$(LDFLAGS)
|
||||||
|
|
||||||
@ -381,9 +384,12 @@ out/apk/classes.dex: $(CLASS_FILES)
|
|||||||
@echo [dx] $@
|
@echo [dx] $@
|
||||||
@$(ANDROID_BUILD_TOOLS)/dx --dex --output=$@ out/classes/
|
@$(ANDROID_BUILD_TOOLS)/dx --dex --output=$@ out/classes/
|
||||||
|
|
||||||
out/TildeFriends.unsigned.apk: out/apk/classes.dex
|
out/TildeFriends.unsigned.apk: out/apk/classes.dex androiddebug
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@) out/apk/lib/arm64-v8a/
|
||||||
@echo [aapt] $@
|
@echo [aapt] $@
|
||||||
|
@cp out/androiddebug/libtildefriends.so out/apk/lib/arm64-v8a/
|
||||||
|
@cp deps/openssl/android/arm64-v8a/usr/local/lib/libssl.so out/apk/lib/arm64-v8a/
|
||||||
|
@cp deps/openssl/android/arm64-v8a/usr/local/lib/libcrypto.so out/apk/lib/arm64-v8a/
|
||||||
@$(ANDROID_BUILD_TOOLS)/aapt package -f -M src/android/AndroidManifest.xml -S src/android/res/ -I $(ANDROID_PLATFORM)/android.jar -F $@ out/apk/
|
@$(ANDROID_BUILD_TOOLS)/aapt package -f -M src/android/AndroidManifest.xml -S src/android/res/ -I $(ANDROID_PLATFORM)/android.jar -F $@ out/apk/
|
||||||
|
|
||||||
out/TildeFriends.apk: out/TildeFriends.unsigned.apk
|
out/TildeFriends.apk: out/TildeFriends.unsigned.apk
|
||||||
|
@ -10,6 +10,12 @@ public class MainActivity extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
TextView text = (TextView)findViewById(R.id.my_text);
|
TextView text = (TextView)findViewById(R.id.my_text);
|
||||||
text.setText("Hello, world!");
|
text.setText(getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public native String getMessage();
|
||||||
|
|
||||||
|
static {
|
||||||
|
System.loadLibrary("tildefriends");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
src/jnitest.c
Normal file
8
src/jnitest.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#if defined(__ANDROID__)
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL Java_com_unprompted_tildefriends_MainActivity_getMessage(JNIEnv* env, jobject obj)
|
||||||
|
{
|
||||||
|
return (*env)->NewStringUTF(env, "Hello!");
|
||||||
|
}
|
||||||
|
#endif
|
@ -69,7 +69,7 @@ static void _tf_ssb_rpc_blobs_get(tf_ssb_connection_t* connection, uint8_t flags
|
|||||||
}
|
}
|
||||||
uint8_t* blob = NULL;
|
uint8_t* blob = NULL;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
const int k_send_max = 8192;
|
const size_t k_send_max = 8192;
|
||||||
if (tf_ssb_db_blob_get(ssb, id, &blob, &size))
|
if (tf_ssb_db_blob_get(ssb, id, &blob, &size))
|
||||||
{
|
{
|
||||||
for (size_t offset = 0; offset < size; offset += k_send_max)
|
for (size_t offset = 0; offset < size; offset += k_send_max)
|
||||||
|
Loading…
Reference in New Issue
Block a user