crossbundle_tools/commands/android/common/
save_manifest.rs1use crate::error::{AndroidError, Result};
2use android_manifest::AndroidManifest;
3use std::fs::create_dir_all;
4use std::{
5 fs::File,
6 io::Write,
7 path::{Path, PathBuf},
8};
9
10pub fn save_android_manifest(out_dir: &Path, manifest: &AndroidManifest) -> Result<PathBuf> {
12 if !out_dir.exists() {
13 create_dir_all(out_dir)?;
14 }
15 let manifest_path = out_dir.join("AndroidManifest.xml");
16 let mut file = File::create(&manifest_path)?;
17 let given_xml = android_manifest::to_string_pretty(manifest).map_err(AndroidError::from)?;
18 file.write_all(given_xml.as_bytes())?;
19 Ok(manifest_path)
20}