1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Mono/C#: Re-structure API solution and GodotTools post-build target

Previously we had a placeholder solution called 'Managed' to benefit from
tooling while editing the a part of the C# API.
Later the bindings generator would create the final 'GodotSharp' solution
including these C# files as well as the auto-generated C# API.
Now we replaced the 'Managed' solution with the final 'GodotSharp' solution
which is no longer auto-generated, and the bindings generator only takes
care of the auto-generated C# API.
This has the following benefits:
- It's less confusing as there will no longer be two versions of the same file
(the original and a generated copy of it). Now there's only one.
- We no longer need placeholder for auto-generated API classes, like Node or
Resource. We used them for benefiting from tooling. Now we can just use the
auto-generated API itself.
- Simplifies the build system and bindings generator. Removed lot of code
that is not needed anymore.

Also added a post-build target to the GodotTools project to copy the output to
the data dir. This makes it easy to iterate when doing changes to GodotTools,
as SCons doesn't have to be executed anymore just to copy these new files.
This commit is contained in:
Ignacio Etcheverry
2019-12-28 19:12:32 +01:00
parent 318c693516
commit 86274b9fc9
72 changed files with 350 additions and 674 deletions

View File

@@ -44,54 +44,6 @@
namespace CSharpProject {
bool generate_api_solution_impl(const String &p_solution_dir, const String &p_core_proj_dir, const Vector<String> &p_core_compile_items,
const String &p_editor_proj_dir, const Vector<String> &p_editor_compile_items,
GDMonoAssembly *p_tools_project_editor_assembly) {
GDMonoClass *klass = p_tools_project_editor_assembly->get_class("GodotTools.ProjectEditor", "ApiSolutionGenerator");
Variant solution_dir = p_solution_dir;
Variant core_proj_dir = p_core_proj_dir;
Variant core_compile_items = p_core_compile_items;
Variant editor_proj_dir = p_editor_proj_dir;
Variant editor_compile_items = p_editor_compile_items;
const Variant *args[5] = { &solution_dir, &core_proj_dir, &core_compile_items, &editor_proj_dir, &editor_compile_items };
MonoException *exc = NULL;
klass->get_method("GenerateApiSolution", 5)->invoke(NULL, args, &exc);
if (exc) {
GDMonoUtils::debug_print_unhandled_exception(exc);
ERR_FAIL_V(false);
}
return true;
}
bool generate_api_solution(const String &p_solution_dir, const String &p_core_proj_dir, const Vector<String> &p_core_compile_items,
const String &p_editor_proj_dir, const Vector<String> &p_editor_compile_items) {
if (GDMono::get_singleton()->get_tools_project_editor_assembly()) {
return generate_api_solution_impl(p_solution_dir, p_core_proj_dir, p_core_compile_items,
p_editor_proj_dir, p_editor_compile_items,
GDMono::get_singleton()->get_tools_project_editor_assembly());
} else {
MonoDomain *temp_domain = GDMonoUtils::create_domain("GodotEngine.Domain.ApiSolutionGeneration");
CRASH_COND(temp_domain == NULL);
_GDMONO_SCOPE_EXIT_DOMAIN_UNLOAD_(temp_domain);
_GDMONO_SCOPE_DOMAIN_(temp_domain);
GDMonoAssembly *tools_project_editor_asm = NULL;
bool assembly_loaded = GDMono::get_singleton()->load_assembly(TOOLS_PROJECT_EDITOR_ASM_NAME, &tools_project_editor_asm);
ERR_FAIL_COND_V_MSG(!assembly_loaded, false, "Failed to load assembly: '" TOOLS_PROJECT_EDITOR_ASM_NAME "'.");
return generate_api_solution_impl(p_solution_dir, p_core_proj_dir, p_core_compile_items,
p_editor_proj_dir, p_editor_compile_items,
tools_project_editor_asm);
}
}
void add_item(const String &p_project_path, const String &p_item_type, const String &p_include) {
if (!GLOBAL_DEF("mono/project/auto_update_project", true))