From 21c35f9da8b815c914a7886e3a126001cb3fa79b Mon Sep 17 00:00:00 2001 From: Jaeyun Date: Mon, 4 Nov 2019 19:12:10 +0900 Subject: [PATCH] [Android] prepare native libs for c-api update build script to provide native libraries using nnstreamer c-api. Signed-off-by: Jaeyun Jung --- api/android/README.md | 12 +++++++++-- .../api/src/main/jni/nnstreamer-native-api.c | 15 +++++++++++--- api/android/build-android-lib.sh | 24 +++++++++++++++++++++- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/api/android/README.md b/api/android/README.md index fa7498c..641f226 100644 --- a/api/android/README.md +++ b/api/android/README.md @@ -124,13 +124,21 @@ $ git clone https://github.com/nnsuite/nnstreamer.git #### Build Android API Run the build script in NNStreamer. -After building the Android API, you can find the library(.aar) in ```$NNSTREAMER_ROOT/android_lib```. + +- Build options + 1. target_abi: Specify the ABI (armv7, arm64) to be built for with `--target_abi={TARGET-ABI}`. + 2. api_option: Get the minimized library with GStreamer core elements `--api_option=lite`. + 3. run_unittest: Run the instrumentation test `--run_unittest=yes`. ```bash $ cd $NNSTREAMER_ROOT $ bash ./api/android/build-android-lib.sh ``` -Specify the ABI to be built for with `--target\_abi={TARGET-ABI}`. + +After building the Android API, you can find the library(.aar) in `$NNSTREAMER_ROOT/android_lib`. +- Build result + 1. nnstreamer.aar: NNStreamer library + 2. nnstreamer-native.zip: shared objects and header files for native developer #### Run the unit-test (Optional) diff --git a/api/android/api/src/main/jni/nnstreamer-native-api.c b/api/android/api/src/main/jni/nnstreamer-native-api.c index a600c03..0200844 100644 --- a/api/android/api/src/main/jni/nnstreamer-native-api.c +++ b/api/android/api/src/main/jni/nnstreamer-native-api.c @@ -477,11 +477,10 @@ nns_parse_tensors_info (pipeline_info_s * pipe_info, JNIEnv * env, } /** - * @brief Native method to initialize NNStreamer. + * @brief Initialize NNStreamer, register required plugins. */ jboolean -Java_org_nnsuite_nnstreamer_NNStreamer_nativeInitialize (JNIEnv * env, jclass clazz, - jobject context) +nnstreamer_native_initialize (void) { nns_logi ("Called native initialize."); @@ -507,6 +506,16 @@ Java_org_nnsuite_nnstreamer_NNStreamer_nativeInitialize (JNIEnv * env, jclass cl } /** + * @brief Native method to initialize NNStreamer. + */ +jboolean +Java_org_nnsuite_nnstreamer_NNStreamer_nativeInitialize (JNIEnv * env, jclass clazz, + jobject context) +{ + return nnstreamer_native_initialize (); +} + +/** * @brief Native method to get the version string of NNStreamer and GStreamer. */ jstring diff --git a/api/android/build-android-lib.sh b/api/android/build-android-lib.sh index 307baae..37260e6 100644 --- a/api/android/build-android-lib.sh +++ b/api/android/build-android-lib.sh @@ -180,13 +180,35 @@ if [[ -e $nnstreamer_android_api_lib ]]; then mkdir -p $result_directory cp $nnstreamer_android_api_lib $result_directory/$nnstreamer_lib_name-$today.aar + # Prepare native libraries and header files for C-API + unzip $nnstreamer_android_api_lib -d aar_extracted + + mkdir -p main/java/org/freedesktop + mkdir -p main/jni/nnstreamer/lib + mkdir -p main/jni/nnstreamer/include + + cp -r api/src/main/java/org/freedesktop/* main/java/org/freedesktop + cp -r aar_extracted/jni/* main/jni/nnstreamer/lib + cp ext-files/jni/Android-nnstreamer-prebuilt.mk main/jni + cp $NNSTREAMER_ROOT/api/capi/include/nnstreamer.h main/jni/nnstreamer/include + cp $NNSTREAMER_ROOT/api/capi/include/nnstreamer-single.h main/jni/nnstreamer/include + cp $NNSTREAMER_ROOT/api/capi/include/platform/tizen_error.h main/jni/nnstreamer/include + + nnstreamer_native_files="$nnstreamer_lib_name-native-$today.zip" + zip -r $nnstreamer_native_files main + cp $nnstreamer_native_files $result_directory + + rm -rf aar_extracted main + + # Upload to jcenter if [[ $release_bintray == 'yes' ]]; then echo "Upload NNStreamer library to Bintray." ./gradlew api:bintrayUpload -PbintrayUser=$bintray_user_name -PbintrayKey=$bintray_user_key -PdryRun=false fi + # Run instrumentation test if [[ $run_unittest == 'yes' ]]; then - echo "Run instrumented test." + echo "Run instrumentation test." ./gradlew api:connectedCheck test_result="$nnstreamer_lib_name-test-$today.zip" -- 2.7.4