You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-13 13:31:48 +00:00
Mono: Better versioning and gracefully unloading of Godot API assemblies
(cherry picked from commit f37090ccf4)
This commit is contained in:
committed by
Hein-Pieter van Braam
parent
1ea805a4aa
commit
dde14e15c6
@@ -33,7 +33,6 @@
|
||||
#include "main/main.h"
|
||||
|
||||
#include "../godotsharp_dirs.h"
|
||||
#include "../mono_gd/gd_mono.h"
|
||||
#include "../mono_gd/gd_mono_class.h"
|
||||
#include "../mono_gd/gd_mono_marshal.h"
|
||||
#include "../utils/path_utils.h"
|
||||
@@ -178,13 +177,15 @@ bool GodotSharpBuilds::build_api_sln(const String &p_name, const String &p_api_s
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GodotSharpBuilds::copy_api_assembly(const String &p_src_dir, const String &p_dst_dir, const String &p_assembly_name) {
|
||||
bool GodotSharpBuilds::copy_api_assembly(const String &p_src_dir, const String &p_dst_dir, const String &p_assembly_name, APIAssembly::Type p_api_type) {
|
||||
|
||||
String assembly_file = p_assembly_name + ".dll";
|
||||
String assembly_src = p_src_dir.plus_file(assembly_file);
|
||||
String assembly_dst = p_dst_dir.plus_file(assembly_file);
|
||||
|
||||
if (!FileAccess::exists(assembly_dst) || FileAccess::get_modified_time(assembly_src) > FileAccess::get_modified_time(assembly_dst)) {
|
||||
if (!FileAccess::exists(assembly_dst) ||
|
||||
FileAccess::get_modified_time(assembly_src) > FileAccess::get_modified_time(assembly_dst) ||
|
||||
GDMono::get_singleton()->metadata_is_api_assembly_invalidated(p_api_type)) {
|
||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||
|
||||
String xml_file = p_assembly_name + ".xml";
|
||||
@@ -203,33 +204,46 @@ bool GodotSharpBuilds::copy_api_assembly(const String &p_src_dir, const String &
|
||||
show_build_error_dialog("Failed to copy " API_ASSEMBLY_NAME ".dll");
|
||||
return false;
|
||||
}
|
||||
|
||||
GDMono::get_singleton()->metadata_set_api_assembly_invalidated(p_api_type, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GodotSharpBuilds::make_api_sln(GodotSharpBuilds::APIType p_api_type) {
|
||||
String GodotSharpBuilds::_api_folder_name(APIAssembly::Type p_api_type) {
|
||||
|
||||
String api_name = p_api_type == API_CORE ? API_ASSEMBLY_NAME : EDITOR_API_ASSEMBLY_NAME;
|
||||
uint64_t api_hash = p_api_type == APIAssembly::API_CORE ?
|
||||
GDMono::get_singleton()->get_api_core_hash() :
|
||||
GDMono::get_singleton()->get_api_editor_hash();
|
||||
return String::num_uint64(api_hash) +
|
||||
"_" + String::num_uint64(BindingsGenerator::get_version()) +
|
||||
"_" + String::num_uint64(BindingsGenerator::get_cs_glue_version());
|
||||
}
|
||||
|
||||
bool GodotSharpBuilds::make_api_sln(APIAssembly::Type p_api_type) {
|
||||
|
||||
String api_name = p_api_type == APIAssembly::API_CORE ? API_ASSEMBLY_NAME : EDITOR_API_ASSEMBLY_NAME;
|
||||
String api_build_config = "Release";
|
||||
|
||||
EditorProgress pr("mono_build_release_" + api_name, "Building " + api_name + " solution...", 4);
|
||||
|
||||
pr.step("Generating " + api_name + " solution");
|
||||
|
||||
uint64_t core_hash = GDMono::get_singleton()->get_api_core_hash();
|
||||
uint64_t editor_hash = GDMono::get_singleton()->get_api_editor_hash();
|
||||
String core_api_sln_dir = GodotSharpDirs::get_mono_solutions_dir()
|
||||
.plus_file(_api_folder_name(APIAssembly::API_CORE))
|
||||
.plus_file(API_ASSEMBLY_NAME);
|
||||
String editor_api_sln_dir = GodotSharpDirs::get_mono_solutions_dir()
|
||||
.plus_file(_api_folder_name(APIAssembly::API_EDITOR))
|
||||
.plus_file(EDITOR_API_ASSEMBLY_NAME);
|
||||
|
||||
String core_api_sln_dir = GodotSharpDirs::get_mono_solutions_dir().plus_file(API_ASSEMBLY_NAME "_" + itos(core_hash));
|
||||
String editor_api_sln_dir = GodotSharpDirs::get_mono_solutions_dir().plus_file(EDITOR_API_ASSEMBLY_NAME "_" + itos(editor_hash));
|
||||
|
||||
String api_sln_dir = p_api_type == API_CORE ? core_api_sln_dir : editor_api_sln_dir;
|
||||
String api_sln_dir = p_api_type == APIAssembly::API_CORE ? core_api_sln_dir : editor_api_sln_dir;
|
||||
String api_sln_file = api_sln_dir.plus_file(api_name + ".sln");
|
||||
|
||||
if (!DirAccess::exists(api_sln_dir) || !FileAccess::exists(api_sln_file)) {
|
||||
String core_api_assembly;
|
||||
|
||||
if (p_api_type == API_EDITOR) {
|
||||
if (p_api_type == APIAssembly::API_EDITOR) {
|
||||
core_api_assembly = core_api_sln_dir.plus_file("bin")
|
||||
.plus_file(api_build_config)
|
||||
.plus_file(API_ASSEMBLY_NAME ".dll");
|
||||
@@ -242,7 +256,7 @@ bool GodotSharpBuilds::make_api_sln(GodotSharpBuilds::APIType p_api_type) {
|
||||
BindingsGenerator *gen = BindingsGenerator::get_singleton();
|
||||
bool gen_verbose = OS::get_singleton()->is_stdout_verbose();
|
||||
|
||||
Error err = p_api_type == API_CORE ?
|
||||
Error err = p_api_type == APIAssembly::API_CORE ?
|
||||
gen->generate_cs_core_project(api_sln_dir, gen_verbose) :
|
||||
gen->generate_cs_editor_project(api_sln_dir, core_api_assembly, gen_verbose);
|
||||
|
||||
@@ -275,7 +289,7 @@ bool GodotSharpBuilds::make_api_sln(GodotSharpBuilds::APIType p_api_type) {
|
||||
|
||||
// Copy the built assembly to the assemblies directory
|
||||
String api_assembly_dir = api_sln_dir.plus_file("bin").plus_file(api_build_config);
|
||||
if (!GodotSharpBuilds::copy_api_assembly(api_assembly_dir, res_assemblies_dir, api_name))
|
||||
if (!GodotSharpBuilds::copy_api_assembly(api_assembly_dir, res_assemblies_dir, api_name, p_api_type))
|
||||
return false;
|
||||
|
||||
pr.step("Done");
|
||||
@@ -288,10 +302,10 @@ bool GodotSharpBuilds::build_project_blocking() {
|
||||
if (!FileAccess::exists(GodotSharpDirs::get_project_sln_path()))
|
||||
return true; // No solution to build
|
||||
|
||||
if (!GodotSharpBuilds::make_api_sln(GodotSharpBuilds::API_CORE))
|
||||
if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_CORE))
|
||||
return false;
|
||||
|
||||
if (!GodotSharpBuilds::make_api_sln(GodotSharpBuilds::API_EDITOR))
|
||||
if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_EDITOR))
|
||||
return false;
|
||||
|
||||
EditorProgress pr("mono_project_debug_build", "Building project solution...", 2);
|
||||
|
||||
Reference in New Issue
Block a user