/// Embeds the manifest described by `manifest` by converting it to XML, /// then saving it to a file and passing the correct options to the linker /// on MSVC targets, or by building a static library and instructing Cargo /// to link the executable against it on GNU targets. pubfn embed_manifest(manifest: ManifestBuilder) -> Result<(), Error> { let out_dir = get_out_dir()?; let target = get_target()?; if matches!(target.os, TargetOs::WindowsMsvc) { let manifest_file = out_dir.join("manifest.xml");
write!(BufWriter::new(File::create(&manifest_file)?), "{}", manifest)?;
link_manifest_msvc(&manifest_file, &mut stdout().lock())
} else { let manifest_data = manifest.to_string();
link_manifest_gnu(manifest_data.as_bytes(), &out_dir, target.arch, &mut stdout().lock())
}
}
/// Directly embeds the manifest in the provided `file` by passing the correct /// options to the linker on MSVC targets, or by building a static library /// and instructing Cargo to link the executable against it on GNU targets. pubfn embed_manifest_file<P: AsRef<Path>>(file: P) -> Result<(), io::Error> { let out_dir = get_out_dir()?; let target = get_target()?; if matches!(target.os, TargetOs::WindowsMsvc) {
Ok(link_manifest_msvc(file.as_ref(), &mut stdout().lock())?)
} else { let manifest = fs::read(file.as_ref())?;
Ok(link_manifest_gnu(&manifest, &out_dir, target.arch, &mut stdout().lock())?)
}
}
// Create resource directories for type ID 24, name ID 1, language ID 1033.
obj.add_data(&resource_directory_table(1))?;
obj.add_data(&resource_directory_id_entry(24, 24, true))?;
obj.add_data(&resource_directory_table(1))?;
obj.add_data(&resource_directory_id_entry(1, 48, true))?;
obj.add_data(&resource_directory_table(1))?;
obj.add_data(&resource_directory_id_entry(1033, 72, false))?;
// Add resource data entry with relocated address. let address = obj.add_data(&resource_data_entry(88, manifest.len() as u32))?;
// Add the manifest data.
obj.add_data(manifest)?;
obj.align_to(8)?;
// Write manifest data relocation at the end of the section.
obj.add_relocation(address)?;
// Finish writing file and return the populated object data.
Ok(obj.finish()?.into_inner())
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.