Skip to content

Commit

Permalink
Use android-rs-injected-glue on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Dec 9, 2016
1 parent c3c086e commit 868ca2a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ports/servo/Cargo.toml
Expand Up @@ -54,3 +54,4 @@ sig = "0.1"
[target.'cfg(target_os = "android")'.dependencies]
libc = "0.2"
android_glue = "0.2"
android_injected_glue = {git = "https://github.com/mmatyas/android-rs-injected-glue"}
15 changes: 9 additions & 6 deletions ports/servo/main.rs
Expand Up @@ -20,6 +20,8 @@
#[cfg(target_os = "android")]
#[macro_use]
extern crate android_glue;
#[cfg(target_os = "android")]
extern crate android_injected_glue;
extern crate backtrace;
// The window backed by glutin
extern crate glutin_app as app;
Expand Down Expand Up @@ -247,18 +249,19 @@ fn args() -> Vec<String> {
}


// This extern definition ensures that the linker will not discard
// the static native lib bits, which are brought in from the NDK libraries
// we link in from build.rs.
#[cfg(target_os = "android")]
extern {
fn app_dummy() -> libc::c_void;
#[no_mangle]
#[inline(never)]
#[allow(non_snake_case)]
pub extern "C" fn android_main(app: *mut ()) {
android_injected_glue::android_main2(app as *mut _, move |_, _| { main() });
}


#[cfg(target_os = "android")]
mod android {
extern crate android_glue;
extern crate android_injected_glue;
extern crate libc;

use self::libc::c_int;
Expand All @@ -272,7 +275,7 @@ mod android {
redirect_output(STDERR_FILENO);
redirect_output(STDOUT_FILENO);

unsafe { super::app_dummy(); }
unsafe { android_injected_glue::ffi::app_dummy() };
}

struct FilePtr(*mut self::libc::FILE);
Expand Down

0 comments on commit 868ca2a

Please sign in to comment.