-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom name for JNI_OnLoad #34
Comments
Sounds good. When you specify in CMake |
You're right fully flexible custom name isn't required. A static-custom name like, a At now, as a temporary workaround I added a step for a build.gradle (replace text in a file) to replace |
Small update from me. Maybe static-custom name is not enough. In my project I have separate library builded with Scapix ( |
To use Scapix (headers+lib) as a dependency: find_package(Scapix REQUIRED)
target_link_libraries(example PRIVATE scapix) It may be better to do it the other way around: your static library could use Here is a small example project, doing exactly that: Right now, you are supposed to call I will consider supporting separate |
Thanks a lot for these tips. I applied those changes to a project and I'm really enjoyed with final results. Both projects (library + application) looks clean and works properly. BTW. I see that with
Scapix could generate a something like that (in short, public static classes with prefixes for a namespaces):
In this way we don't need to match a package name. This feature will greatly improve integration of Scapix into relative big, existing projects like mine. At now I can use one matched package in my project, but in a future I would need a 2-3 more packages. Anyway after a first, working integration in Android part I can say that Scapix works really good! Thanks again! At now I just need to finish iOS integration part. |
Perhaps a better approach would be to generate each Java class in it's own source file, so they can all be public? |
This will be also a good solution. Yes, maybe even better than mine, however if I'm not wrong (just imagination, because I didn't looked at Scapix sources too much) it will require little more work to do. |
Hello, |
Added SCAPIX_CUSTOM_JNI_ONLOAD feature: By default Scapix generates JNI_OnLoad() function for target library. target_compile_definitions(scapix PUBLIC SCAPIX_CUSTOM_JNI_ONLOAD) #include <scapix/bridge/java/on_load.h>
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
// ... your additional JNI init code ...
return scapix_JNI_OnLoad(vm, reserved);
} |
Great, thanks a lot. I tested this stuff and it works without problems. It looks like this issue may be closed. We talked here about namespaces and private-package problem, but it may be better to shift that into another thread or just not start issue for that, because as I understand you agreed that this feature will be good and you will add support for it in future, so "official" ticket is not important too much. Namespaces handling (eg. as prefixes glued with underscores will be useful for other languages like a obj-c too). |
Opened a separate issue for generating Java classes public: |
Hello,
I'm not sure if this functionality doesn't exist in Scapix, but I couldn't find it, so thats why I write this message. In our project we have a lot of JNI code and we can't replace all of them by Scapix in an easy way, but we want to use Scapix for new screens. At this point I found a problem related to JNI_OnLoad. It would be nice to tell a Scapix to generate 'JNI_OnLoad' with a custom name and separate it to *.h and *.cpp file if custom name is provided eg:
With this feature we will be able to just execute 'customname_JNI_OnLoad' from our 'JNI_OnLoad'. What do you think about this feature?
Patryk,
The text was updated successfully, but these errors were encountered: