true
})
}).filter_map(|(id, _)| match bcx.get_package(id) {
- Ok(pkg) => pkg.targets().iter().find(|t| t.is_lib()).map(|t| {
+ Ok(pkg) => pkg.lib_target().map(|t| {
let mode = check_or_build_mode(&unit.mode, t);
let unit = new_unit(bcx, pkg, t, profile_for, unit.kind.for_target(t), mode);
Ok((unit, profile_for))
let mut ret = Vec::new();
for dep in deps {
let dep = dep?;
- let lib = match dep.targets().iter().find(|t| t.is_lib()) {
+ let lib = match dep.lib_target() {
Some(lib) => lib,
None => continue,
};
pub fn targets(&self) -> &[Target] {
self.manifest.targets()
}
+ /// Get the library target for the package
+ pub fn lib_target(&self) -> Option<&Target> {
+ self.targets().iter().find(|t| t.is_lib())
+ }
/// Get the current package version
pub fn version(&self) -> &Version {
self.package_id().version()
proposals.extend(default_units);
if build_config.mode == CompileMode::Test {
// Include the lib as it will be required for doctests.
- if let Some(t) = pkg.targets().iter().find(|t| t.is_lib() && t.doctested()) {
- proposals.push((new_unit(pkg, t, CompileMode::Build), false));
+ match pkg.lib_target() {
+ Some(t) if t.doctested() => {
+ proposals.push((new_unit(pkg, t, CompileMode::Build), false));
+ }
+ _ => {}
}
}
}
ref benches,
} => {
if lib {
- if let Some(target) = pkg.targets().iter().find(|t| t.is_lib()) {
+ if let Some(target) = pkg.lib_target() {
proposals.push((new_unit(pkg, target, build_config.mode), false));
} else if !all_targets {
bail!("no library targets found")