From 8dd66e2524fa8b910ed6608cb68796106b219c6b Mon Sep 17 00:00:00 2001 From: Ryan <73148864+Ryan-000@users.noreply.github.com> Date: Sun, 4 Aug 2024 21:35:16 -0400 Subject: [PATCH 1/2] Update file name to include .generated --- src/editor/generate_csharp_bindings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/editor/generate_csharp_bindings.h b/src/editor/generate_csharp_bindings.h index aee84bdb..be835cef 100644 --- a/src/editor/generate_csharp_bindings.h +++ b/src/editor/generate_csharp_bindings.h @@ -80,7 +80,7 @@ class GenerateCSharpBindingsPlugin { }; String output_directory = "res://addons/debug_draw_3d/gen/csharp"; - String api_file_name = "DebugDrawGeneratedAPI.cs"; + String api_file_name = "DebugDrawGeneratedAPI.generated.cs"; String log_file_name = "log.txt"; String indent_template = " "; String indent; @@ -171,4 +171,4 @@ class GenerateCSharpBindingsPlugin { IndentGuard tab(); }; -#endif \ No newline at end of file +#endif From bdb14fb18a82893df66d01fe74371cd440e5a3e4 Mon Sep 17 00:00:00 2001 From: Ryan <73148864+Ryan-000@users.noreply.github.com> Date: Sun, 4 Aug 2024 21:40:20 -0400 Subject: [PATCH 2/2] Delete the file with the older naming convention when generating --- src/editor/generate_csharp_bindings.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/editor/generate_csharp_bindings.cpp b/src/editor/generate_csharp_bindings.cpp index c2c68de6..d755326a 100644 --- a/src/editor/generate_csharp_bindings.cpp +++ b/src/editor/generate_csharp_bindings.cpp @@ -30,6 +30,13 @@ bool GenerateCSharpBindingsPlugin::is_need_to_update() { if (!ClassDB::class_exists("CSharpScript")) return false; + // Old file name + const String old_api_path = output_directory.path_join("DebugDrawGeneratedAPI.cs"); + if (FileAccess::file_exists(old_api_path)) { + return true; + } + + const String api_path = output_directory.path_join(api_file_name); if (FileAccess::file_exists(api_path)) { auto file = FileAccess::open(api_path, FileAccess::READ); @@ -61,6 +68,14 @@ void GenerateCSharpBindingsPlugin::generate() { } } + // Delete the file with the older naming convention + const String old_api_path = output_directory.path_join("DebugDrawGeneratedAPI.cs"); + if (FileAccess::file_exists(old_api_path)) { + PRINT("Attempt to delete API file with older naming convention: " + out_path); + ERR_FAIL_COND(dir->remove(old_api_path) != Error::OK); + } + + // First, delete the old file to check for locks if (FileAccess::file_exists(out_path)) { PRINT("Attempt to delete an old file: " + out_path);