Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update C# API File Naming Convention #50

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading