From 868ca2a3b0ef6c59f9e81e099ec5519454cb35c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Mustoha?= Date: Fri, 9 Dec 2016 13:49:38 +0100 Subject: [PATCH] Use `android-rs-injected-glue` on Android --- Cargo.lock | 7 +++++++ ports/servo/Cargo.toml | 1 + ports/servo/main.rs | 15 +++++++++------ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e90dbb14e4f..7ccb3a82aed1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,6 +39,11 @@ name = "android_glue" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "android_injected_glue" +version = "0.2.1" +source = "git+https://github.com/mmatyas/android-rs-injected-glue#d3223d1273d0dafcf06d6a6405fedfffbf257300" + [[package]] name = "angle" version = "0.1.2" @@ -2377,6 +2382,7 @@ name = "servo" version = "0.0.1" dependencies = [ "android_glue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "android_injected_glue 0.2.1 (git+https://github.com/mmatyas/android-rs-injected-glue)", "backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "browserhtml 0.1.17 (git+https://github.com/browserhtml/browserhtml?branch=crate)", "compiletest_helper 0.0.1", @@ -3206,6 +3212,7 @@ dependencies = [ "checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" "checksum alloc-no-stdlib 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b21f6ad9c9957eb5d70c3dee16d31c092b3cab339628f821766b05e6833d72b8" "checksum android_glue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e2b80445d331077679dfc6f3014f3e9ab7083e588423d35041d3fc017198189" +"checksum android_injected_glue 0.2.1 (git+https://github.com/mmatyas/android-rs-injected-glue)" = "" "checksum angle 0.1.2 (git+https://github.com/servo/angle?branch=servo)" = "" "checksum app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "636ee56f12e31dbc11dc0a1ac6004f08b04e6e6595963716fc8130e90d4e04cf" "checksum arrayvec 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "80a137392e2e92ce7387c063d98a11f0d47115426c5f8759657af3c7b385c860" diff --git a/ports/servo/Cargo.toml b/ports/servo/Cargo.toml index 016824642b8d..d9ab8a459c9e 100644 --- a/ports/servo/Cargo.toml +++ b/ports/servo/Cargo.toml @@ -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"} diff --git a/ports/servo/main.rs b/ports/servo/main.rs index 228e4ec2447a..89bac711f53a 100644 --- a/ports/servo/main.rs +++ b/ports/servo/main.rs @@ -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; @@ -247,18 +249,19 @@ fn args() -> Vec { } -// 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; @@ -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);