From 4306336a5b94125befe90cee4b3fa59720c542d7 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 26 Jul 2018 09:50:29 +0200 Subject: [PATCH] run_in_headless_android_emulator: add support for $HOST_FILE --- etc/run_in_headless_android_emulator.py | 10 ++++++++++ ports/servo/main.rs | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/etc/run_in_headless_android_emulator.py b/etc/run_in_headless_android_emulator.py index 32f8e18146f..af8034b204d 100755 --- a/etc/run_in_headless_android_emulator.py +++ b/etc/run_in_headless_android_emulator.py @@ -54,6 +54,7 @@ def main(avd_name, apk_path, *args): check_call(adb + ["install", "-r", apk_path]) args = list(args) write_user_stylesheets(adb, args) + write_hosts_file(adb) write_args(adb, args) check_call(adb + ["shell", "am start com.mozilla.servo/com.mozilla.servo.MainActivity"], @@ -143,6 +144,15 @@ def write_user_stylesheets(adb, args): check_call(adb + ["push", path, remote_path], stdout=sys.stderr) +def write_hosts_file(adb): + hosts_file = os.environ.get("HOST_FILE") + if hosts_file: + data_dir = "/sdcard/Android/data/com.mozilla.servo/files" + check_call(adb + ["shell", "mkdir -p %s" % data_dir]) + remote_path = data_dir + "/android_hosts" + check_call(adb + ["push", hosts_file, remote_path], stdout=sys.stderr) + + def forward_webdriver(adb, args): webdriver_port = extract_arg("--webdriver", args) if webdriver_port is not None: diff --git a/ports/servo/main.rs b/ports/servo/main.rs index b0db7926eb1..5060f87ed48 100644 --- a/ports/servo/main.rs +++ b/ports/servo/main.rs @@ -46,7 +46,6 @@ mod resources; use backtrace::Backtrace; use servo::Servo; use servo::compositing::windowing::WindowEvent; -#[cfg(target_os = "android")] use servo::config; use servo::config::opts::{self, ArgumentParsingResult, parse_url_or_filename}; use servo::config::servo_version; @@ -105,6 +104,12 @@ fn main() { resources::init(); + if cfg!(target_os = "android") && env::var_os("HOST_FILE").is_none() { + let mut path = config::basedir::default_config_dir(); + path.push("android_hosts"); + env::set_var("HOST_FILE", path); + } + // Parse the command line options and store them globally let opts_result = opts::from_cmdline_args(&*args());