From dc6544fbd67348e1598141d8da1b7c62650edcb7 Mon Sep 17 00:00:00 2001 From: VirxEC Date: Sun, 28 Jan 2024 02:42:11 -0500 Subject: [PATCH] Fix line endings on Windows --- build.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/build.rs b/build.rs index da48ff5..ea84c03 100644 --- a/build.rs +++ b/build.rs @@ -48,9 +48,11 @@ impl PythonBindGenerator { let struct_t_name = format!("{struct_name}T"); - // read the contents of the file let contents = fs::read_to_string(path).ok()?; + #[cfg(windows)] + let contents = contents.replace("\r\n", "\n"); + let Some((types, bind_type)) = Self::get_normal_struct_types(&contents, &struct_t_name) .or_else(|| Self::get_enum_struct_types(&contents, &struct_name)) else { @@ -1194,10 +1196,9 @@ fn main() -> io::Result<()> { .spawn()? .wait()?; - let out_folder_path = format!("{OUT_FOLDER}/rlbot/flat"); - let out_folder = Path::new(&out_folder_path); + let out_folder = Path::new(OUT_FOLDER).join("rlbot").join("flat"); - assert!(out_folder.exists(), "Could not find generated folder: {}", out_folder_path); + assert!(out_folder.exists(), "Could not find generated folder: {}", out_folder.display()); // ^ the above generates the Rust flatbuffers code, // and the below we generates the wanted additional Python binds @@ -1210,12 +1211,6 @@ fn main() -> io::Result<()> { let mut type_data = Vec::new(); for path in generated_files { - // check if it's a file or a directory - if path.is_dir() { - println!("Got directory, skipping for now"); - continue; - } - let Some(mut python_bind_generator) = PythonBindGenerator::new(&path) else { continue; };