|
@@ -7,8 +7,7 @@
|
|
|
use std::{
|
|
|
collections::{BTreeMap, HashMap},
|
|
|
env::{current_dir, vars_os},
|
|
|
- fs::{create_dir_all, read_to_string, write, File},
|
|
|
- io::{BufWriter, Write},
|
|
|
+ fs::{create_dir_all, read_to_string, write},
|
|
|
path::{Path, PathBuf},
|
|
|
};
|
|
|
|
|
@@ -80,15 +79,6 @@ pub fn define_permissions(
|
|
|
.filter(|p| p.parent().unwrap().file_name().unwrap() != PERMISSION_SCHEMAS_FOLDER_NAME)
|
|
|
.collect::<Vec<PathBuf>>();
|
|
|
|
|
|
- for path in &permission_files {
|
|
|
- if !path
|
|
|
- .components()
|
|
|
- .any(|c| c.as_os_str() == AUTOGENERATED_FOLDER_NAME)
|
|
|
- {
|
|
|
- println!("cargo:rerun-if-changed={}", path.display());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
let permission_files_path = out_dir.join(format!("{}-permission-files", pkg_name));
|
|
|
std::fs::write(
|
|
|
&permission_files_path,
|
|
@@ -147,10 +137,9 @@ pub fn parse_capabilities(
|
|
|
.unwrap_or_default()
|
|
|
})
|
|
|
// filter schema files
|
|
|
+ // TODO: remove this before stable
|
|
|
.filter(|p| p.parent().unwrap().file_name().unwrap() != CAPABILITIES_SCHEMA_FOLDER_NAME)
|
|
|
{
|
|
|
- println!("cargo:rerun-if-changed={}", path.display());
|
|
|
-
|
|
|
let capability_file = std::fs::read_to_string(&path).map_err(Error::ReadFile)?;
|
|
|
let ext = path.extension().unwrap().to_string_lossy().to_string();
|
|
|
let capability: CapabilityFile = match ext.as_str() {
|
|
@@ -252,10 +241,11 @@ pub fn generate_schema<P: AsRef<Path>>(
|
|
|
let out_dir = out_dir.as_ref().join(PERMISSION_SCHEMAS_FOLDER_NAME);
|
|
|
create_dir_all(&out_dir).expect("unable to create schema output directory");
|
|
|
|
|
|
- let mut schema_file = BufWriter::new(
|
|
|
- File::create(out_dir.join(PERMISSION_SCHEMA_FILE_NAME)).map_err(Error::CreateFile)?,
|
|
|
- );
|
|
|
- write!(schema_file, "{schema_str}").map_err(Error::WriteFile)?;
|
|
|
+ let schema_path = out_dir.join(PERMISSION_SCHEMA_FILE_NAME);
|
|
|
+ if schema_str != read_to_string(&schema_path).unwrap_or_default() {
|
|
|
+ write(schema_path, schema_str).map_err(Error::WriteFile)?;
|
|
|
+ }
|
|
|
+
|
|
|
Ok(())
|
|
|
}
|
|
|
|