1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
use cargo_shim::{ Profile, TargetKind }; use build::BuildArgs; use error::Error; pub fn command_build_or_check(build_args: BuildArgs, should_build: bool) -> Result<(), Error> { let project = build_args.load_project()?; let targets = project.target_or_select( |target| { target.kind == TargetKind::Lib || target.kind == TargetKind::CDyLib || target.kind == TargetKind::Bin })?; let config = project.aggregate_configuration( Profile::Main )?; for target in targets { if should_build { project.build( &config, target )?; } else { project.check( &config, target )?; } } Ok(()) } pub fn command_build(args: BuildArgs) -> Result<(), Error> { command_build_or_check(args, true) } pub fn command_check(args: BuildArgs) -> Result<(), Error> { command_build_or_check(args, false) }