Skip to content

Commit

Permalink
add a new command line flag --profile-dir [path]
Browse files Browse the repository at this point in the history
  • Loading branch information
ddefisher committed Mar 20, 2016
1 parent a4251c8 commit ddc96dc
Showing 1 changed file with 14 additions and 0 deletions.
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

0 comments on commit ddc96dc

Please sign in to comment.