Skip to content

Commit

Permalink
Update build.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Dec 9, 2024
1 parent 88041ed commit a109335
Showing 1 changed file with 24 additions and 27 deletions.
51 changes: 24 additions & 27 deletions yuv-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,32 @@ fn rename_symbols(
) {
// Find all occurences of the function in every header and source files
// and prefix it with FNC_PREFIX
include_files
.par_iter()
.chain(source_files)
.for_each(|file| {
let mut content = fs::read_to_string(&file.path()).unwrap();
for line in fnc_list {
let fnc = line.trim();
if fnc.is_empty() {
continue;
}

// Split line using space as delimiter (If there is two words, the second word is the new name instead of using prefix)
let split: Vec<&str> = fnc.split_whitespace().collect();
let fnc = split[0];

let new_name = if split.len() > 1 {
split[1].to_owned()
} else {
format!("{}{}", FNC_PREFIX, fnc)
};

let re = Regex::new(&format!(r"\b{}\b", fnc)).unwrap();
if let Cow::Owned(c) = re.replace_all(&content, &new_name) {
content = c
}
include_files.par_iter().chain(source_files).for_each(|file| {
let mut content = fs::read_to_string(&file.path()).unwrap();
for line in fnc_list {
let fnc = line.trim();
if fnc.is_empty() {
continue;
}

fs::write(&file.path(), content.to_string()).unwrap();
});
// Split line using space as delimiter (If there is two words, the second word is the new name instead of using prefix)
let split: Vec<&str> = fnc.split_whitespace().collect();
let fnc = split[0];

let new_name = if split.len() > 1 {
split[1].to_owned()
} else {
format!("{}{}", FNC_PREFIX, fnc)
};

let re = Regex::new(&format!(r"\b{}\b", fnc)).unwrap();
if let Cow::Owned(c) = re.replace_all(&content, &new_name) {
content = c
}
}

fs::write(&file.path(), content.to_string()).unwrap();
});
}

fn copy_dir(source: impl AsRef<Path>, destination: impl AsRef<Path>) -> io::Result<()> {
Expand Down

0 comments on commit a109335

Please sign in to comment.