pub fn vendor_sign_zbi(
    outdir: impl AsRef<Path>,
    signing_config: &ZbiSigningScript,
    zbi: impl AsRef<Path>,
) -> Result<PathBuf> {
    // The resultant file path
    let signed_path = outdir.as_ref().join("fuchsia.zbi");

    // The parameters of the script that are required:
    let mut args = Vec::new();
    args.push("-z".to_string());
    args.push(zbi.as_ref().path_to_string()?);
    args.push("-o".to_string());
    args.push(signed_path.path_to_string()?);

    // If the script config defines extra arguments, add them:
    args.extend_from_slice(&signing_config.extra_arguments[..]);

    let output = Command::new(&signing_config.tool)
        .args(&args)
        .output()
        .context(format!("Failed to run the vendor tool: {}", signing_config.tool.display()))?;

    // The tool ran, but may have returned an error.
    if output.status.success() {
        Ok(signed_path)
    } else {
        Err(anyhow!(
            "Vendor tool returned an error: {}\n{}",
            output.status,
            String::from_utf8_lossy(output.stderr.as_slice())
        ))
    }
}
/// If the board requires the zbi to be post-processed to make it bootable by
/// the bootloaders, then perform that task here.
If the board requires the zbi to be post-processed to make it bootable by
the bootloaders, then perform that task here.
If the board requires the zbi to be post - processed to make it bootable by the bootloaders then perform that task here .
pub fn vendor_sign_zbi(
    outdir: impl AsRef<Path>,
    signing_config: &ZbiSigningScript,
    zbi: impl AsRef<Path>,
) -> Result<PathBuf> {
    // The resultant file path
    let signed_path = outdir.as_ref().join("fuchsia.zbi");
    // The parameters of the script that are required:
    let mut args = Vec::new();
    args.push("-z".to_string());
    args.push(zbi.as_ref().path_to_string()?);
    args.push("-o".to_string());
    args.push(signed_path.path_to_string()?);
    // If the script config defines extra arguments, add them:
    args.extend_from_slice(&signing_config.extra_arguments[..]);
    let output = Command::new(&signing_config.tool)
        .args(&args)
        .output()
        .context(format!("Failed to run the vendor tool: {}", signing_config.tool.display()))?;
    // The tool ran, but may have returned an error.
    if output.status.success() {
        Ok(signed_path)
    } else {
        Err(anyhow!(
            "Vendor tool returned an error: {}\n{}",
            output.status,
            String::from_utf8_lossy(output.stderr.as_slice())
        ))
    }
}
pub fn vendor_sign_zbi ( outdir : impl AsRef < Path > , signing_config : & ZbiSigningScript , zbi : impl AsRef < Path > , ) -> Result < PathBuf > { // The resultant file path let signed_path = outdir . as_ref ( ) . join ( " " ) ; // The parameters of the script that are required: let mut args = Vec :: new ( ) ; args . push ( " " . to_string ( ) ) ; args . push ( zbi . as_ref ( ) . path_to_string ( ) ? ) ; args . push ( " " . to_string ( ) ) ; args . push ( signed_path . path_to_string ( ) ? ) ; // If the script config defines extra arguments, add them: args . extend_from_slice ( & signing_config . extra_arguments [ .. ] ) ; let output = Command :: new ( & signing_config . tool ) . args ( & args ) . output ( ) . context ( format ! ( " " signing_config tool display ( ) ) ) ? ; // The tool ran, but may have returned an error. if output . status . success ( ) { Ok ( signed_path ) } else { Err ( anyhow ! ( " \n " output status String from_utf8_lossy ( output stderr as_slice ( ) ) ) ) } }
If the board requires the zbi to be post-processed to make it bootable by
the bootloaders, then perform that task here.
If the board requires the zbi to be post - processed to make it bootable by the bootloaders then perform that task here .
outdir
impl AsRef<Path>
signing_config
&ZbiSigningScript
zbi
impl AsRef<Path>
outdir
impl AsRef<Path>
signing_config
&ZbiSigningScript
zbi
impl AsRef<Path>