mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
refactor(toml): Move bin resolving up a level
This commit is contained in:
parent
72ee140548
commit
c699941d13
@ -73,17 +73,16 @@ pub(super) fn to_targets(
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or_else(|| anyhow::format_err!("manifest has no `package` (or `project`)"))?;
|
.ok_or_else(|| anyhow::format_err!("manifest has no `package` (or `project`)"))?;
|
||||||
|
|
||||||
targets.extend(to_bin_targets(
|
let bins = resolve_bins(
|
||||||
features,
|
|
||||||
resolved_toml.bin.as_ref(),
|
resolved_toml.bin.as_ref(),
|
||||||
package_root,
|
package_root,
|
||||||
package_name,
|
package_name,
|
||||||
edition,
|
edition,
|
||||||
package.autobins,
|
package.autobins,
|
||||||
warnings,
|
warnings,
|
||||||
errors,
|
|
||||||
has_lib,
|
has_lib,
|
||||||
)?);
|
)?;
|
||||||
|
targets.extend(to_bin_targets(features, &bins, edition, errors)?);
|
||||||
|
|
||||||
targets.extend(to_example_targets(
|
targets.extend(to_example_targets(
|
||||||
resolved_toml.example.as_ref(),
|
resolved_toml.example.as_ref(),
|
||||||
@ -325,27 +324,12 @@ fn resolve_bins(
|
|||||||
|
|
||||||
fn to_bin_targets(
|
fn to_bin_targets(
|
||||||
features: &Features,
|
features: &Features,
|
||||||
toml_bins: Option<&Vec<TomlBinTarget>>,
|
bins: &[TomlBinTarget],
|
||||||
package_root: &Path,
|
|
||||||
package_name: &str,
|
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
autodiscover: Option<bool>,
|
|
||||||
warnings: &mut Vec<String>,
|
|
||||||
errors: &mut Vec<String>,
|
errors: &mut Vec<String>,
|
||||||
has_lib: bool,
|
|
||||||
) -> CargoResult<Vec<Target>> {
|
) -> CargoResult<Vec<Target>> {
|
||||||
let bins = resolve_bins(
|
|
||||||
toml_bins,
|
|
||||||
package_root,
|
|
||||||
package_name,
|
|
||||||
edition,
|
|
||||||
autodiscover,
|
|
||||||
warnings,
|
|
||||||
has_lib,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// This loop performs basic checks on each of the TomlTarget in `bins`.
|
// This loop performs basic checks on each of the TomlTarget in `bins`.
|
||||||
for bin in &bins {
|
for bin in bins {
|
||||||
// For each binary, check if the `filename` parameter is populated. If it is,
|
// For each binary, check if the `filename` parameter is populated. If it is,
|
||||||
// check if the corresponding cargo feature has been activated.
|
// check if the corresponding cargo feature has been activated.
|
||||||
if bin.filename.is_some() {
|
if bin.filename.is_some() {
|
||||||
@ -377,7 +361,7 @@ fn to_bin_targets(
|
|||||||
validate_unique_names(&bins, "binary")?;
|
validate_unique_names(&bins, "binary")?;
|
||||||
|
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
for bin in &bins {
|
for bin in bins {
|
||||||
let path = bin.path.clone().expect("previously resolved").0;
|
let path = bin.path.clone().expect("previously resolved").0;
|
||||||
let mut target = Target::bin_target(
|
let mut target = Target::bin_target(
|
||||||
name_or_panic(bin),
|
name_or_panic(bin),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user