diff --git a/wrappers/android/mynteye/app/build.gradle b/wrappers/android/mynteye/app/build.gradle index 229eac5..3e74552 100644 --- a/wrappers/android/mynteye/app/build.gradle +++ b/wrappers/android/mynteye/app/build.gradle @@ -8,7 +8,7 @@ android { targetSdkVersion xversions.targetSdk versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ndk { abiFilters xabis } @@ -19,17 +19,26 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation xdeps.support.appcompat - implementation xdeps.support.constraint + implementation 'androidx.appcompat:appcompat:1.1.0-alpha01' + implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3' + + implementation 'com.jakewharton.timber:timber:4.7.1' + + implementation 'com.jakewharton:butterknife:10.0.0' + annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0' implementation project(':libmynteye') - testImplementation xdeps.junit - androidTestImplementation xdeps.support.test.runner - androidTestImplementation xdeps.support.test.espresso + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' } diff --git a/wrappers/android/mynteye/app/src/androidTest/java/com/slightech/mynteye/demo/ExampleInstrumentedTest.java b/wrappers/android/mynteye/app/src/androidTest/java/com/slightech/mynteye/demo/ExampleInstrumentedTest.java index a7c3f03..e30780b 100644 --- a/wrappers/android/mynteye/app/src/androidTest/java/com/slightech/mynteye/demo/ExampleInstrumentedTest.java +++ b/wrappers/android/mynteye/app/src/androidTest/java/com/slightech/mynteye/demo/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.slightech.mynteye.demo; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/wrappers/android/mynteye/app/src/main/AndroidManifest.xml b/wrappers/android/mynteye/app/src/main/AndroidManifest.xml index 76abdcc..0e03278 100644 --- a/wrappers/android/mynteye/app/src/main/AndroidManifest.xml +++ b/wrappers/android/mynteye/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ diff --git a/wrappers/android/mynteye/app/src/main/java/com/slightech/mynteye/demo/MainActivity.java b/wrappers/android/mynteye/app/src/main/java/com/slightech/mynteye/demo/MainActivity.java index e4578d3..ef9edd7 100644 --- a/wrappers/android/mynteye/app/src/main/java/com/slightech/mynteye/demo/MainActivity.java +++ b/wrappers/android/mynteye/app/src/main/java/com/slightech/mynteye/demo/MainActivity.java @@ -1,7 +1,10 @@ package com.slightech.mynteye.demo; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; +import com.slightech.mynteye.Device; +import com.slightech.mynteye.DeviceUsbInfo; +import timber.log.Timber; public class MainActivity extends AppCompatActivity { @@ -9,5 +12,9 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + + for (DeviceUsbInfo info : Device.query()) { + Timber.i(info.toString()); + } } } diff --git a/wrappers/android/mynteye/app/src/main/java/com/slightech/mynteye/demo/MyApplication.java b/wrappers/android/mynteye/app/src/main/java/com/slightech/mynteye/demo/MyApplication.java new file mode 100644 index 0000000..b72b43d --- /dev/null +++ b/wrappers/android/mynteye/app/src/main/java/com/slightech/mynteye/demo/MyApplication.java @@ -0,0 +1,32 @@ +package com.slightech.mynteye.demo; + +import android.app.Application; +import timber.log.Timber; + +public class MyApplication extends Application { + + static { + try { + System.loadLibrary("mynteye_jni"); + } catch (UnsatisfiedLinkError e) { + System.err.println("mynteye_jni library failed to load.\n" + e); + } + } + + @Override public void onCreate() { + super.onCreate(); + Timber.plant(new Timber.DebugTree()); + } + + @Override public void onLowMemory() { + super.onLowMemory(); + } + + @Override public void onTrimMemory(int level) { + super.onTrimMemory(level); + } + + @Override public void onTerminate() { + super.onTerminate(); + } +} diff --git a/wrappers/android/mynteye/app/src/main/res/layout/activity_main.xml b/wrappers/android/mynteye/app/src/main/res/layout/activity_main.xml index 3b779f6..8a0f7e4 100644 --- a/wrappers/android/mynteye/app/src/main/res/layout/activity_main.xml +++ b/wrappers/android/mynteye/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/wrappers/android/mynteye/build.gradle b/wrappers/android/mynteye/build.gradle index e7a3ada..76a5905 100644 --- a/wrappers/android/mynteye/build.gradle +++ b/wrappers/android/mynteye/build.gradle @@ -8,7 +8,7 @@ buildscript { jcenter() } dependencies { - classpath xplugins.android.buildGradle + classpath 'com.android.tools.build:gradle:3.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/wrappers/android/mynteye/gradle.properties b/wrappers/android/mynteye/gradle.properties index 82618ce..d546dea 100644 --- a/wrappers/android/mynteye/gradle.properties +++ b/wrappers/android/mynteye/gradle.properties @@ -6,6 +6,8 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit diff --git a/wrappers/android/mynteye/gradle/dependencies.gradle b/wrappers/android/mynteye/gradle/dependencies.gradle index c4d7278..9811a55 100644 --- a/wrappers/android/mynteye/gradle/dependencies.gradle +++ b/wrappers/android/mynteye/gradle/dependencies.gradle @@ -1,45 +1,8 @@ ext { - xplugins = [ - 'android': [ - // Gradle: https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google - buildGradle: 'com.android.tools.build:gradle:3.2.1', - ], - ] - xversions = [ 'compileSdk': 28, - 'minSdk': 21, + 'minSdk': 24, 'targetSdk': 28, - - 'androidSupport': '28.0.0', - ] - - xdeps = [ - // Support Library - // https://developer.android.com/topic/libraries/support-library/ - 'support': [ - // Android AppCompat Library V7 - // https://mvnrepository.com/artifact/com.android.support/appcompat-v7?repo=google - 'appcompat': "com.android.support:appcompat-v7:${xversions.androidSupport}", - - // Android ConstraintLayout Solver - // https://mvnrepository.com/artifact/com.android.support.constraint/constraint-layout-solver - 'constraint': 'com.android.support.constraint:constraint-layout:1.1.3', - // Android Multi Dex Library - // https://mvnrepository.com/artifact/com.android.support/multidex - 'multidex': 'com.android.support:multidex:1.0.3', - - // Test apps on Android - // https://developer.android.com/training/testing/ - 'test': [ - 'espresso': 'com.android.support.test.espresso:espresso-core:3.0.2', - 'rules': 'com.android.support.test:rules:1.0.2', - 'runner': 'com.android.support.test:runner:1.0.2', - ], - ], - - // JUnit4: https://github.com/junit-team/junit4 - 'junit': 'junit:junit:4.12', ] xabis = ['arm64-v8a', 'armeabi-v7a'] as String[] diff --git a/wrappers/android/mynteye/gradle/wrapper/gradle-wrapper.properties b/wrappers/android/mynteye/gradle/wrapper/gradle-wrapper.properties index 9a4163a..0c93efd 100644 --- a/wrappers/android/mynteye/gradle/wrapper/gradle-wrapper.properties +++ b/wrappers/android/mynteye/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Tue Jan 15 14:54:17 CST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/CMakeLists.txt b/wrappers/android/mynteye/libmynteye/CMakeLists.txt similarity index 64% rename from wrappers/android/mynteye/libmynteye/src/main/cpp/CMakeLists.txt rename to wrappers/android/mynteye/libmynteye/CMakeLists.txt index 104bdf3..31afdd5 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/cpp/CMakeLists.txt +++ b/wrappers/android/mynteye/libmynteye/CMakeLists.txt @@ -5,29 +5,46 @@ cmake_minimum_required(VERSION 3.4.1) -get_filename_component(MYNTETE_ROOT "${PROJECT_SOURCE_DIR}/../../../../../../.." ABSOLUTE) +get_filename_component(MYNTETE_ROOT "${PROJECT_SOURCE_DIR}/../../../.." ABSOLUTE) message(STATUS "MYNTETE_ROOT: ${MYNTETE_ROOT}") -set(MYNTEYE_NAME "mynteye") +if(NOT DJINNI_DIR) + if(DEFINED ENV{DJINNI_DIR}) + set(DJINNI_DIR $ENV{DJINNI_DIR}) + else() + set(DJINNI_DIR "$ENV{HOME}/Workspace/Fever/Dropbox/djinni") + endif() +endif() -set(MYNTEYE_NAMESPACE "${MYNTEYE_NAME}") -message(STATUS "Namespace: ${MYNTEYE_NAMESPACE}") +# libs + +## log + +find_library(log-lib log) + +## djinni_jni + +include_directories( + ${DJINNI_DIR}/support-lib/jni +) +add_library(djinni_jni STATIC + ${DJINNI_DIR}/support-lib/jni/djinni_support.cpp +) + +# targets + +## libmynteye + +add_definitions(-DMYNTEYE_EXPORTS) + +set(MYNTEYE_NAMESPACE "mynteye") +#message(STATUS "Namespace: ${MYNTEYE_NAMESPACE}") configure_file( ${MYNTETE_ROOT}/include/mynteye/mynteye.h.in include/mynteye/mynteye.h @ONLY ) -## libs - -find_library(log-lib log) - -## targets - -# libmynteye - -add_definitions(-DMYNTEYE_EXPORTS) - set(MYNTEYE_SRCS ${MYNTETE_ROOT}/src/mynteye/uvc/linux/uvc-v4l2.cc ${MYNTETE_ROOT}/src/mynteye/types.cc @@ -56,12 +73,35 @@ set(MYNTEYE_SRCS list(APPEND MYNTEYE_SRCS ${MYNTETE_ROOT}/src/mynteye/miniglog.cc) -add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS}) -target_link_libraries(${MYNTEYE_NAME} ${log-lib}) +add_library(mynteye STATIC ${MYNTEYE_SRCS}) +target_link_libraries(mynteye ${log-lib}) -target_include_directories(${MYNTEYE_NAME} PUBLIC +target_include_directories(mynteye PUBLIC "$" "$" "$" "$" ) + +## libmynteye_jni + +set(CPP_DIR "${PROJECT_SOURCE_DIR}/src/main/cpp") + +include_directories( + ${CPP_DIR}/mynteye/cpp + ${CPP_DIR}/mynteye/impl + ${CPP_DIR}/mynteye/jni +) + +set(MYNTEYE_JNI_SRCS "") +foreach(__dir cpp impl jni) + file(GLOB __srcs "${CPP_DIR}/mynteye/${__dir}/*.cpp") + list(APPEND MYNTEYE_JNI_SRCS ${__srcs}) +endforeach() +#message(STATUS "MYNTEYE_JNI_SRCS: ${MYNTEYE_JNI_SRCS}") + +add_library(mynteye_jni SHARED + ${DJINNI_DIR}/support-lib/jni/djinni_main.cpp + ${MYNTEYE_JNI_SRCS} +) +target_link_libraries(mynteye_jni ${log-lib} djinni_jni mynteye) diff --git a/wrappers/android/mynteye/libmynteye/build.gradle b/wrappers/android/mynteye/libmynteye/build.gradle index 97f0e29..b5c3507 100644 --- a/wrappers/android/mynteye/libmynteye/build.gradle +++ b/wrappers/android/mynteye/libmynteye/build.gradle @@ -9,7 +9,7 @@ android { versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" externalNativeBuild { // https://developer.android.com/ndk/guides/cmake @@ -32,15 +32,22 @@ android { externalNativeBuild { cmake { - path "src/main/cpp/CMakeLists.txt" + path "CMakeLists.txt" } } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - testImplementation xdeps.junit - androidTestImplementation xdeps.support.test.runner - androidTestImplementation xdeps.support.test.espresso + implementation 'androidx.annotation:annotation:1.0.1' + + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' } diff --git a/wrappers/android/mynteye/libmynteye/src/androidTest/java/com/slightech/mynteye/ExampleInstrumentedTest.java b/wrappers/android/mynteye/libmynteye/src/androidTest/java/com/slightech/mynteye/ExampleInstrumentedTest.java index 2b84b62..8348283 100644 --- a/wrappers/android/mynteye/libmynteye/src/androidTest/java/com/slightech/mynteye/ExampleInstrumentedTest.java +++ b/wrappers/android/mynteye/libmynteye/src/androidTest/java/com/slightech/mynteye/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.slightech.mynteye; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device.hpp new file mode 100644 index 0000000..6e0214f --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device.hpp @@ -0,0 +1,31 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#pragma once + +#include +#include + +namespace mynteye_jni { + +struct DeviceUsbInfo; +struct StreamRequest; + +class Device { +public: + virtual ~Device() {} + + static std::vector Query(); + + static std::shared_ptr Create(const DeviceUsbInfo & info); + + virtual std::vector GetStreamRequests() = 0; + + virtual void ConfigStreamRequest(const StreamRequest & request) = 0; + + virtual void Start() = 0; + + virtual void Stop() = 0; +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device_usb_info.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device_usb_info.hpp new file mode 100644 index 0000000..5f93d25 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/device_usb_info.hpp @@ -0,0 +1,26 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#pragma once + +#include +#include +#include + +namespace mynteye_jni { + +struct DeviceUsbInfo final { + int32_t index; + std::string name; + std::string sn; + + DeviceUsbInfo(int32_t index_, + std::string name_, + std::string sn_) + : index(std::move(index_)) + , name(std::move(name_)) + , sn(std::move(sn_)) + {} +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/format.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/format.hpp new file mode 100644 index 0000000..55febf5 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/format.hpp @@ -0,0 +1,28 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#pragma once + +#include + +namespace mynteye_jni { + +enum class Format : int { + GREY, + YUYV, + BGR888, + RGB888, +}; + +} // namespace mynteye_jni + +namespace std { + +template <> +struct hash<::mynteye_jni::Format> { + size_t operator()(::mynteye_jni::Format type) const { + return std::hash()(static_cast(type)); + } +}; + +} // namespace std diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream_request.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream_request.hpp new file mode 100644 index 0000000..0238c74 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/stream_request.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#pragma once + +#include "format.hpp" +#include +#include + +namespace mynteye_jni { + +struct StreamRequest final { + int32_t index; + int32_t width; + int32_t height; + Format format; + int32_t fps; + + StreamRequest(int32_t index_, + int32_t width_, + int32_t height_, + Format format_, + int32_t fps_) + : index(std::move(index_)) + , width(std::move(width_)) + , height(std::move(height_)) + , format(std::move(format_)) + , fps(std::move(fps_)) + {} +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.cpp new file mode 100644 index 0000000..f9cb061 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.cpp @@ -0,0 +1,77 @@ +#include "device_impl.hpp" + +#include "mynteye/device/context.h" +#include "mynteye/device/device.h" + +#include "device_usb_info.hpp" +#include "stream_request.hpp" +#include "type_conversion.hpp" + +MYNTEYE_USE_NAMESPACE + +namespace mynteye_jni { + +std::vector Device::Query() { + std::vector infos; + + Context context; + int32_t i = 0; + for (auto&& d : context.devices()) { + infos.emplace_back(i, + d->GetInfo(Info::DEVICE_NAME), + d->GetInfo(Info::SERIAL_NUMBER)); + ++i; + } + + return infos; +} + +std::shared_ptr Device::Create(const DeviceUsbInfo & info) { + Context context; + int32_t i = 0; + for (auto&& d : context.devices()) { + if (i == info.index) { + return std::make_shared(d); + } + ++i; + } + return nullptr; +} + +DeviceImpl::DeviceImpl(const device_t & device) : Device(), device_(device) { +} + +DeviceImpl::~DeviceImpl() { +} + +std::vector DeviceImpl::GetStreamRequests() { + std::vector requests; + + int32_t i = 0; + for (auto&& req : device_->GetStreamRequests()) { + requests.emplace_back(i, + req.width, req.height, to_jni(req.format), req.fps); + ++i; + } + + return requests; +} + +void DeviceImpl::ConfigStreamRequest(const StreamRequest & request) { + int32_t i = 0; + for (auto&& req : device_->GetStreamRequests()) { + if (i == request.index) { + device_->ConfigStreamRequest(req); + return; + } + ++i; + } +} + +void DeviceImpl::Start() { +} + +void DeviceImpl::Stop() { +} + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.hpp new file mode 100644 index 0000000..9462704 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/device_impl.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +#include "mynteye/device/device.h" + +#include "device.hpp" + +namespace mynteye_jni { + +class DeviceImpl : public Device { + public: + using device_t = std::shared_ptr; + + explicit DeviceImpl(const device_t & device); + ~DeviceImpl(); + + std::vector GetStreamRequests() override; + + void ConfigStreamRequest(const StreamRequest & request) override; + + void Start() override; + + void Stop() override; + + private: + device_t device_; +}; + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/type_conversion.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/type_conversion.hpp new file mode 100644 index 0000000..b705f26 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/impl/type_conversion.hpp @@ -0,0 +1,37 @@ +#include + +#include "mynteye/logger.h" +#include "mynteye/types.h" + +#include "format.hpp" + +namespace mynteye_jni { + +using RawFormat = MYNTEYE_NAMESPACE::Format; +using JniFormat = mynteye_jni::Format; + +inline +RawFormat from_jni(const JniFormat& format) { + switch (format) { + case JniFormat::GREY: return RawFormat::GREY; + case JniFormat::YUYV: return RawFormat::YUYV; + case JniFormat::BGR888: return RawFormat::BGR888; + case JniFormat::RGB888: return RawFormat::RGB888; + default: + LOG(FATAL) << "Format is unknown"; + } +} + +inline +JniFormat to_jni(const RawFormat& format) { + switch (format) { + case RawFormat::GREY: return JniFormat::GREY; + case RawFormat::YUYV: return JniFormat::YUYV; + case RawFormat::BGR888: return JniFormat::BGR888; + case RawFormat::RGB888: return JniFormat::RGB888; + default: + LOG(FATAL) << "Format is unknown"; + } +} + +} // namespace mynteye_jni diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDevice.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDevice.cpp new file mode 100644 index 0000000..a551ac0 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDevice.cpp @@ -0,0 +1,79 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#include "NativeDevice.hpp" // my header +#include "Marshal.hpp" +#include "NativeDeviceUsbInfo.hpp" +#include "NativeStreamRequest.hpp" + +namespace djinni_generated { + +NativeDevice::NativeDevice() : ::djinni::JniInterface<::mynteye_jni::Device, NativeDevice>("com/slightech/mynteye/Device$CppProxy") {} + +NativeDevice::~NativeDevice() = default; + + +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::mynteye_jni::Device>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_query(JNIEnv* jniEnv, jobject /*this*/) +{ + try { + DJINNI_FUNCTION_PROLOGUE0(jniEnv); + auto r = ::mynteye_jni::Device::Query(); + return ::djinni::release(::djinni::List<::djinni_generated::NativeDeviceUsbInfo>::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_create(JNIEnv* jniEnv, jobject /*this*/, jobject j_info) +{ + try { + DJINNI_FUNCTION_PROLOGUE0(jniEnv); + auto r = ::mynteye_jni::Device::Create(::djinni_generated::NativeDeviceUsbInfo::toCpp(jniEnv, j_info)); + return ::djinni::release(::djinni_generated::NativeDevice::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1getStreamRequests(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); + auto r = ref->GetStreamRequests(); + return ::djinni::release(::djinni::List<::djinni_generated::NativeStreamRequest>::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1configStreamRequest(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_request) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); + ref->ConfigStreamRequest(::djinni_generated::NativeStreamRequest::toCpp(jniEnv, j_request)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1start(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); + ref->Start(); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT void JNICALL Java_com_slightech_mynteye_Device_00024CppProxy_native_1stop(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::mynteye_jni::Device>(nativeRef); + ref->Stop(); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDevice.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDevice.hpp new file mode 100644 index 0000000..98629b8 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDevice.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#pragma once + +#include "device.hpp" +#include "djinni_support.hpp" + +namespace djinni_generated { + +class NativeDevice final : ::djinni::JniInterface<::mynteye_jni::Device, NativeDevice> { +public: + using CppType = std::shared_ptr<::mynteye_jni::Device>; + using CppOptType = std::shared_ptr<::mynteye_jni::Device>; + using JniType = jobject; + + using Boxed = NativeDevice; + + ~NativeDevice(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeDevice(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::mynteye_jni::Device, NativeDevice>; + +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.cpp new file mode 100644 index 0000000..755af55 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.cpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#include "NativeDeviceUsbInfo.hpp" // my header +#include "Marshal.hpp" + +namespace djinni_generated { + +NativeDeviceUsbInfo::NativeDeviceUsbInfo() = default; + +NativeDeviceUsbInfo::~NativeDeviceUsbInfo() = default; + +auto NativeDeviceUsbInfo::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef { + const auto& data = ::djinni::JniClass::get(); + auto r = ::djinni::LocalRef{jniEnv->NewObject(data.clazz.get(), data.jconstructor, + ::djinni::get(::djinni::I32::fromCpp(jniEnv, c.index)), + ::djinni::get(::djinni::String::fromCpp(jniEnv, c.name)), + ::djinni::get(::djinni::String::fromCpp(jniEnv, c.sn)))}; + ::djinni::jniExceptionCheck(jniEnv); + return r; +} + +auto NativeDeviceUsbInfo::toCpp(JNIEnv* jniEnv, JniType j) -> CppType { + ::djinni::JniLocalScope jscope(jniEnv, 4); + assert(j != nullptr); + const auto& data = ::djinni::JniClass::get(); + return {::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mIndex)), + ::djinni::String::toCpp(jniEnv, (jstring)jniEnv->GetObjectField(j, data.field_mName)), + ::djinni::String::toCpp(jniEnv, (jstring)jniEnv->GetObjectField(j, data.field_mSn))}; +} + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.hpp new file mode 100644 index 0000000..0d8b5f3 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeDeviceUsbInfo.hpp @@ -0,0 +1,34 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#pragma once + +#include "device_usb_info.hpp" +#include "djinni_support.hpp" + +namespace djinni_generated { + +class NativeDeviceUsbInfo final { +public: + using CppType = ::mynteye_jni::DeviceUsbInfo; + using JniType = jobject; + + using Boxed = NativeDeviceUsbInfo; + + ~NativeDeviceUsbInfo(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j); + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c); + +private: + NativeDeviceUsbInfo(); + friend ::djinni::JniClass; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/slightech/mynteye/DeviceUsbInfo") }; + const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "", "(ILjava/lang/String;Ljava/lang/String;)V") }; + const jfieldID field_mIndex { ::djinni::jniGetFieldID(clazz.get(), "mIndex", "I") }; + const jfieldID field_mName { ::djinni::jniGetFieldID(clazz.get(), "mName", "Ljava/lang/String;") }; + const jfieldID field_mSn { ::djinni::jniGetFieldID(clazz.get(), "mSn", "Ljava/lang/String;") }; +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFormat.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFormat.hpp new file mode 100644 index 0000000..36cf938 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeFormat.hpp @@ -0,0 +1,26 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "format.hpp" + +namespace djinni_generated { + +class NativeFormat final : ::djinni::JniEnum { +public: + using CppType = ::mynteye_jni::Format; + using JniType = jobject; + + using Boxed = NativeFormat; + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return static_cast(::djinni::JniClass::get().ordinal(jniEnv, j)); } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, CppType c) { return ::djinni::JniClass::get().create(jniEnv, static_cast(c)); } + +private: + NativeFormat() : JniEnum("com/slightech/mynteye/Format") {} + friend ::djinni::JniClass; +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.cpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.cpp new file mode 100644 index 0000000..b20eb93 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.cpp @@ -0,0 +1,37 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#include "NativeStreamRequest.hpp" // my header +#include "Marshal.hpp" +#include "NativeFormat.hpp" + +namespace djinni_generated { + +NativeStreamRequest::NativeStreamRequest() = default; + +NativeStreamRequest::~NativeStreamRequest() = default; + +auto NativeStreamRequest::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef { + const auto& data = ::djinni::JniClass::get(); + auto r = ::djinni::LocalRef{jniEnv->NewObject(data.clazz.get(), data.jconstructor, + ::djinni::get(::djinni::I32::fromCpp(jniEnv, c.index)), + ::djinni::get(::djinni::I32::fromCpp(jniEnv, c.width)), + ::djinni::get(::djinni::I32::fromCpp(jniEnv, c.height)), + ::djinni::get(::djinni_generated::NativeFormat::fromCpp(jniEnv, c.format)), + ::djinni::get(::djinni::I32::fromCpp(jniEnv, c.fps)))}; + ::djinni::jniExceptionCheck(jniEnv); + return r; +} + +auto NativeStreamRequest::toCpp(JNIEnv* jniEnv, JniType j) -> CppType { + ::djinni::JniLocalScope jscope(jniEnv, 6); + assert(j != nullptr); + const auto& data = ::djinni::JniClass::get(); + return {::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mIndex)), + ::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mWidth)), + ::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mHeight)), + ::djinni_generated::NativeFormat::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mFormat)), + ::djinni::I32::toCpp(jniEnv, jniEnv->GetIntField(j, data.field_mFps))}; +} + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.hpp b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.hpp new file mode 100644 index 0000000..bdc80b1 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/jni/NativeStreamRequest.hpp @@ -0,0 +1,36 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "stream_request.hpp" + +namespace djinni_generated { + +class NativeStreamRequest final { +public: + using CppType = ::mynteye_jni::StreamRequest; + using JniType = jobject; + + using Boxed = NativeStreamRequest; + + ~NativeStreamRequest(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j); + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c); + +private: + NativeStreamRequest(); + friend ::djinni::JniClass; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/slightech/mynteye/StreamRequest") }; + const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "", "(IIILcom/slightech/mynteye/Format;I)V") }; + const jfieldID field_mIndex { ::djinni::jniGetFieldID(clazz.get(), "mIndex", "I") }; + const jfieldID field_mWidth { ::djinni::jniGetFieldID(clazz.get(), "mWidth", "I") }; + const jfieldID field_mHeight { ::djinni::jniGetFieldID(clazz.get(), "mHeight", "I") }; + const jfieldID field_mFormat { ::djinni::jniGetFieldID(clazz.get(), "mFormat", "Lcom/slightech/mynteye/Format;") }; + const jfieldID field_mFps { ::djinni::jniGetFieldID(clazz.get(), "mFps", "I") }; +}; + +} // namespace djinni_generated diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Device.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Device.java new file mode 100644 index 0000000..725cd1b --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Device.java @@ -0,0 +1,94 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; + +public interface Device { + @NonNull + public ArrayList getStreamRequests(); + + public void configStreamRequest(@NonNull StreamRequest request); + + public void start(); + + public void stop(); + + @NonNull + public static ArrayList query() + { + return CppProxy.query(); + } + + @Nullable + public static Device create(@NonNull DeviceUsbInfo info) + { + return CppProxy.create(info); + } + + static final class CppProxy implements Device + { + private final long nativeRef; + private final AtomicBoolean destroyed = new AtomicBoolean(false); + + private CppProxy(long nativeRef) + { + if (nativeRef == 0) throw new RuntimeException("nativeRef is zero"); + this.nativeRef = nativeRef; + } + + private native void nativeDestroy(long nativeRef); + public void _djinni_private_destroy() + { + boolean destroyed = this.destroyed.getAndSet(true); + if (!destroyed) nativeDestroy(this.nativeRef); + } + protected void finalize() throws java.lang.Throwable + { + _djinni_private_destroy(); + super.finalize(); + } + + @Override + public ArrayList getStreamRequests() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_getStreamRequests(this.nativeRef); + } + private native ArrayList native_getStreamRequests(long _nativeRef); + + @Override + public void configStreamRequest(StreamRequest request) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + native_configStreamRequest(this.nativeRef, request); + } + private native void native_configStreamRequest(long _nativeRef, StreamRequest request); + + @Override + public void start() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + native_start(this.nativeRef); + } + private native void native_start(long _nativeRef); + + @Override + public void stop() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + native_stop(this.nativeRef); + } + private native void native_stop(long _nativeRef); + + @NonNull + public static native ArrayList query(); + + @Nullable + public static native Device create(@NonNull DeviceUsbInfo info); + } +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/DeviceUsbInfo.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/DeviceUsbInfo.java new file mode 100644 index 0000000..d190c89 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/DeviceUsbInfo.java @@ -0,0 +1,50 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +public final class DeviceUsbInfo { + + + /*package*/ final int mIndex; + + /*package*/ final String mName; + + /*package*/ final String mSn; + + public DeviceUsbInfo( + int index, + @NonNull String name, + @NonNull String sn) { + this.mIndex = index; + this.mName = name; + this.mSn = sn; + } + + public int getIndex() { + return mIndex; + } + + @NonNull + public String getName() { + return mName; + } + + @NonNull + public String getSn() { + return mSn; + } + + @Override + public String toString() { + return "DeviceUsbInfo{" + + "mIndex=" + mIndex + + "," + "mName=" + mName + + "," + "mSn=" + mSn + + "}"; + } + +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Format.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Format.java new file mode 100644 index 0000000..860daf6 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Format.java @@ -0,0 +1,15 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +public enum Format { + GREY, + YUYV, + BGR888, + RGB888, + ; +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/StreamRequest.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/StreamRequest.java new file mode 100644 index 0000000..a653e54 --- /dev/null +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/StreamRequest.java @@ -0,0 +1,67 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from mynteye.djinni + +package com.slightech.mynteye; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +public final class StreamRequest { + + + /*package*/ final int mIndex; + + /*package*/ final int mWidth; + + /*package*/ final int mHeight; + + /*package*/ final Format mFormat; + + /*package*/ final int mFps; + + public StreamRequest( + int index, + int width, + int height, + @NonNull Format format, + int fps) { + this.mIndex = index; + this.mWidth = width; + this.mHeight = height; + this.mFormat = format; + this.mFps = fps; + } + + public int getIndex() { + return mIndex; + } + + public int getWidth() { + return mWidth; + } + + public int getHeight() { + return mHeight; + } + + @NonNull + public Format getFormat() { + return mFormat; + } + + public int getFps() { + return mFps; + } + + @Override + public String toString() { + return "StreamRequest{" + + "mIndex=" + mIndex + + "," + "mWidth=" + mWidth + + "," + "mHeight=" + mHeight + + "," + "mFormat=" + mFormat + + "," + "mFps=" + mFps + + "}"; + } + +} diff --git a/wrappers/android/mynteye/scripts/.gitignore b/wrappers/android/mynteye/scripts/.gitignore new file mode 100644 index 0000000..0c9146c --- /dev/null +++ b/wrappers/android/mynteye/scripts/.gitignore @@ -0,0 +1 @@ +/djinni-output-temp/ diff --git a/wrappers/android/mynteye/scripts/mynteye.djinni b/wrappers/android/mynteye/scripts/mynteye.djinni new file mode 100644 index 0000000..236cfc5 --- /dev/null +++ b/wrappers/android/mynteye/scripts/mynteye.djinni @@ -0,0 +1,33 @@ + +format = enum { + grey; + yuyv; + bgr888; + rgb888; +} + +stream_request = record { + index: i32; + width: i32; + height: i32; + format: format; + fps: i32; +} + +device_usb_info = record { + index: i32; + name: string; + sn: string; +} + +device = interface +c { + static query(): list; + + static create(info: device_usb_info): device; + + get_stream_requests(): list; + config_stream_request(request: stream_request); + + start(); + stop(); +} diff --git a/wrappers/android/mynteye/scripts/run_djinni.sh b/wrappers/android/mynteye/scripts/run_djinni.sh new file mode 100755 index 0000000..675cb15 --- /dev/null +++ b/wrappers/android/mynteye/scripts/run_djinni.sh @@ -0,0 +1,83 @@ +#! /usr/bin/env bash +set -e +shopt -s nullglob + +base_dir=$(cd "$(dirname "$0")" && pwd) + +# options + +while getopts "d:i:" opt; do + case "$opt" in + d) djinni_dir="$OPTARG" ;; + i) in_idl="$OPTARG" ;; + ?) echo "Usage: $0 <-d DJINNI_DIR> [-i IN_IDL]" + exit 2 ;; + esac +done + +if [ -z "$djinni_dir" ]; then + echo "<-d DJINNI_DIR> option is required" 1>&2 + exit 2 +fi + +[ -n "$in_idl" ] || in_idl="$base_dir/mynteye.djinni" + +# generate + +djinni_run="$djinni_dir/src/run-assume-built" +if [ ! -x "$djinni_run" ]; then + echo "djinni run file not found: $djinni_run" 1>&2 + exit 2 +fi + +temp_out="$base_dir/djinni-output-temp" + +java_package="com.slightech.mynteye" +cpp_namespace="mynteye_jni" + +[ ! -e "$temp_out" ] || rm -r "$temp_out" +"$djinni_run" \ +--java-out "$temp_out/java" \ +--java-package "$java_package" \ +--java-class-access-modifier "public" \ +--java-generate-interfaces true \ +--java-nullable-annotation "androidx.annotation.Nullable" \ +--java-nonnull-annotation "androidx.annotation.NonNull" \ +--ident-java-field mFooBar \ +\ +--cpp-out "$temp_out/cpp" \ +--cpp-namespace "$cpp_namespace" \ +--ident-cpp-enum-type FooBar \ +--ident-cpp-method FooBar \ +\ +--jni-out "$temp_out/jni" \ +--ident-jni-class NativeFooBar \ +--ident-jni-file NativeFooBar \ +\ +--idl "$in_idl" + +# copy + +mirror() { + local prefix="$1" ; shift + local src="$1" ; shift + local dest="$1" ; shift + mkdir -p "$dest" + rsync -r --delete --checksum --itemize-changes "$src"/ "$dest" | sed "s/^/[$prefix]/" +} + +dst_dir="$base_dir/../libmynteye/src/main" +cpp_out="$dst_dir/cpp/mynteye/cpp" +jni_out="$dst_dir/cpp/mynteye/jni" +java_out="$dst_dir/java/com/slightech/mynteye" + +gen_stamp="$temp_out/gen.stamp" + +echo "Copying generated code to final directories..." +mirror "cpp" "$temp_out/cpp" "$cpp_out" +mirror "jni" "$temp_out/jni" "$jni_out" +mirror "java" "$temp_out/java" "$java_out" + +date > "$gen_stamp" + +echo "djinni completed."