MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / package_aot_artifacts

Function package_aot_artifacts

xtask/src/main.rs:8866–8940  ·  view source on GitHub ↗
(
    target: &str,
    outputs: &BuildOutputs,
    sources: &SourcesManifest,
)

Source from the content-addressed store, hash-verified

8864}
8865
8866fn package_aot_artifacts(
8867 target: &str,
8868 outputs: &BuildOutputs,
8869 sources: &SourcesManifest,
8870) -> Result<()> {
8871 let source_dir = Path::new("assets/wasix-build/build/aot").join(target);
8872 if !source_dir.exists() {
8873 bail!(
8874 "AOT source directory {} is missing; run `cargo run -p xtask -- assets aot --target-triple {target}` before packaging",
8875 source_dir.display()
8876 );
8877 }
8878
8879 let artifacts_dir = generated_aot_dir(target);
8880 if artifacts_dir.exists() {
8881 fs::remove_dir_all(&artifacts_dir)
8882 .with_context(|| format!("remove {}", artifacts_dir.display()))?;
8883 }
8884 fs::create_dir_all(&artifacts_dir)
8885 .with_context(|| format!("create {}", artifacts_dir.display()))?;
8886
8887 let mut manifest_artifacts = Vec::new();
8888 for module in &outputs.modules {
8889 let name = module.name.as_str();
8890 let file = module.aot_file.as_str();
8891 let source = source_dir.join(file);
8892 if !source.exists() {
8893 bail!(
8894 "missing AOT artifact {}; run AOT generation for target {target} before packaging",
8895 source.display()
8896 );
8897 }
8898 let destination = artifacts_dir.join(file);
8899 copy_file(&source, &destination)?;
8900 let raw_artifact = decode_zstd_file(&destination)
8901 .with_context(|| format!("decode AOT artifact {}", destination.display()))?;
8902 let module_sha256 = outputs
8903 .modules
8904 .iter()
8905 .find(|module| module.name == name)
8906 .map(|module| sha256_file(&module.path))
8907 .transpose()?
8908 .ok_or_else(|| anyhow!("missing build output module {name} for AOT manifest"))?;
8909 manifest_artifacts.push(AotManifestArtifact {
8910 name: name.to_owned(),
8911 path: file.to_owned(),
8912 sha256: sha256_file(&destination)?,
8913 raw_sha256: sha256_bytes(&raw_artifact),
8914 raw_size: raw_artifact.len() as u64,
8915 module_sha256,
8916 compressed: true,
8917 });
8918 }
8919 ensure!(
8920 !manifest_artifacts.is_empty(),
8921 "AOT packaging produced an empty manifest for {target}"
8922 );
8923

Callers 3

release_build_assetsFunction · 0.85
package_aot_onlyFunction · 0.85

Calls 9

generated_aot_dirFunction · 0.85
copy_fileFunction · 0.85
decode_zstd_fileFunction · 0.85
sha256_bytesFunction · 0.85
iterMethod · 0.80
pushMethod · 0.80
lenMethod · 0.80
sha256_fileFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected