mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
fixed #5602, expose cached build script output in json output
This commit is contained in:
parent
9f097787b0
commit
f101d88ebd
@ -365,6 +365,22 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
|
||||
BuildOutput::parse_file(&output_file, &pkg_name, &prev_root_output, &root_output)?
|
||||
}
|
||||
};
|
||||
|
||||
if json_messages {
|
||||
let library_paths = output
|
||||
.library_paths
|
||||
.iter()
|
||||
.map(|l| l.display().to_string())
|
||||
.collect::<Vec<_>>();
|
||||
machine_message::emit(&machine_message::BuildScript {
|
||||
package_id: &id,
|
||||
linked_libs: &output.library_links,
|
||||
linked_paths: &library_paths,
|
||||
cfgs: &output.cfgs,
|
||||
env: &output.env,
|
||||
});
|
||||
}
|
||||
|
||||
build_state.insert(id, kind, output);
|
||||
Ok(())
|
||||
});
|
||||
|
@ -3976,11 +3976,13 @@ fn compiler_json_error_format() {
|
||||
name = "foo"
|
||||
version = "0.5.0"
|
||||
authors = ["wycats@example.com"]
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies.bar]
|
||||
path = "bar"
|
||||
"#,
|
||||
)
|
||||
.file("build.rs", "fn main() { println!(\"cargo:rustc-cfg=xyz\") }")
|
||||
.file("src/main.rs", "fn main() { let unused = 92; }")
|
||||
.file(
|
||||
"bar/Cargo.toml",
|
||||
@ -4035,6 +4037,36 @@ fn compiler_json_error_format() {
|
||||
"fresh": false
|
||||
}
|
||||
|
||||
{
|
||||
"reason":"compiler-artifact",
|
||||
"package_id":"foo 0.5.0 ([..])",
|
||||
"target":{
|
||||
"kind":["custom-build"],
|
||||
"crate_types":["bin"],
|
||||
"name":"build-script-build",
|
||||
"src_path":"[..]build.rs"
|
||||
},
|
||||
"profile": {
|
||||
"debug_assertions": true,
|
||||
"debuginfo": 2,
|
||||
"opt_level": "0",
|
||||
"overflow_checks": true,
|
||||
"test": false
|
||||
},
|
||||
"features": [],
|
||||
"filenames": "{...}",
|
||||
"fresh": false
|
||||
}
|
||||
|
||||
{
|
||||
"reason":"build-script-executed",
|
||||
"package_id":"foo 0.5.0 ([..])",
|
||||
"linked_libs":[],
|
||||
"linked_paths":[],
|
||||
"env":[],
|
||||
"cfgs":["xyz"]
|
||||
}
|
||||
|
||||
{
|
||||
"reason":"compiler-message",
|
||||
"package_id":"foo 0.5.0 ([..])",
|
||||
@ -4080,6 +4112,27 @@ fn compiler_json_error_format() {
|
||||
.arg("json"),
|
||||
execs().with_status(0).with_json(
|
||||
r#"
|
||||
{
|
||||
"reason":"compiler-artifact",
|
||||
"package_id":"foo 0.5.0 ([..])",
|
||||
"target":{
|
||||
"kind":["custom-build"],
|
||||
"crate_types":["bin"],
|
||||
"name":"build-script-build",
|
||||
"src_path":"[..]build.rs"
|
||||
},
|
||||
"profile": {
|
||||
"debug_assertions": true,
|
||||
"debuginfo": 2,
|
||||
"opt_level": "0",
|
||||
"overflow_checks": true,
|
||||
"test": false
|
||||
},
|
||||
"features": [],
|
||||
"filenames": "{...}",
|
||||
"fresh": true
|
||||
}
|
||||
|
||||
{
|
||||
"reason":"compiler-artifact",
|
||||
"profile": {
|
||||
@ -4101,6 +4154,15 @@ fn compiler_json_error_format() {
|
||||
"fresh": true
|
||||
}
|
||||
|
||||
{
|
||||
"reason":"build-script-executed",
|
||||
"package_id":"foo 0.5.0 ([..])",
|
||||
"linked_libs":[],
|
||||
"linked_paths":[],
|
||||
"env":[],
|
||||
"cfgs":["xyz"]
|
||||
}
|
||||
|
||||
{
|
||||
"reason":"compiler-artifact",
|
||||
"package_id":"foo 0.5.0 ([..])",
|
||||
|
Loading…
x
Reference in New Issue
Block a user