servo: Merge #14528 - Add C++ runtime shared object to the Android APK (from mmatyas:android_cppruntime); r=larsbergstrom
authorMátyás Mustoha <>
Tue, 13 Dec 2016 13:35:25 -0800
changeset 478496 d08ba3ef73749a1e7362f9826522585f13c071f9
parent 478495 0b360afbefa1804d88b51a7046a48d9d50971175
child 478497 92646471f722ff59c5664c03324f17a40c6fc6b1
push id44079
push dateSat, 04 Feb 2017 00:14:49 +0000
servo: Merge #14528 - Add C++ runtime shared object to the Android APK (from mmatyas:android_cppruntime); r=larsbergstrom <!-- Please describe your changes on the following line: --> At the moment, the Android port requires `` to run -- this patch adds the file to the generated APK. Part of #13154. If you know a cleaner way to solve this issue, feel free to share it! Static linking didn't work, see the related issue. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: Source-Revision: 91a223093368be339ad00f42df4214ac36e1be6e
--- a/servo/support/android/build-apk/src/
+++ b/servo/support/android/build-apk/src/
@@ -12,31 +12,39 @@ use std::path::{Path, PathBuf};
 use std::process;
 use std::process::{Command, Stdio};
 use walkdir::WalkDir;
 fn main() {
     let (args, passthrough) = parse_arguments();
     // Find all the native shared libraries that exist in the target directory.
-    let native_shared_libs = find_native_libs(&args);
+    let mut native_shared_libs = find_native_libs(&args);
     // Get the SDK path from the ANDROID_HOME env.
     let sdk_path = env::var("ANDROID_HOME").ok().expect("Please set the ANDROID_HOME environment variable");
     let sdk_path = Path::new(&sdk_path);
     // Get the NDK path from NDK_HOME env.
     let ndk_path = env::var("NDK_HOME").ok().expect("Please set the NDK_HOME environment variable");
     let ndk_path = Path::new(&ndk_path);
     // Get the target android platform from ANDROID_PLATFORM env. Expecting "android-{version}"
     let android_platform = env::var("ANDROID_PLATFORM")
         .expect("Please set the ANDROID_PLATFORM environment variable");
+    // Add the C++ runtime .so
+    {
+        let libcpp_base_path = ndk_path.join("sources").join("cxx-stl").join("llvm-libc++").join("libs");
+        let libcpp_filename = "";
+        let libcpp_path = libcpp_base_path.join("armeabi").join(libcpp_filename);
+        native_shared_libs.insert(libcpp_filename.to_string(), libcpp_path);
+    }
     // Get the standalone NDK path from NDK_STANDALONE env.
     //  let standalone_path = env::var("NDK_STANDALONE").ok().unwrap_or("/opt/ndk_standalone".to_string());
     //  let standalone_path = Path::new(&standalone_path);
     let debug = passthrough.contains(&"-d".to_string());
     // Set the build directory that will contain all the necessary files to create the apk
     let directory = args.root_path.join("support").join("android").join("apk");