Cargo format
This commit is contained in:
parent
9bab810b91
commit
8c0224e983
44 changed files with 1784 additions and 611 deletions
24
src/build.rs
24
src/build.rs
|
|
@ -7,7 +7,13 @@ use std::path::{Path, PathBuf};
|
|||
fn get_const_name<P: Clone + Into<PathBuf>>(p: &P) -> String {
|
||||
let mut file_name_without_extension = p.clone().into();
|
||||
file_name_without_extension.set_extension("");
|
||||
String::from(file_name_without_extension.file_name().unwrap().to_string_lossy()).to_uppercase()
|
||||
String::from(
|
||||
file_name_without_extension
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_string_lossy(),
|
||||
)
|
||||
.to_uppercase()
|
||||
}
|
||||
|
||||
pub fn create_static_output_files(source_dir: &str) {
|
||||
|
|
@ -17,8 +23,20 @@ pub fn create_static_output_files(source_dir: &str) {
|
|||
for maybe_dir_entry in read_dir(source_dir).unwrap() {
|
||||
let file_path = maybe_dir_entry.unwrap().path();
|
||||
let mut buffer = String::new();
|
||||
File::open(file_path.clone()).unwrap().read_to_string(&mut buffer).unwrap();
|
||||
File::open(file_path.clone())
|
||||
.unwrap()
|
||||
.read_to_string(&mut buffer)
|
||||
.unwrap();
|
||||
let fence = buffer.chars().filter(|c| *c == '#').collect::<String>() + "#";
|
||||
f.write_all(format!("pub const {}: &str = r{1}\"{2}\"{1};\n", get_const_name(&file_path), fence, buffer).as_bytes()).unwrap();
|
||||
f.write_all(
|
||||
format!(
|
||||
"pub const {}: &str = r{1}\"{2}\"{1};\n",
|
||||
get_const_name(&file_path),
|
||||
fence,
|
||||
buffer
|
||||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue