Skip to content

Commit

Permalink
Merge pull request #50 from Ryan-000/make_file_name_include_generated
Browse files Browse the repository at this point in the history
Update C# API File Naming Convention
  • Loading branch information
DmitriySalnikov committed Aug 5, 2024
2 parents 0cc3998 + bdb14fb commit f00d19b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/editor/generate_csharp_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/editor/generate_csharp_bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -171,4 +171,4 @@ class GenerateCSharpBindingsPlugin {
IndentGuard tab();
};

#endif
#endif

0 comments on commit f00d19b

Please sign in to comment.