-
Notifications
You must be signed in to change notification settings - Fork 109
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
Android glue #13
Merged
+1,922
−13,897
Merged
Android glue #13
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8e8b8f7
Make native-app-glue optional.
dvc94ch e9349a3
Link against libandroid.so
dvc94ch 52c80a6
Add some missing functions.
dvc94ch 77f5f3f
Remove unnecessary armv7 bindings.
dvc94ch 0e179c8
Android glue.
dvc94ch 4c0dc7b
Add android-build-tools.
dvc94ch 6b63fd1
Add cargo-apk.
dvc94ch af677c1
Add android-examples.
dvc94ch afc01d7
Remove native-app-glue support.
dvc94ch 21d1401
Update ci.
dvc94ch 36d81dc
Update README.
dvc94ch 371f6d4
Support test and doc commands.
dvc94ch a5c2576
Rename everything.
dvc94ch 49b3110
Add ndk_glue macro.
dvc94ch 3d8e2b7
Update cargo-subcommand.
dvc94ch e78acbb
Update README.
dvc94ch f0f79fa
Fix panic on exit.
dvc94ch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
[workspace] | ||
|
||
members = [ | ||
"android-ndk-sys", | ||
"android-ndk", | ||
"ndk", | ||
"ndk-build", | ||
"ndk-examples", | ||
"ndk-glue", | ||
"ndk-sys", | ||
"cargo-apk", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,62 @@ | ||
# `android-ndk`: Rust bindings of the Android NDK | ||
# Rust on Android | ||
|
||
[![Build Status](https://travis-ci.org/mb64/android-ndk-rs.svg?branch=master)](https://travis-ci.org/mb64/android-ndk-rs) | ||
[![Crates.io Status](https://meritbadge.herokuapp.com/android-ndk-sys)](https://crates.io/crates/android-ndk-sys) | ||
[![Docs.rs Status](https://docs.rs/android-ndk-sys/badge.svg)](https://docs.rs/android-ndk-sys) | ||
[![Crates.io Status](https://meritbadge.herokuapp.com/android-ndk)](https://crates.io/crates/android-ndk) | ||
[![Docs.rs Status](https://docs.rs/android-ndk/badge.svg)](https://docs.rs/android-ndk) | ||
- Raw FFI bindings to the NDK ![ndk-sys-docs][ndk-sys-badge] | ||
- Safe abstraction of the bindings ![ndk-docs][ndk-badge] | ||
- Startup code ![ndk-glue-docs][ndk-glue-badge] | ||
- Everything for building apk's ![ndk-build-docs][ndk-build-badge] | ||
- Build tool ![cargo-apk-docs][cargo-apk-badge] | ||
|
||
This is a work in progress at the moment. | ||
## Hello world | ||
`Cargo.toml` | ||
```toml | ||
[lib] | ||
crate-type = ["lib", "cdylib"] | ||
``` | ||
|
||
`android-ndk-sys` contains the raw FFI bindings, pre-generated from NDK r20, and `android-ndk` | ||
provides a safe API over it. | ||
`src/lib.rs` | ||
```rust | ||
#[cfg(target_os = "android")] | ||
ndk_glue::ndk_glue!(main); | ||
|
||
Other helpful crates for Android: | ||
pub fn main() { | ||
println!("hello world"); | ||
} | ||
``` | ||
|
||
* [`jni`](https://crates.io/crates/jni), JNI bindings for Rust | ||
* [`android_logger`](https://crates.io/crates/android_logger) and [`ndk-logger`](https://crates.io/crates/ndk-logger), | ||
Android backends for the `log` crate | ||
`src/main.rs` | ||
```rust | ||
fn main() { | ||
$crate::main(); | ||
} | ||
``` | ||
|
||
```sh | ||
cargo install cargo-apk | ||
cargo apk run | ||
``` | ||
|
||
## Logging and stdout | ||
Stdout is redirected to the android log api when using `ndk-glue`. Any logger that logs to | ||
stdout should therefore work. | ||
|
||
## JNI | ||
TODO: talk more about jni and add some examples | ||
|
||
- [`jni`](https://crates.io/crates/jni), JNI bindings for Rust | ||
|
||
## Winit and glutin | ||
TODO shameless plug | ||
|
||
## Flutter | ||
TODO shameless plug | ||
|
||
[ndk-sys-docs]: https://docs.rs/ndk-sys | ||
[ndk-sys-badge]: https://docs.rs/ndk-sys/badge.svg | ||
[ndk-docs]: https://docs.rs/ndk | ||
[ndk-badge]: https://docs.rs/ndk/badge.svg | ||
[ndk-glue-docs]: https://docs.rs/ndk-glue | ||
[ndk-badge]: https://docs.rs/ndk-glue/badge.svg | ||
[ndk-build-docs]: https://docs.rs/ndk-build | ||
[ndk-build-badge]: https://docs.rs/ndk-build/badge.svg | ||
[cargo-apk-docs]: https://docs.rs/cargo-apk | ||
[cargo-apk-badge]: https://docs.rs/cargo-apk/badge.svg |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, so yesterday I tried this, which didn't work:
You mention it needs to be cdylib, so I tried this.
I did some googling, and this gets rid of the
eh_personality
error:Implementing panic handler on a function wouldn't fix that error, though, so this readme leaves me kind of stumped :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for me:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rustflags env the way you set it gives me the same error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem seems to be that it tries to compile all crates as cdylib, when only the example needs to be cdylib. Trying to compile a proc-macro as cdylib is no good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also note that it'll crash in any case. we could add support to the ios-example and rename it to mobile-example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it is not making an apk at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into it tomorrow, need to sleep...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it still do that after I reverted the
cargo-rustc
hack?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still broken when using
--manifest-path
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the path returned from cargo-subcommand to the
Cargo.toml
is relative to thecurrent_dir
, but theaapt
command is executed from thetarget/{profile}/apk
dir. Should be fixed now