(
target: &str,
outputs: &BuildOutputs,
sources: &SourcesManifest,
)
| 8864 | } |
| 8865 | |
| 8866 | fn 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 |
no test coverage detected