From 928351e52dca0769d896850c9a6cb1fa7a51f3d1 Mon Sep 17 00:00:00 2001 From: Lars Bergstrom Date: Fri, 21 Mar 2014 11:44:44 -0500 Subject: [PATCH 1/2] Produce dylib and rlib --- js.rc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js.rc b/js.rc index 9e71b117f..65d0724d3 100644 --- a/js.rc +++ b/js.rc @@ -4,6 +4,8 @@ #[crate_id = "github.com/mozilla-servo/rust-mozjs#js:0.1"]; #[crate_type = "lib"]; +#[crate_type = "dylib"]; +#[crate_type = "rlib"]; #[feature(globs, managed_boxes)]; From 4da979f44de0bbd3452e2fbd4fe4240841825bd9 Mon Sep 17 00:00:00 2001 From: Lars Bergstrom Date: Tue, 1 Apr 2014 11:13:40 -0500 Subject: [PATCH 2/2] Support for Android --- Makefile.in | 2 +- glue.rs | 8 ++++++++ js.rc | 2 +- linkhack.rs | 8 +++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile.in b/Makefile.in index bf2b9ee73..2f7112820 100644 --- a/Makefile.in +++ b/Makefile.in @@ -33,4 +33,4 @@ check: js-test .PHONY: clean clean: - rm -f js-test *.o *.a *.so *.dylib *.dll *.dummy + rm -f js-test *.o *.a *.so *.dylib *.rlib *.dll *.dummy diff --git a/glue.rs b/glue.rs index 127e87a1c..f8d9119ae 100644 --- a/glue.rs +++ b/glue.rs @@ -51,7 +51,15 @@ pub struct ProxyTraps { trace: Option } +#[cfg(not(target_os = "android"))] #[link(name = "jsglue")] +extern { } + + +#[cfg(target_os = "android")] +#[link_args = "-ljsglue -lstdc++ -lgcc"] +extern { } + extern { // FIXME: Couldn't run on rust_stack until rust issue #6470 fixed. diff --git a/js.rc b/js.rc index 65d0724d3..94403b900 100644 --- a/js.rc +++ b/js.rc @@ -7,7 +7,7 @@ #[crate_type = "dylib"]; #[crate_type = "rlib"]; -#[feature(globs, managed_boxes)]; +#[feature(globs, link_args, managed_boxes)]; #[allow(non_uppercase_statics, non_camel_case_types)]; diff --git a/linkhack.rs b/linkhack.rs index 18934988b..17e7c3692 100644 --- a/linkhack.rs +++ b/linkhack.rs @@ -17,11 +17,13 @@ extern { } #[link(name = "z")] extern { } -//Avoid hard linking with stdc++ in android ndk cross toolchain +// Avoid hard linking with stdc++ in android ndk cross toolchain so that +// the ELF header will have an entry for libstdc++ and we will know to +// open it explicitly. //It is hard to find location of android system libs in this rust source file //and also we need to size down for mobile app packaging #[cfg(target_os = "android")] -#[link(name = "js_static")] -#[link(name = "stdc++")] +#[link(name = "mozjs")] +#[link_args="-lstdc++"] #[link(name = "z")] extern { }