build-manifest: handle rust-src being target-independent

This commit is contained in:
Pietro Albini 2020-09-25 15:36:16 +02:00
parent 73d9c24b3e
commit 0749ad02d0
No known key found for this signature in database
GPG key ID: 3E06ABE80BAAF19C

View file

@ -88,6 +88,11 @@ impl PkgType {
PkgType::Other(_) => true,
}
}
/// Whether this package is target-independent or not.
fn target_independent(&self) -> bool {
*self == PkgType::RustSrc
}
}
#[derive(Debug, Default, Clone)]
@ -198,15 +203,15 @@ impl Versions {
package: &PkgType,
target: &str,
) -> Result<String, Error> {
Ok(format!(
"{}-{}-{}.tar.gz",
package.tarball_component_name(),
self.package_version(package).with_context(|| format!(
"failed to get the package version for component {:?}",
package,
))?,
target
))
let component_name = package.tarball_component_name();
let version = self.package_version(package).with_context(|| {
format!("failed to get the package version for component {:?}", package,)
})?;
if package.target_independent() {
Ok(format!("{}-{}.tar.gz", component_name, version))
} else {
Ok(format!("{}-{}-{}.tar.gz", component_name, version, target))
}
}
pub(crate) fn package_version(&mut self, package: &PkgType) -> Result<String, Error> {