Add ability to explicitly set static resources path, used by cef-linux.

This commit is contained in:
Glenn Watson 2015-01-05 13:25:13 +10:00
parent 7800d98728
commit cf047d6cef
3 changed files with 36 additions and 13 deletions

View file

@ -4,6 +4,7 @@
use std::io::{File, IoResult};
use std::path::Path;
use opts;
#[cfg(not(target_os = "android"))]
use std::io::fs::PathExtensions;
@ -17,20 +18,25 @@ pub fn resources_dir_path() -> Path {
#[cfg(not(target_os = "android"))]
pub fn resources_dir_path() -> Path {
// FIXME: Find a way to not rely on the executable being
// under `<servo source>/components/servo/target`
// or `<servo source>/components/servo/target/release`.
let mut path = os::self_exe_path().expect("can't get exe path");
path.pop();
path.pop();
path.pop();
path.push("resources");
if !path.is_dir() { // self_exe_path() is probably in .../target/release
path.pop();
path.pop();
path.push("resources");
match opts::get().resources_path {
Some(ref path) => Path::new(path),
None => {
// FIXME: Find a way to not rely on the executable being
// under `<servo source>/components/servo/target`
// or `<servo source>/components/servo/target/release`.
let mut path = os::self_exe_path().expect("can't get exe path");
path.pop();
path.pop();
path.pop();
path.push("resources");
if !path.is_dir() { // self_exe_path() is probably in .../target/release
path.pop();
path.pop();
path.push("resources");
}
path
}
}
path
}