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 `--version` flag #11262

Merged
merged 1 commit into from Jun 29, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -35,6 +35,7 @@ use servo::Browser;
use servo::compositing::windowing::WindowEvent;
use servo::util::opts::{self, ArgumentParsingResult};
use servo::util::panicking::initiate_panic_hook;
use std::process;
use std::rc::Rc;

fn main() {
@@ -60,6 +61,11 @@ fn main() {
return servo::run_content_process(token)
}

if opts::get().is_printing_version {
println!("Servo {}{}", env!("CARGO_PKG_VERSION"), env!("GIT_INFO"));
process::exit(0);
}

let window = app::create_window(None);

// Our wrapper around `Browser` that also implements some
@@ -205,6 +205,9 @@ pub struct Opts {

// don't skip any backtraces on panic
pub full_backtraces: bool,

/// Print the version and exit.
pub is_printing_version: bool,
}

fn print_usage(app: &str, opts: &Options) {
@@ -527,6 +530,7 @@ pub fn default_opts() -> Opts {
render_api: DEFAULT_RENDER_API,
config_dir: None,
full_backtraces: false,
is_printing_version: false,
}
}

@@ -584,6 +588,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
opts.optopt("G", "graphics", "Select graphics backend (gl or es2)", "gl");
opts.optopt("", "config-dir",
"config directory following xdg spec on linux platform", "");
opts.optflag("v", "version", "Display servo version information");


let opt_match = match opts.parse(args) {
@@ -776,6 +781,8 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
_ => args_fail(&format!("error: graphics option must be gl or es2:")),
};

let is_printing_version = opt_match.opt_present("v") || opt_match.opt_present("version");

let opts = Opts {
is_running_problem_test: is_running_problem_test,
url: Some(url),
@@ -831,6 +838,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
use_msaa: debug_options.use_msaa,
config_dir: opt_match.opt_str("config-dir"),
full_backtraces: debug_options.full_backtraces,
is_printing_version: is_printing_version,
};

set_defaults(opts);
@@ -413,6 +413,22 @@ def build_env(self, gonk=False, hosts_file_path=None, target=None):

env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -W unused-extern-crates"

git_info = []
if os.path.isdir('.git'):
git_sha = subprocess.check_output([
'git', 'rev-parse', '--short', 'HEAD'
]).strip()
git_is_dirty = bool(subprocess.check_output([
'git', 'status', '--porcelain'
]).strip())

git_info.append('')
git_info.append(git_sha)
if git_is_dirty:
git_info.append('dirty')

env['GIT_INFO'] = '-'.join(git_info)

return env

def servo_crate(self):
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.