mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Add ability to explicitly set static resources path, used by cef-linux.
This commit is contained in:
parent
7800d98728
commit
cf047d6cef
3 changed files with 36 additions and 13 deletions
|
@ -113,6 +113,9 @@ pub struct Opts {
|
|||
pub validate_display_list_geometry: bool,
|
||||
|
||||
pub render_api: RenderApi,
|
||||
|
||||
/// A specific path to find required resources (such as user-agent.css).
|
||||
pub resources_path: Option<String>,
|
||||
}
|
||||
|
||||
fn print_usage(app: &str, opts: &[getopts::OptGroup]) {
|
||||
|
@ -180,6 +183,7 @@ pub fn default_opts() -> Opts {
|
|||
validate_display_list_geometry: false,
|
||||
profile_tasks: false,
|
||||
render_api: RenderApi::OpenGL,
|
||||
resources_path: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,6 +212,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
|||
getopts::optopt("Z", "debug", "A comma-separated string of debug options. Pass help to show available options.", ""),
|
||||
getopts::optflag("h", "help", "Print this message"),
|
||||
getopts::optopt("r", "render-api", "Set the rendering API to use", "gl|mesa"),
|
||||
getopts::optopt("", "resources-path", "Path to find static resources", "/home/servo/resources"),
|
||||
);
|
||||
|
||||
let opt_match = match getopts::getopts(args, opts.as_slice()) {
|
||||
|
@ -332,6 +337,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
|||
dump_flow_tree: debug_options.contains(&"dump-flow-tree"),
|
||||
validate_display_list_geometry: debug_options.contains(&"validate-display-list-geometry"),
|
||||
render_api: render_api,
|
||||
resources_path: opt_match.opt_str("resources-path"),
|
||||
};
|
||||
|
||||
set_opts(opts);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,6 +43,16 @@ static CEF_API_HASH_PLATFORM: &'static [u8] = b"6813214accbf2ebfb6bdcf8d00654650
|
|||
#[cfg(target_os="linux")]
|
||||
static CEF_API_HASH_PLATFORM: &'static [u8] = b"2bc564c3871965ef3a2531b528bda3e17fa17a6d\0";
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
fn resources_path() -> Option<String> {
|
||||
Some("../../servo/resources".into_string())
|
||||
}
|
||||
|
||||
#[cfg(not(target_os="linux"))]
|
||||
fn resources_path() -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
|
||||
settings: *mut cef_settings_t,
|
||||
|
@ -102,6 +112,7 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
|
|||
dump_flow_tree: false,
|
||||
validate_display_list_geometry: false,
|
||||
render_api: RenderApi::OpenGL,
|
||||
resources_path: resources_path(),
|
||||
});
|
||||
|
||||
return 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue