-
Notifications
You must be signed in to change notification settings - Fork 19
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
Support for cross compilation #2
Comments
Thank you for your attention to this project! |
I think that would be a great idea! Let me know if you need some help with it, at the very least I can commit to reviewing your code if that's helpful. My rust is quite rusty, so it's a good excuse to practice it a bit more. If you implement that trait I can work an example on how to hook it up to make a cross platform build for Android. |
I've just pushed a change be684f6 , but not published a version yet. You can check if it meets your need. Please give me some results, if it not works well, I'll update it. |
Thank you both so much for working on this! It's really greatly appreciated! 🙏 🙇 |
@ihciah @nguquen would it perhaps be possible for you to put together an example on how to implement the I made some attempts, but my rust knowledge is quite limited, and am running into the problem of "impl for type defined outside of crate.". Even some pointers in the right direction would be greatly appreciated. Apologies for the noob question. |
hi @hellais , here's what i'm using for
To support cross compilation, actually we also need other env vars like
|
First of all, really great work, thanks for putting this together!
I was wondering if you would be interested in accepting a patch to add support for running the go compilation step with cross compiler support.
My use case is that I would like to use rust2go to build a rust library that calls a go library that's then wrapped with JNI to be included inside of an Android application (yeah it's basically inception).
In order to achieve that I would need to be able to set certain environment variables (and possibly command line options) when the
go build
call is placed here: https://github.com/ihciah/rust2go/blob/master/rust2go/src/build.rs#L123.You can check this cmake file and Makefile to understand more in detail what kind of configuration is needed to cross compile a golang shared library to be included inside of an android application.
Effectively you need to set
GOOS
,GOARCH
,CC
,CXX
,CGO_CFLAGS
,CGO_LDFLAGS
and then add some extra parameters to the build command like:-tags linux
.I think the patch would not be too big, depending on how it's done. I see a few approaches for to doing it:
CARGO_TARGET_*
is set and extract from there the necessary things to map the rust specific targets into the golang syntax.I think 2 would be nicer in that it would make the whole thing work out of the box without requiring changes to support cross compilation, however it's not clear to me if these
CARGO_TARGET_*
are standards or if it's something specific to the mozilla rust-android-gradle.If you let me know which approach you think is best, I'm happy to draft a PR for it.
The text was updated successfully, but these errors were encountered: