GithubHelp home page GithubHelp logo

cross-language-cpp / djinni-support-lib Goto Github PK

View Code? Open in Web Editor NEW
27.0 7.0 10.0 422 KB

C++ support library that is required as a foundation for the generated djinni gluecode

Home Page: https://djinni.xlcpp.dev/djinni-support-lib/install

License: Apache License 2.0

CMake 8.98% C++ 45.59% Objective-C 6.31% Objective-C++ 7.48% Java 9.42% C 1.03% Python 16.60% C# 4.58%
djinni

djinni-support-lib's Introduction

djinni-support-lib's People

Contributors

a4z avatar dyp avatar eakoli avatar fanglinifolor avatar freitass avatar jothepro avatar richey-v avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

djinni-support-lib's Issues

Replace `assert` statements in Marshall.hpp with run-time error handling

The assert statements were discovered due to a warning, reported in #13. The warnings were addressed in #15.

The apparent purpose of the asserts is to ensure that a NewByteArray can be created that is large enough to handle the data to be marshaled. There is no run-time error handling other than the assert statement, so if those are optimized away, there is no safety at all.

`DJINNI_WITH_PYTHON` does not build on Windows

When trying to build djinni-support-lib DJINNI_WITH_PYTHON=ON with Visual Studio 16, the build fails with the following error:

fatal error C1083: Datei (Include) kann nicht geöffnet werden: "pthread.h": No such file or directory

I am aware that Python is experimental and not yet supported on Windows, so this does not have a high priority to me. I just stumbled across it by accident.

Use CMake djinni-support-lib target in integration tests

Currently the integration tests do include the support-lib by globbing for it's source files like in the good old days:

if(DJINNI_WITH_JNI)
  file(GLOB_RECURSE SUPPORT_LIB_JNI_SRCS "${CMAKE_SOURCE_DIR}/djinni/jni/*")

  add_library(DjinniTestNative SHARED
    ${SUPPORT_LIB_JNI_SRCS}
    ${JNI_GENERATED_SRCS}
    ${CPP_GENERATED_SRCS}
    ${WCHAR_JNI_GENERATED_SRCS}
    ${WCHAR_CPP_GENERATED_SRCS}
    ${CPP_HANDWRITTEN_SRCS}
  )

This is not optimal as the tests can not detect errors in the support-lib CMake target configuration.

As a maintainer I would like the tests to link the djinni-support-lib target that is defined in the root CMakeLists.txt:

if(DJINNI_WITH_JNI)
  add_library(DjinniTestNative SHARED
    ${JNI_GENERATED_SRCS}
    ${CPP_GENERATED_SRCS}
    ${WCHAR_JNI_GENERATED_SRCS}
    ${WCHAR_CPP_GENERATED_SRCS}
    ${CPP_HANDWRITTEN_SRCS}
  )
  target_link_libraries(DjinniTestNative PUBLIC djinni_support_lib)

Python windows build problems

Even after the change which targets issue #32 , and fixes that , there are several issues with the Windows build for Python.

Then, the problems:

First

string(JOIN ":" PYTHONPATH

On Windows, the PYTHON_PATH needs to be separated with a ; character, not with a :

Second

Even when this is done, when it is used on Windows

${CMAKE_COMMAND} -E env PYTHONPATH=${PYTHONPATH} ${PYTHON_EXECUTABLE}

CMake replaces the semicolon with a space, so something must be done to prevent that from happen,

Third

When this is fixed, on Windows with MSVC, the required created lib (mylib) needs to be found, what is not the case if this library gets generated into subfolder, like Debug.
Just output them into the current binary dir would work, but would also cause other side effects, like, problems with everything that support a multiconfig build (msvc, ninja, ...)

Forth

And when this is fixed and we would have a custom_target command that works, a next problem occurse.

opt = compiler.runtime_library_dir_option(dir)
  File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\_msvccompiler.py", line 519, in runtime_library_dir_option
    raise DistutilsPlatformError(
distutils.errors.DistutilsPlatformError: don't know how to set runtime library search path for MSVC
Batch file failed at line 3 with errorcode 1

Actions

Due to time restrictions I can not say how long it will take me to dig into all that, so help would be welcome.
Even if not the whole issue gets fixed, but parts from it.

First step

As a first step I suggest:
Disable it in CMake and bring a nice message, instead of letting users run into cryptic errors.

assertion failure on Android AVD on Apple M1

When using Djinni in the Android Emulator for Apple M1 (arm64), the assertion in djinni_support.hpp:323 fails.

This is a false positive (no pun intended). In this environment handle can be negative. I'm not quite sure where the 4096 comes from, but I would suggest to either remove the assertion, cast the (signed) jlong value to unsigned for this assertion or allow the value to be either negative or greater than 4096.

I can confirm that my application runs perfectly fine when uncommenting this assertion.

Problems when use Conan recipe and iOS + Darwin Toolchain

Hi,

Problems when use Conan recipe and iOS + Darwin Toolchain:

Example:

self.requires("djinni-support-lib/1.2.0")

Profile:

include(default)

[settings]
os=iOS
os.version=9.0
arch=armv7

[build_requires]
darwin-toolchain/1.3.0@ezored/stable

Problem:

djinni library is unique in my case that don't was built with bitcode

Error:

ld: '/Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/package/d6e505b85ccfea684875e909e66f7dd9e382b16b/lib/libdjinni_support_lib.a(DJIProxyCaches.mm.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Log:

djinni-support-lib/1.2.0: Applying build-requirement: darwin-toolchain/1.3.0@ezored/stable
Downloading conan_sources.tgz completed [0.31k]                                          
Decompressing conan_sources.tgz completed [0.00k]                                        
djinni-support-lib/1.2.0: Configuring sources in /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/source
Downloading v1.2.0.tar.gz completed [370.66k]                                            

djinni-support-lib/1.2.0: Copying sources to build folder
djinni-support-lib/1.2.0: Building your package in /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/build/d6e505b85ccfea684875e909e66f7dd9e382b16b
djinni-support-lib/1.2.0: Generator cmake created conanbuildinfo.cmake
djinni-support-lib/1.2.0: Aggregating env generators
djinni-support-lib/1.2.0: Calling build()
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: called by CMake conan helper
-- Conan: called inside local cache
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Adjusting fPIC flag (ON)
-- Conan: C++ stdlib: libc++
-- The OBJC compiler identification is AppleClang 13.0.0.13000029
-- The OBJCXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting OBJC compiler ABI info
-- Detecting OBJC compiler ABI info - done
-- Check for working OBJC compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting OBJCXX compiler ABI info
-- Detecting OBJCXX compiler ABI info - done
-- Check for working OBJCXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_EXPORT_NO_PACKAGE_REGISTRY
    CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
    CMAKE_FIND_ROOT_PATH_MODE_PACKAGE


-- Build files have been written to: /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/build/d6e505b85ccfea684875e909e66f7dd9e382b16b
[ 66%] Building OBJCXX object source_subfolder/CMakeFiles/djinni_support_lib.dir/djinni/objc/DJIError.mm.o
[ 66%] Building OBJCXX object source_subfolder/CMakeFiles/djinni_support_lib.dir/djinni/objc/DJIProxyCaches.mm.o
[100%] Linking OBJCXX static library ../lib/libdjinni_support_lib.a
[100%] Built target djinni_support_lib
djinni-support-lib/1.2.0: Package 'd6e505b85ccfea684875e909e66f7dd9e382b16b' built
djinni-support-lib/1.2.0: Build folder /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/build/d6e505b85ccfea684875e909e66f7dd9e382b16b
djinni-support-lib/1.2.0: Generated conaninfo.txt
djinni-support-lib/1.2.0: Generated conanbuildinfo.txt
djinni-support-lib/1.2.0: Generating the package
djinni-support-lib/1.2.0: Package folder /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/package/d6e505b85ccfea684875e909e66f7dd9e382b16b
djinni-support-lib/1.2.0: Calling package()
Consolidate compiler generated dependencies of target djinni_support_lib
[100%] Built target djinni_support_lib
Install the project...
-- Install configuration: "Debug"
-- Installing: /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/package/d6e505b85ccfea684875e909e66f7dd9e382b16b/lib/libdjinni_support_lib.a
-- Installing: /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/package/d6e505b85ccfea684875e909e66f7dd9e382b16b/include/djinni/djinni_common.hpp
-- Installing: /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/package/d6e505b85ccfea684875e909e66f7dd9e382b16b/include/djinni/proxy_cache_interface.hpp
-- Installing: /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/package/d6e505b85ccfea684875e909e66f7dd9e382b16b/include/djinni/proxy_cache_impl.hpp
-- Installing: /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/package/d6e505b85ccfea684875e909e66f7dd9e382b16b/include/djinni/objc/DJICppWrapperCache+Private.h
-- Installing: /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/package/d6e505b85ccfea684875e909e66f7dd9e382b16b/include/djinni/objc/DJIError.h
-- Installing: /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/package/d6e505b85ccfea684875e909e66f7dd9e382b16b/include/djinni/objc/DJIMarshal+Private.h
-- Installing: /Users/paulo/.conan/data/djinni-support-lib/1.2.0/_/_/package/d6e505b85ccfea684875e909e66f7dd9e382b16b/include/djinni/objc/DJIObjcWrapperCache+Private.h
djinni-support-lib/1.2.0 package(): Packaged 1 file: LICENSE
djinni-support-lib/1.2.0 package(): Packaged 3 '.hpp' files: proxy_cache_interface.hpp, proxy_cache_impl.hpp, djinni_common.hpp
djinni-support-lib/1.2.0 package(): Packaged 4 '.h' files: DJICppWrapperCache+Private.h, DJIError.h, DJIObjcWrapperCache+Private.h, DJIMarshal+Private.h
djinni-support-lib/1.2.0 package(): Packaged 1 '.a' file: libdjinni_support_lib.a
djinni-support-lib/1.2.0: Package 'd6e505b85ccfea684875e909e66f7dd9e382b16b' created
djinni-support-lib/1.2.0: Created package revision cd4db5aa19e05c24df9b6716abdd748c

Can anyone help me?

Remove CMake option DJINNI_STATIC_LIB in favor of BUILD_SHARED_LIBS

CMake provides a standardized way to configure if targets should be STATIC or SHARED:

From the documentation for add_library:

If no type is given explicitly the type is STATIC or SHARED based on whether the current value of the variable BUILD_SHARED_LIBS is ON

We should get rid of DJINNI_STATIC_LIB in favor of BUILD_SHARED_LIBS.

Windows make install does not install the shared library

When building this lib on Windows with shared library, the make install step does not install the dll.
This is most likely due to the fact that Windows is special, and might want a RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" in the install part.
While this is of low priority, it hinders building conan packages with shared libraries enabled, see conan-io/conan-center-index#5063 , and it would be nice providing that feature.

Python CFFI build problem on Windows

On Windows, the current CMake build ends with a Python CFFI problem.
This is unfortunately unsolved so far, and help for fixing this problem is welcome

...
...
  Building CFFI lib
  PyCFFIlib_cffi.c
CUSTOMBUILD : warning : I don't know what to do with 'runtime_library_dirs': ['.'] [C:\Users\a4z\work\djinni\support-lib\build\py2\test-suite\PyCFFIlib_cffi.vcxproj]
  Traceback (most recent call last):
    File "C:\Users\a4z\work\djinni\support-lib\build\py2\test-suite\generated-src\cffi\pycffi_lib_build.py", line 25, in <module>
      ffi.compile()
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\cffi\api.py", line 725, in compile
      return recompile(self, module_name, source, tmpdir=tmpdir,
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\cffi\recompiler.py", line 1564, in recompile
      outputfilename = ffiplatform.compile('.', ext,
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\cffi\ffiplatform.py", line 22, in compile
      outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\cffi\ffiplatform.py", line 51, in _build
      dist.run_command('build_ext')
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\build_ext.py", line 79, in run
      _build_ext.run(self)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 340, in run
      self.build_extensions()
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 449, in build_extensions
      self._build_extensions_serial()
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 474, in _build_extensions_serial
      self.build_extension(ext)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\build_ext.py", line 196, in build_extension
      _build_ext.build_extension(self, ext)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 551, in build_extension
      self.compiler.link_shared_object(
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\ccompiler.py", line 713, in link_shared_object
      self.link(CCompiler.SHARED_OBJECT, objects,
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\_msvccompiler.py", line 460, in link
      lib_opts = gen_lib_options(self,
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\msvc.py", line 329, in msvc14_gen_lib_options
      return get_unpatched(msvc14_gen_lib_options)(*args, **kwargs)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\ccompiler.py", line 1093, in gen_lib_options
      opt = compiler.runtime_library_dir_option(dir)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\_msvccompiler.py", line 519, in runtime_library_dir_option
      raise DistutilsPlatformError(
  distutils.errors.DistutilsPlatformError: don't know how to set runtime library search path for MSVC
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for 'C:\Users\a4z\work\djinni\support-lib\build\py2\CMakeFiles 
\aadf18d4fcbdff197304b4b5d83cea85\pycffi_lib_build.py.rule;C:\Users\a4z\work\djinni\support-lib\build\py2\CMakeFiles\5ce445708c0c39eeaefe4c3c138abd3a\Foo_Record.py.rule;C:\Users\a4z\work\djinni\support-lib\build\py 
2\CMakeFiles\0723da9f51c0e0e7e15825be3e6cbffb\PyCFFIlib_cffi.rule' exited with code 1. [C:\Users\a4z\work\djinni\support-lib\build\py2\test-suite\PyCFFIlib_cffi.vcxproj]
~\work\djinni\support-lib [private/moreWindowsTweaks +4 ~1 -0 !] (18:36:58)

Evaluate: check setting include dir in cmake

It might become a requirement, maybe in case we want a cmake configure file, to set include directories properly
check if, and if how, something like this could be used correctly so it works on all platfroms

target_include_directories(djinni_support_lib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/djinni>
$<INSTALL_INTERFACE:include/djinni> 
)

sign-compare warning in Marshal.hpp

Upgraded from Ubuntu18.04 to Ubuntu20.04 and am now getting a (new) sign-compare warning in Marshall.hpp:

djinni/jni/Marshal.hpp: In static member function ‘static djinni::LocalRef<_jbyteArray*> djinni::Binary::fromCpp(JNIEnv*, const CppType&)’:
djinni/jni/Marshal.hpp:246:29: warning: comparison of integer expressions of different signedness: ‘std::vector<unsigned char>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
  246 |             assert(c.size() <= std::numeric_limits<jsize>::max());
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Most likely due to and upgrade of clang. I'm going to try to fix this in a fork and issue a PR. I'll also try to update w/ compiler details.

Support for weak pointers

The current design of the proxies that are passed to c++ is that they hold a strong reference to the proxied object, and the proxy factory holds a weak reference to the proxy. This results in a situation where if the C++ side wants to hold a std::weak_ptr to the proxy, it cannot, as the proxy is automatically destroyed once all users of the proxy discard it.

This creates issues when using a delegate pattern where the platform object creates a c++ object and passes it a delegate interface. The C++ code has to maintain a strong reference (or the proxy is destroyed) and the delegate implementation has to hold a weak reference to the platform object. This can easily become cumbersome (especially on java where you cannot just decorate a member as weak). Additionally it requires de-registration of the delegate in some circumstances to properly clean up and not leave "dangling" objects.

I'm primarily looking for feedback on if this could be included in the core code, which options would be more likely to be accepted, etc.

To implement this it requires a "weak_ptr" conforming template (we cannot use weak_ptr directly because it cannot be partially specialized, and full specialization proved to be problematic)

template
struct djinni::reference;

This struct implements the basic weak_ptr contract (reset(),lock(),etc) using a holder that is virtual. This allows the implementation of the weak reference mechanics to be customized not only by type, but by instance. If T is a non djinni proxy, its backed by a standard weak_ptr, if instead the instance is a proxy its implemented by holding a weak reference to the platform object (__weak id / WeakReference) and uses the generated toCpp routine to dynamically get/create the proxy when needed.

This results in a string reference from the c++ side keeping the proxied object alive, but a weak reference doesn't. And as soon as the proxied object 'dies' all the weak references properly return an empty shared_ptr when locking.

Currently I have several working patterns that fully implements working weak_ptr semantics to both native and proxy implementations of a djinni interface

Option 1 (simpler, less robust, less intrusive)

djinni-generator -> extended with a new reference< T > type that maps to a djinni::reference< T >.
since the type is parameterized it has access to the generated Marshall contract for any proxied objects. If an platform object is passed to the c++ side as a reference, it generates a reference backed by the weak ref to the platform object.
If the c++ method is called directly from c++ it end up passing a reference backed by a weak_ptr.
djinni-support-lib -> implementation of the reference template

cons:

  • since the translation occurs in the marshaling code, its not possible to convert from a shared_ptr to a reference and maintain the true "weak" reference, as there is no public way to test if an object is a proxy or not.
    benefit

pros:

  • minimal changes to the generator, as its all isolated to a new type
  • the interface clearly documents the intent of how the object will be used (e.g weakly held vs used/strongly held)
  • no hard code links to the platform code (e.g. the same compilation of the c++ code works on all platforms) as the type is "pushed" to the c++ side (just like how an interface is pushed)

Option 2 (more complex, but robust)

djinni-generator -> extend the generation of the Marshall code to generate the proxies with a marker interface. This provides a way to test if an instance is a proxy or not, and if it is, create a 'safe' weak reference to it.
djinni-support-lib -> implementation of the reference template, declaration of the djinni::Proxy interface

cons:

  • involves changing the generated proxy classes, and having to implement the Proxy interface for each one. (can be managed by a template mostly, but still requires minor changes to the generated class)
  • the c++ code has to use the djinni-support-lib directly (currently only the platform implementations need it)

pros:

  • since the instances can be "tested" to see if they are proxies, it allows full 'safe' conversion of std::shared_ptr < - > djinni:reference

Option 3 (more robust, less intrusive - sort of)

Similar to option 2, but instead of altering the proxies, a factory is exposed. That type is parameterized with the djinni interface providing isProxy / make_reference, implemented by the generated marshaling code
djinni-generator -> generate an implementation of the ProxyFactory for that type.
djinni-support-lib -> implementation of the reference template, declaration of the djinni::ProxyFactory interface

cons:

  • the c++ code has a hard dependency on the ProxyFactory, which is generated by the platform marshaling code, and this relies on being linked with a platform. This causes issues if the c++ code is used In a pure c++ fashion as there has to be an implementation of the factory.
  • since there can only be one implementation of the factory, it would not be possible to have a single binary that uses multiple platform implementations (not sure thats current intended to work, but is technically feasible, something like a c++ program that has some objc implementations of things and some java)

NOTE: both of the above could be mitigated using a factory 'registration' mechanism (similar to how the JNI code manages its JniClass instances

pros:

  • reduced / more isolated changes to the generator

JNI_OnLoad/JNI_OnUnload - default implementation not optional

In djinni_jni_main.hpp it is written:

Don't include it if your library does require a custom JNI_OnLoad implementation with custom initialization logic.

Unfortunately the djinni-support-lib has not made the inclusion of this default implementation optional.

Java/JNI thread problems

Hi,

I have a strange problem when i call one java method to make a log:

image

First step:

image

Second step:

image

Third step:

image

Forty step:

image

Obs:

This is very strange, because other call to the same method don't have error, only this in full application.

You can see that first is called ([SimpleHttpServerRequestHandlerFactory : constructor]) and others too before:

image

What about the NativeLibLoader?

In java/com/dropbox/djinni/NativeLibLoader.java a class to help loading native libs is provided. I'm not sure how it is supposed to work because I never had to use it.

As a maintainer I'd like to get an answer to the following questions:

  • How should the loader be distributed? The best option to me seems to move it to a separate repo & publish it as library on some package registry.
  • When and how should it be used? Currently there is just a single paragraph in the docs about it, but it's in the wrong place and not up-to-date.

Additionally I'd like to adapt the package of the class to match our organization (com.github.cross-language-cpp)

Publish to hunter package manager

As a user I want to be able to easily install the latest version of the support-lib over a package manager.
The package manager of my choice is hunter.

Required steps:

  • Update CMakeLists.txt to fulfill [requirements by hunter
  • Add repository to hunter package list (requires a PR to the hunter repository)

Suggestion to use two main files for JNI

Hi,

I think that we can have two main files for JNI.

I remember where i use it before in a project.

Android projects that use libraries like SDL2 already have JNI_OnLoad. See:

https://github.com/libsdl-org/SDL/blob/98a966d1c20afc0abd27d8cd449810893104a908/src/core/android/SDL_android.c#L506-L522

And this function is called here on JVM:
https://android.googlesource.com/platform/dalvik/+/eclair-release/vm/Native.c#532

And the problem is duplicate the entrypoint for function JNI_OnLoad. This problem is described here:
https://engineering.fb.com/2018/01/23/android/android-native-library-merging/

A solution that i created to my projects is have two "main" files for Android. One is your original implementation today and other is initialize djinni after other libraries already initialize JNI. It let library developer choose what implementation use.

My files:
https://github.com/ezored/ezored/blob/version-3/files/modules/support-lib/djinni/jni/main/djinni_jni_main.hpp
and
https://github.com/ezored/ezored/blob/version-3/files/modules/support-lib/djinni/jni/main-ext/djinni_jni_main.hpp

Other references if need:

Github action plan

How to continuously build and test the support lib ?

Use github action, but to do what exactly

Conan recipe and java files

Hi,

When i build my java library in my project ezored (github.com/ezored/ezored) i copy java files folder from support-lib to my library (support-lib/java).

But when i migrate to conan recipe, how i can copy the java folder to my library folder? How can i access the support-lib recipe files to copy java folder?

Thanks.

Some warnings for mac catalyst

Hi,

Some warnings appear when build for mac catalyst:

/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJIMarshal+Private.h:128:113: warning: 'integerValue' is only available on macCatalyst 13.0 or newer [-Wunguarded-availability-new]
        static CppType toCpp(ObjcType x, Tag<int>) noexcept { return Enum::toCpp(static_cast<Enum::ObjcType>([x integerValue])); }
                                                                                                                ^~~~~~~~~~~~~
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:4:
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJICppWrapperCache+Private.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSRange.h:5:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSValue.h:73:32: note: 'integerValue' has been marked as being introduced in macCatalyst 13.0
      here, but the deployment target is macCatalyst 5.0.0
@property (readonly) NSInteger integerValue API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
                               ^
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:6:
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJIMarshal+Private.h:128:113: note: enclose 'integerValue' in an @available check to silence this warning
        static CppType toCpp(ObjcType x, Tag<int>) noexcept { return Enum::toCpp(static_cast<Enum::ObjcType>([x integerValue])); }
                                                                                                                ^~~~~~~~~~~~~
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJIMarshal+Private.h:129:82: warning: 'numberWithInteger:' is only available on macCatalyst 13.0 or newer [-Wunguarded-availability-new]
        static ObjcType fromCpp(CppType x, Tag<int>) noexcept { return [NSNumber numberWithInteger:static_cast<NSInteger>(Enum::fromCpp(x))]; }
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:4:
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJICppWrapperCache+Private.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSRange.h:5:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSValue.h:101:1: note: 'numberWithInteger:' has been marked as being introduced in macCatalyst
      13.0 here, but the deployment target is macCatalyst 5.0.0
+ (NSNumber *)numberWithInteger:(NSInteger)value API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:6:
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJIMarshal+Private.h:129:82: note: enclose 'numberWithInteger:' in an @available check to silence this warning
        static ObjcType fromCpp(CppType x, Tag<int>) noexcept { return [NSNumber numberWithInteger:static_cast<NSInteger>(Enum::fromCpp(x))]; }
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJIMarshal+Private.h:131:118: warning: 'unsignedIntegerValue' is only available on macCatalyst 13.0 or newer [-Wunguarded-availability-new]
        static CppType toCpp(ObjcType x, Tag<unsigned>) noexcept { return Enum::toCpp(static_cast<Enum::ObjcType>([x unsignedIntegerValue])); }
                                                                                                                     ^~~~~~~~~~~~~~~~~~~~~
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:4:
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJICppWrapperCache+Private.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSRange.h:5:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSValue.h:74:33: note: 'unsignedIntegerValue' has been marked as being introduced in
      macCatalyst 13.0 here, but the deployment target is macCatalyst 5.0.0
@property (readonly) NSUInteger unsignedIntegerValue API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
                                ^
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:6:
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJIMarshal+Private.h:131:118: note: enclose 'unsignedIntegerValue' in an @available check to silence this warning
        static CppType toCpp(ObjcType x, Tag<unsigned>) noexcept { return Enum::toCpp(static_cast<Enum::ObjcType>([x unsignedIntegerValue])); }
                                                                                                                     ^~~~~~~~~~~~~~~~~~~~~
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJIMarshal+Private.h:132:87: warning: 'numberWithUnsignedInteger:' is only available on macCatalyst 13.0 or newer [-Wunguarded-availability-new]
        static ObjcType fromCpp(CppType x, Tag<unsigned>) noexcept { return [NSNumber numberWithUnsignedInteger:static_cast<NSUInteger>(Enum::fromCpp(x))]; }
                                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:4:
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJICppWrapperCache+Private.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:7:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSRange.h:5:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSValue.h:102:1: note: 'numberWithUnsignedInteger:' has been marked as being introduced in
      macCatalyst 13.0 here, but the deployment target is macCatalyst 5.0.0
+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:6:
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJIMarshal+Private.h:132:87: note: enclose 'numberWithUnsignedInteger:' in an @available check to silence this warning
        static ObjcType fromCpp(CppType x, Tag<unsigned>) noexcept { return [NSNumber numberWithUnsignedInteger:static_cast<NSUInteger>(Enum::fromCpp(x))]; }
                                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJIMarshal+Private.h:391:14: warning: 'enumerateKeysAndObjectsUsingBlock:' is only available on macCatalyst 13.0 or newer
      [-Wunguarded-availability-new]
        [map enumerateKeysAndObjectsUsingBlock:^(ObjcKeyType key, ObjcValueType obj, BOOL *) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:4:
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJICppWrapperCache+Private.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSDictionary.h:48:1: note: 'enumerateKeysAndObjectsUsingBlock:' has been marked as being
      introduced in macCatalyst 13.0 here, but the deployment target is macCatalyst 5.0.0
- (void)enumerateKeysAndObjectsUsingBlock:(void (NS_NOESCAPE ^)(KeyType key, ObjectType obj, BOOL *stop))block API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0));
^
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:6:
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJIMarshal+Private.h:391:14: note: enclose 'enumerateKeysAndObjectsUsingBlock:' in an @available check to silence this warning
        [map enumerateKeysAndObjectsUsingBlock:^(ObjcKeyType key, ObjcValueType obj, BOOL *) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:8:
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData.h:8:27: warning: 'NSObject' is only available on macCatalyst 13.0 or newer [-Wunguarded-availability-new]
@interface UBSharedData : NSObject
                          ^
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:4:
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/support-lib/djinni/objc/DJICppWrapperCache+Private.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:6:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/objc/NSObject.h:53:12: note: 'NSObject' has been marked as being introduced in macCatalyst 13.0 here, but the deployment target is
      macCatalyst 5.0.0
@interface NSObject <NSObject> {
           ^
In file included from /Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData+Private.mm:8:
/Users/ubookmobile/Developer/workspaces/cpp/ubook-sdk-mobile/files/modules/shared-data/gluecode/generated-src/objc/ubook/data/UBSharedData.h:8:12: note: annotate 'UBSharedData' with an availability attribute to silence this warning
@interface UBSharedData : NSObject
           ^
6 warnings generated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.