diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-04-03 03:26:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-03 03:26:50 +0200 |
| commit | 17f204feee7fe578930d56c231dad957c1b2d422 (patch) | |
| tree | 502e1e248058e6af611f21991642b2a2ba2314e1 | |
| parent | 4f0a791d5d54674a9384879be28322a4986167a4 (diff) | |
| parent | e992565857df86b8dde9365b7fa76cbfdbf283c3 (diff) | |
| download | rust-17f204feee7fe578930d56c231dad957c1b2d422.tar.gz rust-17f204feee7fe578930d56c231dad957c1b2d422.zip | |
Rollup merge of #70698 - nikomatsakis:x-py-json-output, r=Mark-Simulacrum
bootstrap: add `--json-output` for rust-analyzer Motivation is that this allows us to customize rust-analyzer's "cargo watch" integration to run x.py. You simply have to set the command to run to be `x.py --json-output` r? @Mark-Simulacrum -- feel free to make changes, this is quick and dirty for sure
| -rw-r--r-- | src/bootstrap/compile.rs | 6 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/flags.rs | 3 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index ad494b88b3a..5602c659138 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -911,7 +911,11 @@ pub fn stream_cargo( } // Instruct Cargo to give us json messages on stdout, critically leaving // stderr as piped so we can get those pretty colors. - let mut message_format = String::from("json-render-diagnostics"); + let mut message_format = if builder.config.json_output { + String::from("json") + } else { + String::from("json-render-diagnostics") + }; if let Some(s) = &builder.config.rustc_error_format { message_format.push_str(",json-diagnostic-"); message_format.push_str(s); diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 56164b74f30..133709421a5 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -48,6 +48,7 @@ pub struct Config { pub ignore_git: bool, pub exclude: Vec<PathBuf>, pub rustc_error_format: Option<String>, + pub json_output: bool, pub test_compare_mode: bool, pub llvm_libunwind: bool, @@ -415,6 +416,7 @@ impl Config { let mut config = Config::default_opts(); config.exclude = flags.exclude; config.rustc_error_format = flags.rustc_error_format; + config.json_output = flags.json_output; config.on_fail = flags.on_fail; config.stage = flags.stage; config.jobs = flags.jobs.map(threads_from_config); diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index eda26f7df1f..5d6e401d5b3 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -31,6 +31,7 @@ pub struct Flags { pub incremental: bool, pub exclude: Vec<PathBuf>, pub rustc_error_format: Option<String>, + pub json_output: bool, pub dry_run: bool, // This overrides the deny-warnings configuration option, @@ -156,6 +157,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`", "VALUE", ); opts.optopt("", "error-format", "rustc error format", "FORMAT"); + opts.optflag("", "json-output", "use message-format=json"); opts.optopt( "", "llvm-skip-rebuild", @@ -503,6 +505,7 @@ Arguments: dry_run: matches.opt_present("dry-run"), on_fail: matches.opt_str("on-fail"), rustc_error_format: matches.opt_str("error-format"), + json_output: matches.opt_present("json-output"), keep_stage: matches .opt_strs("keep-stage") .into_iter() |
