Skip to content
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

Native npm module node-sodium cross compiled to Android #880

Open
gardner opened this issue Apr 13, 2016 · 6 comments
Open

Native npm module node-sodium cross compiled to Android #880

gardner opened this issue Apr 13, 2016 · 6 comments

Comments

@gardner
Copy link

gardner commented Apr 13, 2016

What is the best approach for getting an npm module with native code cross compiled for use on Android?

We are trying to get the npm module node-sodium into the runtime for use within and Android application. The problem is when doing an npm install from the host machine and then compiling jxcore with the android-ndk the npm module is compiled for the host platform's architecture. (e.g. jxcore is compiled for ARM while the npm native code is compiled for x86)

Should we compile the library directly into the jxcore runtime and port the javascript to work from that level? Should we update the npm module to look for an ARCH environment variable and cross compile for Android? Does jxcore for android support shared libraries as such?

I have been having trouble finding a similar example except for leveldown which is why I started porting libsodium into the jxcore runtime. It would be good to hear from someone with higher level view of the architecture if this is the appropriate approach.

Thank you,
Gardner

@lamuertepeluda
Copy link

Have you tried the Emscripten port already?

I tried compiling the node-sodium directly in Termux app on Android by typing npm install sodium but I get the same compile that I get on the Mac. So perhaps there is a package issue too.

@gardner
Copy link
Author

gardner commented Apr 13, 2016

I have not tried libsodium.js port yet. Performance is a concern but getting it working would definitely be a great step forward. Thanks for that.

It would still be good to know the best practices for getting npm modules with native code cross compiled.

@lamuertepeluda
Copy link

I see. I'd also like to know how to do it, but remember that active development for jxcore has sadly been discontinued by Nubisa.

If we're lucky, node.js folks will eventually land an officially supported version in the future, which at the moment lacks. There is already some discussion about it on their repo.

@dominictarr
Copy link

@lamuertepeluda yes, we are currently using the emscripten port, but it's a lot slower.
We have to verify a lot of signatures, which is the most cpu expensive crypto operation,
so getting libsodium compiled would make a big difference to users.

@obastemur
Copy link
Member

Which engine you've been using with JXcore? If it was v8 3.14 you may follow leveldown-mobile approach without actually converting V8 API to JXcore macro.

@gardner
Copy link
Author

gardner commented Apr 13, 2016

I will continue down that path using v8. Thanks @obastemur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants