Merge pull request #23128 from neikeq/bb

Make sure API assemblies are up to date at startup
This commit is contained in:
Ignacio Etcheverry 2018-10-19 00:24:15 +02:00 committed by GitHub
commit 6312f18f8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 31 deletions

View file

@ -306,6 +306,16 @@ String GodotSharpBuilds::_api_folder_name(APIAssembly::Type p_api_type) {
bool GodotSharpBuilds::make_api_sln(APIAssembly::Type p_api_type) { 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_name = p_api_type == APIAssembly::API_CORE ? API_ASSEMBLY_NAME : EDITOR_API_ASSEMBLY_NAME;
String editor_prebuilt_api_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir();
String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir();
if (FileAccess::exists(editor_prebuilt_api_dir.plus_file(api_name + ".dll"))) {
EditorProgress pr("mono_copy_prebuilt_api_assembly", "Copying prebuilt " + api_name + " assembly...", 1);
pr.step("Copying " + api_name + " assembly", 0);
return GodotSharpBuilds::copy_api_assembly(editor_prebuilt_api_dir, res_assemblies_dir, api_name, p_api_type);
}
String api_build_config = "Release"; String api_build_config = "Release";
EditorProgress pr("mono_build_release_" + api_name, "Building " + api_name + " solution...", 3); EditorProgress pr("mono_build_release_" + api_name, "Building " + api_name + " solution...", 3);
@ -357,7 +367,6 @@ bool GodotSharpBuilds::make_api_sln(APIAssembly::Type p_api_type) {
// Copy the built assembly to the assemblies directory // Copy the built assembly to the assemblies directory
String api_assembly_dir = api_sln_dir.plus_file("bin").plus_file(api_build_config); String api_assembly_dir = api_sln_dir.plus_file("bin").plus_file(api_build_config);
String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir();
if (!GodotSharpBuilds::copy_api_assembly(api_assembly_dir, res_assemblies_dir, api_name, p_api_type)) if (!GodotSharpBuilds::copy_api_assembly(api_assembly_dir, res_assemblies_dir, api_name, p_api_type))
return false; return false;
@ -369,36 +378,11 @@ bool GodotSharpBuilds::build_project_blocking(const String &p_config) {
if (!FileAccess::exists(GodotSharpDirs::get_project_sln_path())) if (!FileAccess::exists(GodotSharpDirs::get_project_sln_path()))
return true; // No solution to build return true; // No solution to build
String editor_prebuilt_api_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir(); if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_CORE))
String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir(); return false;
if (FileAccess::exists(editor_prebuilt_api_dir.plus_file(API_ASSEMBLY_NAME ".dll"))) { if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_EDITOR))
EditorProgress pr("mono_copy_prebuilt_api_assemblies", return false;
"Copying prebuilt " API_ASSEMBLY_NAME " assemblies...", 1);
pr.step("Copying " API_ASSEMBLY_NAME " assembly", 0);
if (!GodotSharpBuilds::copy_api_assembly(editor_prebuilt_api_dir, res_assemblies_dir,
API_ASSEMBLY_NAME, APIAssembly::API_CORE)) {
return false;
}
} else {
if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_CORE))
return false;
}
if (DirAccess::exists(editor_prebuilt_api_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll"))) {
EditorProgress pr("mono_copy_prebuilt_api_assemblies",
"Copying prebuilt " EDITOR_API_ASSEMBLY_NAME " assemblies...", 1);
pr.step("Copying " EDITOR_API_ASSEMBLY_NAME " assembly", 0);
if (!GodotSharpBuilds::copy_api_assembly(editor_prebuilt_api_dir, res_assemblies_dir,
EDITOR_API_ASSEMBLY_NAME, APIAssembly::API_EDITOR)) {
return false;
}
} else {
if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_EDITOR))
return false;
}
EditorProgress pr("mono_project_debug_build", "Building project solution...", 1); EditorProgress pr("mono_project_debug_build", "Building project solution...", 1);
pr.step("Building project solution", 0); pr.step("Building project solution", 0);

View file

@ -108,6 +108,33 @@ bool GodotSharpEditor::_create_project_solution() {
return true; return true;
} }
void GodotSharpEditor::_make_api_solutions_if_needed() {
// I'm sick entirely of ProgressDialog
static bool recursion_guard = false;
if (!recursion_guard) {
recursion_guard = true;
_make_api_solutions_if_needed_impl();
recursion_guard = false;
}
}
void GodotSharpEditor::_make_api_solutions_if_needed_impl() {
// If the project has a solution and C# project make sure the API assemblies are present and up to date
String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir();
if (!FileAccess::exists(res_assemblies_dir.plus_file(API_ASSEMBLY_NAME ".dll")) ||
GDMono::get_singleton()->metadata_is_api_assembly_invalidated(APIAssembly::API_CORE)) {
if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_CORE))
return;
}
if (!FileAccess::exists(res_assemblies_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll")) ||
GDMono::get_singleton()->metadata_is_api_assembly_invalidated(APIAssembly::API_EDITOR)) {
if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_EDITOR))
return; // Redundant? I don't think so
}
}
void GodotSharpEditor::_remove_create_sln_menu_option() { void GodotSharpEditor::_remove_create_sln_menu_option() {
menu_popup->remove_item(menu_popup->get_item_index(MENU_CREATE_SLN)); menu_popup->remove_item(menu_popup->get_item_index(MENU_CREATE_SLN));
@ -169,6 +196,7 @@ void GodotSharpEditor::_notification(int p_notification) {
void GodotSharpEditor::_bind_methods() { void GodotSharpEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_create_project_solution"), &GodotSharpEditor::_create_project_solution); ClassDB::bind_method(D_METHOD("_create_project_solution"), &GodotSharpEditor::_create_project_solution);
ClassDB::bind_method(D_METHOD("_make_api_solutions_if_needed"), &GodotSharpEditor::_make_api_solutions_if_needed);
ClassDB::bind_method(D_METHOD("_remove_create_sln_menu_option"), &GodotSharpEditor::_remove_create_sln_menu_option); ClassDB::bind_method(D_METHOD("_remove_create_sln_menu_option"), &GodotSharpEditor::_remove_create_sln_menu_option);
ClassDB::bind_method(D_METHOD("_toggle_about_dialog_on_start"), &GodotSharpEditor::_toggle_about_dialog_on_start); ClassDB::bind_method(D_METHOD("_toggle_about_dialog_on_start"), &GodotSharpEditor::_toggle_about_dialog_on_start);
ClassDB::bind_method(D_METHOD("_menu_option_pressed", "id"), &GodotSharpEditor::_menu_option_pressed); ClassDB::bind_method(D_METHOD("_menu_option_pressed", "id"), &GodotSharpEditor::_menu_option_pressed);
@ -390,7 +418,10 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) {
String sln_path = GodotSharpDirs::get_project_sln_path(); String sln_path = GodotSharpDirs::get_project_sln_path();
String csproj_path = GodotSharpDirs::get_project_csproj_path(); String csproj_path = GodotSharpDirs::get_project_csproj_path();
if (!FileAccess::exists(sln_path) || !FileAccess::exists(csproj_path)) { if (FileAccess::exists(sln_path) && FileAccess::exists(csproj_path)) {
// We can't use EditorProgress here. It calls Main::iterarion() and the main loop is not initialized yet.
call_deferred("_make_api_solutions_if_needed");
} else {
bottom_panel_btn->hide(); bottom_panel_btn->hide();
menu_popup->add_item(TTR("Create C# solution"), MENU_CREATE_SLN); menu_popup->add_item(TTR("Create C# solution"), MENU_CREATE_SLN);
} }

View file

@ -56,6 +56,8 @@ class GodotSharpEditor : public Node {
#endif #endif
bool _create_project_solution(); bool _create_project_solution();
void _make_api_solutions_if_needed();
void _make_api_solutions_if_needed_impl();
void _remove_create_sln_menu_option(); void _remove_create_sln_menu_option();
void _show_about_dialog(); void _show_about_dialog();