Skip to content

Commit

Permalink
Expose the target directory in cargo metadata
Browse files Browse the repository at this point in the history
Closes #4017
  • Loading branch information
sfackler committed May 10, 2017
1 parent 80f19a8 commit a367875
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cargo/ops/cargo_output_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fn metadata_no_deps(ws: &Workspace,
packages: ws.members().cloned().collect(),
workspace_members: ws.members().map(|pkg| pkg.package_id().clone()).collect(),
resolve: None,
target_directory: ws.target_dir().display().to_string(),
version: VERSION,
})
}
Expand All @@ -63,6 +64,7 @@ fn metadata_full(ws: &Workspace,
resolve: resolve,
root: ws.current_opt().map(|pkg| pkg.package_id().clone()),
}),
target_directory: ws.target_dir().display().to_string(),
version: VERSION,
})
}
Expand All @@ -72,6 +74,7 @@ pub struct ExportInfo {
packages: Vec<Package>,
workspace_members: Vec<PackageId>,
resolve: Option<MetadataResolve>,
target_directory: String,
version: u32,
}

Expand Down
8 changes: 8 additions & 0 deletions tests/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fn cargo_metadata_simple() {
],
"root": "foo 0.5.0 (path+file:[..]foo)"
},
"target_directory": "[..]foo[/]target",
"version": 1
}"#));
}
Expand Down Expand Up @@ -121,6 +122,7 @@ crate-type = ["lib", "staticlib"]
],
"root": "foo 0.5.0 (path+file:[..]foo)"
},
"target_directory": "[..]foo[/]target",
"version": 1
}"#));
}
Expand Down Expand Up @@ -269,6 +271,7 @@ fn cargo_metadata_with_deps_and_version() {
],
"root": "foo 0.5.0 (path+file:[..]foo)"
},
"target_directory": "[..]foo[/]target",
"version": 1
}"#));
}
Expand Down Expand Up @@ -329,6 +332,7 @@ name = "ex"
}
]
},
"target_directory": "[..]foo[/]target",
"version": 1
}"#));
}
Expand Down Expand Up @@ -390,6 +394,7 @@ crate-type = ["rlib", "dylib"]
}
]
},
"target_directory": "[..]foo[/]target",
"version": 1
}"#));
}
Expand Down Expand Up @@ -464,6 +469,7 @@ fn workspace_metadata() {
],
"root": null
},
"target_directory": "[..]foo[/]target",
"version": 1
}"#))
}
Expand Down Expand Up @@ -526,6 +532,7 @@ fn workspace_metadata_no_deps() {
],
"workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"],
"resolve": null,
"target_directory": "[..]foo[/]target",
"version": 1
}"#))
}
Expand Down Expand Up @@ -566,6 +573,7 @@ const MANIFEST_OUTPUT: &'static str=
}],
"workspace_members": [ "foo 0.5.0 (path+file:[..]foo)" ],
"resolve": null,
"target_directory": "[..]foo[/]target",
"version": 1
}"#;

Expand Down

0 comments on commit a367875

Please sign in to comment.