-
Notifications
You must be signed in to change notification settings - Fork 113
The apk builder is now a Cargo subcommand #75
Conversation
My initial idea to inject code was to build a file that would contain: include!("/path/to/main.rs");
// injected code
pub extern fn android_main() { ... } However this doesn't work in practice because
|
Thinking about it, I think the best way is in fact to rework the way the glue works. The glue would be split in two parts:
The former would query stuff from the latter through unmangled symbols. This way we are guaranteed that it will work every time. |
#rust-internals told me that plugins couldn't inject code. I'm going to try using traditional object files and linking, but I'm a bit dubious seeing how complex it was the last time I tried. |
Things should work fine in theory, but I'm going to test it properly tomorrow. |
Awesome! This sounds like a pretty sweet subcommand. Let me know if there's anything Cargo can do to make this easier!
In Cargo we'd actually love to add a whitelisted area of
I might recommend directly linking to the |
Sure. The advantage of using
That's what I wanted to do initially. However I think cargo itself is too annoying to build on Windows right now because you need to have a C compiler, cmake, openssl, and maybe others. If cargo-apk depends on cargo, then cargo-apk will be annoying to build as well. |
Yeah there's definitely some parts of Cargo that could be split out, like the configuration, errors, etc. Note though that OpenSSL isn't required on Windows, just cmake + a C compiler. |
After the fixes I just pushed, it is now possible to do:
And the package works (and shows a black screen). Adding |
Got vulkano's triangle example running after a few tweaks (the few tweaks being necessary because the example itself is badly written). |
Sweet. |
I'm going to merge this since this code is already better than the old one, and Servo has their own fork of this repo. I don't think I'm going to break anyone's workflow, since the apk-builder is usually part of a git submodule and not a Cargo dependency. Last commit pre-rework is 8aa355a if anyone wants to jump back to it. |
Turns the apk-builder into
cargo-apk
, which provides thecargo apk
Cargo subcommand.Using it will:
android-artifacts
directory insidetarget
.android_native_glue
for each platform.android_main
call Rust'smain
.ant
.To do:
CargoApk.toml
file that can indicate various information about the package..cargo/config
file to find out the path to the Android SDK and NDK.cargo apk install
that would invokeadb
.The idea is that it should now be much simpler to build an apk by just running
cargo install cargo-apk
followed withcargo apk
, without having to modify your source code or anything fancy.You would be able to configure your build with a
CargoApk.toml
file whose content remains to be determined. Another advantage is that the build directory wouldn't be destroyed, making it possible to easily tweak and debug builds.The setup would also be greatly simplified by just having to install the NDK, the SDK, and a compatible rustc thanks to rustup. An NDK standalone toolchain would no longer be needed.
cc @ozkriff @larsbergstrom (@brson and @alexcrichton maybe as well?)