mirror of
https://github.com/servo/servo.git
synced 2025-06-20 15:18:58 +01:00
Auto merge of #11262 - campaul:add_version_flag, r=Manishearth
Add `--version` flag - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy --faster` does not report any errors - [X] These changes fix #11241 (github issue number if applicable). Either: - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ Not 100% sure of a good way to test this, so I'm submitting as is for feedback. Manually testing it appears to work fine. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11262) <!-- Reviewable:end -->
This commit is contained in:
commit
5478e605ae
3 changed files with 30 additions and 0 deletions
|
@ -40,6 +40,7 @@ use servo::Browser;
|
||||||
use servo::compositing::windowing::WindowEvent;
|
use servo::compositing::windowing::WindowEvent;
|
||||||
use servo::util::opts::{self, ArgumentParsingResult};
|
use servo::util::opts::{self, ArgumentParsingResult};
|
||||||
use servo::util::panicking::initiate_panic_hook;
|
use servo::util::panicking::initiate_panic_hook;
|
||||||
|
use std::process;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub mod platform {
|
pub mod platform {
|
||||||
|
@ -102,6 +103,11 @@ fn main() {
|
||||||
return servo::run_content_process(token)
|
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);
|
let window = app::create_window(None);
|
||||||
|
|
||||||
// Our wrapper around `Browser` that also implements some
|
// Our wrapper around `Browser` that also implements some
|
||||||
|
|
|
@ -202,6 +202,9 @@ pub struct Opts {
|
||||||
|
|
||||||
// don't skip any backtraces on panic
|
// don't skip any backtraces on panic
|
||||||
pub full_backtraces: bool,
|
pub full_backtraces: bool,
|
||||||
|
|
||||||
|
/// Print the version and exit.
|
||||||
|
pub is_printing_version: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_usage(app: &str, opts: &Options) {
|
fn print_usage(app: &str, opts: &Options) {
|
||||||
|
@ -507,6 +510,7 @@ pub fn default_opts() -> Opts {
|
||||||
render_api: DEFAULT_RENDER_API,
|
render_api: DEFAULT_RENDER_API,
|
||||||
config_dir: None,
|
config_dir: None,
|
||||||
full_backtraces: false,
|
full_backtraces: false,
|
||||||
|
is_printing_version: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,6 +568,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
opts.optopt("G", "graphics", "Select graphics backend (gl or es2)", "gl");
|
opts.optopt("G", "graphics", "Select graphics backend (gl or es2)", "gl");
|
||||||
opts.optopt("", "config-dir",
|
opts.optopt("", "config-dir",
|
||||||
"config directory following xdg spec on linux platform", "");
|
"config directory following xdg spec on linux platform", "");
|
||||||
|
opts.optflag("v", "version", "Display servo version information");
|
||||||
|
|
||||||
|
|
||||||
let opt_match = match opts.parse(args) {
|
let opt_match = match opts.parse(args) {
|
||||||
|
@ -753,6 +758,8 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
_ => args_fail(&format!("error: graphics option must be gl or es2:")),
|
_ => 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 {
|
let opts = Opts {
|
||||||
is_running_problem_test: is_running_problem_test,
|
is_running_problem_test: is_running_problem_test,
|
||||||
url: Some(url),
|
url: Some(url),
|
||||||
|
@ -807,6 +814,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
use_msaa: debug_options.use_msaa,
|
use_msaa: debug_options.use_msaa,
|
||||||
config_dir: opt_match.opt_str("config-dir"),
|
config_dir: opt_match.opt_str("config-dir"),
|
||||||
full_backtraces: debug_options.full_backtraces,
|
full_backtraces: debug_options.full_backtraces,
|
||||||
|
is_printing_version: is_printing_version,
|
||||||
};
|
};
|
||||||
|
|
||||||
set_defaults(opts);
|
set_defaults(opts);
|
||||||
|
|
|
@ -374,6 +374,22 @@ class CommandBase(object):
|
||||||
|
|
||||||
env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -W unused-extern-crates"
|
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
|
return env
|
||||||
|
|
||||||
def servo_crate(self):
|
def servo_crate(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue