Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a new command line flag --profile-dir [path] #10087

Merged
merged 1 commit into from Mar 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions components/util/opts.rs
Expand Up @@ -14,6 +14,7 @@ use resource_files::set_resources_path;
use std::cmp;
use std::default::Default;
use std::env;
use std::fs;
use std::fs::File;
use std::io::{self, Read, Write};
use std::path::Path;
Expand Down Expand Up @@ -187,6 +188,9 @@ pub struct Opts {
/// True if WebRender should use multisample antialiasing.
pub use_msaa: bool,

/// Directory path for persistent session
pub profile_dir: Option<String>,

// Which rendering API to use.
pub render_api: RenderApi,
}
Expand Down Expand Up @@ -499,6 +503,7 @@ pub fn default_opts() -> Opts {
webrender_stats: false,
use_msaa: false,
render_api: DEFAULT_RENDER_API,
profile_dir: None,
}
}

Expand Down Expand Up @@ -544,6 +549,8 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
opts.optflag("b", "no-native-titlebar", "Do not use native titlebar");
opts.optflag("w", "webrender", "Use webrender backend");
opts.optopt("G", "graphics", "Select graphics backend (gl or es2)", "gl");
opts.optopt("", "profile-dir",
"optional directory path for user sessions", "");

let opt_match = match opts.parse(args) {
Ok(m) => m,
Expand All @@ -557,6 +564,12 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
process::exit(0);
};

if let Some(ref profile_dir) = opt_match.opt_str("profile-dir") {
if let Err(why) = fs::create_dir_all(profile_dir) {
error!("Couldn't create/open {:?}: {:?}", Path::new(profile_dir).to_string_lossy(), why);
}
}

// If this is the content process, we'll receive the real options over IPC. So just fill in
// some dummy options for now.
if let Some(content_process) = opt_match.opt_str("content-process") {
Expand Down Expand Up @@ -746,6 +759,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
use_webrender: use_webrender,
webrender_stats: debug_options.webrender_stats,
use_msaa: debug_options.use_msaa,
profile_dir: opt_match.opt_str("profile-dir"),
};

set_defaults(opts);
Expand Down