|
7 | 7 | use std::{ |
8 | 8 | collections::{BTreeMap, HashMap}, |
9 | 9 | env::{current_dir, vars_os}, |
10 | | - fs::{create_dir_all, read_to_string, write, File}, |
11 | | - io::{BufWriter, Write}, |
| 10 | + fs::{create_dir_all, read_to_string, write}, |
12 | 11 | path::{Path, PathBuf}, |
13 | 12 | }; |
14 | 13 |
|
@@ -80,15 +79,6 @@ pub fn define_permissions( |
80 | 79 | .filter(|p| p.parent().unwrap().file_name().unwrap() != PERMISSION_SCHEMAS_FOLDER_NAME) |
81 | 80 | .collect::<Vec<PathBuf>>(); |
82 | 81 |
|
83 | | - for path in &permission_files { |
84 | | - if !path |
85 | | - .components() |
86 | | - .any(|c| c.as_os_str() == AUTOGENERATED_FOLDER_NAME) |
87 | | - { |
88 | | - println!("cargo:rerun-if-changed={}", path.display()); |
89 | | - } |
90 | | - } |
91 | | - |
92 | 82 | let permission_files_path = out_dir.join(format!("{}-permission-files", pkg_name)); |
93 | 83 | std::fs::write( |
94 | 84 | &permission_files_path, |
@@ -147,10 +137,9 @@ pub fn parse_capabilities( |
147 | 137 | .unwrap_or_default() |
148 | 138 | }) |
149 | 139 | // filter schema files |
| 140 | + // TODO: remove this before stable |
150 | 141 | .filter(|p| p.parent().unwrap().file_name().unwrap() != CAPABILITIES_SCHEMA_FOLDER_NAME) |
151 | 142 | { |
152 | | - println!("cargo:rerun-if-changed={}", path.display()); |
153 | | - |
154 | 143 | let capability_file = std::fs::read_to_string(&path).map_err(Error::ReadFile)?; |
155 | 144 | let ext = path.extension().unwrap().to_string_lossy().to_string(); |
156 | 145 | let capability: CapabilityFile = match ext.as_str() { |
@@ -252,10 +241,11 @@ pub fn generate_schema<P: AsRef<Path>>( |
252 | 241 | let out_dir = out_dir.as_ref().join(PERMISSION_SCHEMAS_FOLDER_NAME); |
253 | 242 | create_dir_all(&out_dir).expect("unable to create schema output directory"); |
254 | 243 |
|
255 | | - let mut schema_file = BufWriter::new( |
256 | | - File::create(out_dir.join(PERMISSION_SCHEMA_FILE_NAME)).map_err(Error::CreateFile)?, |
257 | | - ); |
258 | | - write!(schema_file, "{schema_str}").map_err(Error::WriteFile)?; |
| 244 | + let schema_path = out_dir.join(PERMISSION_SCHEMA_FILE_NAME); |
| 245 | + if schema_str != read_to_string(&schema_path).unwrap_or_default() { |
| 246 | + write(schema_path, schema_str).map_err(Error::WriteFile)?; |
| 247 | + } |
| 248 | + |
259 | 249 | Ok(()) |
260 | 250 | } |
261 | 251 |
|
|
0 commit comments