diff options
Diffstat (limited to 'modules/mono/editor')
-rw-r--r-- | modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs | 17 | ||||
-rw-r--r-- | modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj | 1 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_builds.cpp | 48 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_editor.cpp | 77 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_export.cpp | 2 | ||||
-rw-r--r-- | modules/mono/editor/mono_bottom_panel.cpp | 14 |
6 files changed, 99 insertions, 60 deletions
diff --git a/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs b/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs index 4137f5eaef..e7d0486c76 100644 --- a/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs +++ b/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs @@ -18,8 +18,6 @@ namespace GodotSharpTools.Build [MethodImpl(MethodImplOptions.InternalCall)] private extern static string godot_icall_BuildInstance_get_MSBuildPath(); [MethodImpl(MethodImplOptions.InternalCall)] - private extern static string godot_icall_BuildInstance_get_FrameworkPath(); - [MethodImpl(MethodImplOptions.InternalCall)] private extern static string godot_icall_BuildInstance_get_MonoWindowsBinDir(); [MethodImpl(MethodImplOptions.InternalCall)] private extern static bool godot_icall_BuildInstance_get_UsingMonoMSBuildOnWindows(); @@ -34,11 +32,6 @@ namespace GodotSharpTools.Build return msbuildPath; } - private static string GetFrameworkPath() - { - return godot_icall_BuildInstance_get_FrameworkPath(); - } - private static string MonoWindowsBinDir { get @@ -85,11 +78,6 @@ namespace GodotSharpTools.Build if (customProperties != null) customPropertiesList.AddRange(customProperties); - string frameworkPath = GetFrameworkPath(); - - if (!string.IsNullOrEmpty(frameworkPath)) - customPropertiesList.Add("FrameworkPathOverride=" + frameworkPath); - string compilerArgs = BuildArguments(loggerAssemblyPath, loggerOutputDir, customPropertiesList); ProcessStartInfo startInfo = new ProcessStartInfo(GetMSBuildPath(), compilerArgs); @@ -145,11 +133,6 @@ namespace GodotSharpTools.Build if (customProperties != null) customPropertiesList.AddRange(customProperties); - string frameworkPath = GetFrameworkPath(); - - if (!string.IsNullOrEmpty(frameworkPath)) - customPropertiesList.Add("FrameworkPathOverride=" + frameworkPath); - string compilerArgs = BuildArguments(loggerAssemblyPath, loggerOutputDir, customPropertiesList); ProcessStartInfo startInfo = new ProcessStartInfo(GetMSBuildPath(), compilerArgs); diff --git a/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj b/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj index f9e9f41977..9a5dd24bb1 100644 --- a/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj +++ b/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj @@ -8,6 +8,7 @@ <RootNamespace>GodotSharpTools</RootNamespace> <AssemblyName>GodotSharpTools</AssemblyName> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <BaseIntermediateOutputPath>obj</BaseIntermediateOutputPath> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> diff --git a/modules/mono/editor/godotsharp_builds.cpp b/modules/mono/editor/godotsharp_builds.cpp index a040e4a344..5e1c9875f0 100644 --- a/modules/mono/editor/godotsharp_builds.cpp +++ b/modules/mono/editor/godotsharp_builds.cpp @@ -100,22 +100,24 @@ MonoString *godot_icall_BuildInstance_get_MSBuildPath() { if (msbuild_tools_path.empty() || !FileAccess::exists(msbuild_tools_path)) { // Try to search it again if it wasn't found last time or if it was removed from its location msbuild_tools_path = MonoRegUtils::find_msbuild_tools_path(); - } - - if (msbuild_tools_path.length()) { - if (!msbuild_tools_path.ends_with("\\")) - msbuild_tools_path += "\\"; - return GDMonoMarshal::mono_string_from_godot(msbuild_tools_path + "MSBuild.exe"); + if (msbuild_tools_path.empty()) { + ERR_PRINTS("Cannot find executable for '" PROP_NAME_MSBUILD_VS "'. Tried with path: " + msbuild_tools_path); + return NULL; + } } - print_verbose("Cannot find executable for '" PROP_NAME_MSBUILD_VS "'. Trying with '" PROP_NAME_MSBUILD_MONO "'..."); - } // FALL THROUGH + if (!msbuild_tools_path.ends_with("\\")) + msbuild_tools_path += "\\"; + + return GDMonoMarshal::mono_string_from_godot(msbuild_tools_path + "MSBuild.exe"); + } break; case GodotSharpBuilds::MSBUILD_MONO: { String msbuild_path = GDMono::get_singleton()->get_mono_reg_info().bin_dir.plus_file("msbuild.bat"); if (!FileAccess::exists(msbuild_path)) { - WARN_PRINTS("Cannot find executable for '" PROP_NAME_MSBUILD_MONO "'. Tried with path: " + msbuild_path); + ERR_PRINTS("Cannot find executable for '" PROP_NAME_MSBUILD_MONO "'. Tried with path: " + msbuild_path); + return NULL; } return GDMonoMarshal::mono_string_from_godot(msbuild_path); @@ -124,7 +126,8 @@ MonoString *godot_icall_BuildInstance_get_MSBuildPath() { String xbuild_path = GDMono::get_singleton()->get_mono_reg_info().bin_dir.plus_file("xbuild.bat"); if (!FileAccess::exists(xbuild_path)) { - WARN_PRINTS("Cannot find executable for '" PROP_NAME_XBUILD "'. Tried with path: " + xbuild_path); + ERR_PRINTS("Cannot find executable for '" PROP_NAME_XBUILD "'. Tried with path: " + xbuild_path); + return NULL; } return GDMonoMarshal::mono_string_from_godot(xbuild_path); @@ -144,7 +147,7 @@ MonoString *godot_icall_BuildInstance_get_MSBuildPath() { } if (xbuild_path.empty()) { - WARN_PRINT("Cannot find binary for '" PROP_NAME_XBUILD "'"); + ERR_PRINT("Cannot find binary for '" PROP_NAME_XBUILD "'"); return NULL; } } else { @@ -154,7 +157,7 @@ MonoString *godot_icall_BuildInstance_get_MSBuildPath() { } if (msbuild_path.empty()) { - WARN_PRINT("Cannot find binary for '" PROP_NAME_MSBUILD_MONO "'"); + ERR_PRINT("Cannot find binary for '" PROP_NAME_MSBUILD_MONO "'"); return NULL; } } @@ -168,22 +171,6 @@ MonoString *godot_icall_BuildInstance_get_MSBuildPath() { #endif } -MonoString *godot_icall_BuildInstance_get_FrameworkPath() { - -#if defined(WINDOWS_ENABLED) - const MonoRegInfo &mono_reg_info = GDMono::get_singleton()->get_mono_reg_info(); - if (mono_reg_info.assembly_dir.length()) { - String framework_path = path_join(mono_reg_info.assembly_dir, "mono", "4.5"); - return GDMonoMarshal::mono_string_from_godot(framework_path); - } - - ERR_EXPLAIN("Cannot find Mono's assemblies directory in the registry"); - ERR_FAIL_V(NULL); -#else - return NULL; -#endif -} - MonoString *godot_icall_BuildInstance_get_MonoWindowsBinDir() { #if defined(WINDOWS_ENABLED) @@ -216,7 +203,6 @@ void GodotSharpBuilds::register_internal_calls() { mono_add_internal_call("GodotSharpTools.Build.BuildSystem::godot_icall_BuildInstance_ExitCallback", (void *)godot_icall_BuildInstance_ExitCallback); mono_add_internal_call("GodotSharpTools.Build.BuildInstance::godot_icall_BuildInstance_get_MSBuildPath", (void *)godot_icall_BuildInstance_get_MSBuildPath); - mono_add_internal_call("GodotSharpTools.Build.BuildInstance::godot_icall_BuildInstance_get_FrameworkPath", (void *)godot_icall_BuildInstance_get_FrameworkPath); mono_add_internal_call("GodotSharpTools.Build.BuildInstance::godot_icall_BuildInstance_get_MonoWindowsBinDir", (void *)godot_icall_BuildInstance_get_MonoWindowsBinDir); mono_add_internal_call("GodotSharpTools.Build.BuildInstance::godot_icall_BuildInstance_get_UsingMonoMSBuildOnWindows", (void *)godot_icall_BuildInstance_get_UsingMonoMSBuildOnWindows); } @@ -459,7 +445,11 @@ GodotSharpBuilds::GodotSharpBuilds() { // Build tool settings EditorSettings *ed_settings = EditorSettings::get_singleton(); +#ifdef WINDOWS_ENABLED + EDITOR_DEF("mono/builds/build_tool", MSBUILD_VS); +#else EDITOR_DEF("mono/builds/build_tool", MSBUILD_MONO); +#endif ed_settings->add_property_hint(PropertyInfo(Variant::INT, "mono/builds/build_tool", PROPERTY_HINT_ENUM, PROP_NAME_MSBUILD_MONO diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp index 474ec8a458..17e29fba19 100644 --- a/modules/mono/editor/godotsharp_editor.cpp +++ b/modules/mono/editor/godotsharp_editor.cpp @@ -30,6 +30,7 @@ #include "godotsharp_editor.h" +#include "core/message_queue.h" #include "core/os/os.h" #include "core/project_settings.h" #include "scene/gui/control.h" @@ -114,10 +115,33 @@ bool GodotSharpEditor::_create_project_solution() { void GodotSharpEditor::_make_api_solutions_if_needed() { // I'm sick entirely of ProgressDialog + + static int attempts_left = 100; + + if (MessageQueue::get_singleton()->is_flushing() || !SceneTree::get_singleton()) { + ERR_FAIL_COND(attempts_left == 0); // You've got to be kidding + + if (SceneTree::get_singleton()) { + SceneTree::get_singleton()->connect("idle_frame", this, "_make_api_solutions_if_needed", Vector<Variant>()); + } else { + call_deferred("_make_api_solutions_if_needed"); + } + + attempts_left--; + return; + } + + // Recursion guard needed because signals don't play well with ProgressDialog either, but unlike + // the message queue, with signals the collateral damage should be minimal in the worst case. static bool recursion_guard = false; if (!recursion_guard) { recursion_guard = true; + + // Oneshot signals don't play well with ProgressDialog either, so we do it this way instead + SceneTree::get_singleton()->disconnect("idle_frame", this, "_make_api_solutions_if_needed"); + _make_api_solutions_if_needed_impl(); + recursion_guard = false; } } @@ -248,19 +272,50 @@ Error GodotSharpEditor::open_in_external_editor(const Ref<Script> &p_script, int static String vscode_path; if (vscode_path.empty() || !FileAccess::exists(vscode_path)) { - static List<String> vscode_name; - vscode_name.push_back("code"); - vscode_name.push_back("code-oss"); - vscode_name.push_back("vscode"); - vscode_name.push_back("vscode-oss"); - vscode_name.push_back("visual-studio-code"); - vscode_name.push_back("visual-studio-code-oss"); // Try to search it again if it wasn't found last time or if it was removed from its location - for (int i = 0; i < vscode_name.size(); i++) { - vscode_path = path_which(vscode_name[i]); - if (!vscode_path.empty() || FileAccess::exists(vscode_path)) + bool found = false; + + // TODO: Use initializer lists once C++11 is allowed + + // Try with hint paths + static Vector<String> hint_paths; +#ifdef WINDOWS_ENABLED + if (hint_paths.empty()) { + hint_paths.push_back(OS::get_singleton()->get_environment("ProgramFiles") + "\\Microsoft VS Code\\Code.exe"); + if (sizeof(size_t) == 8) { + hint_paths.push_back(OS::get_singleton()->get_environment("ProgramFiles(x86)") + "\\Microsoft VS Code\\Code.exe"); + } + } +#endif + for (int i = 0; i < hint_paths.size(); i++) { + vscode_path = hint_paths[i]; + if (FileAccess::exists(vscode_path)) { + found = true; break; + } + } + + if (!found) { + static Vector<String> vscode_names; + if (vscode_names.empty()) { + vscode_names.push_back("code"); + vscode_names.push_back("code-oss"); + vscode_names.push_back("vscode"); + vscode_names.push_back("vscode-oss"); + vscode_names.push_back("visual-studio-code"); + vscode_names.push_back("visual-studio-code-oss"); + } + for (int i = 0; i < vscode_names.size(); i++) { + vscode_path = path_which(vscode_names[i]); + if (!vscode_path.empty()) { + found = true; + break; + } + } } + + if (!found) + vscode_path.clear(); // Not found, clear so next time the empty() check is enough } List<String> args; @@ -434,7 +489,7 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) { String csproj_path = GodotSharpDirs::get_project_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. + // Defer this task because EditorProgress calls Main::iterarion() and the main loop is not yet initialized. call_deferred("_make_api_solutions_if_needed"); } else { bottom_panel_btn->hide(); diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp index 47341e3555..7e2487a6e7 100644 --- a/modules/mono/editor/godotsharp_export.cpp +++ b/modules/mono/editor/godotsharp_export.cpp @@ -124,7 +124,7 @@ void GodotSharpExport::_export_begin(const Set<String> &p_features, bool p_debug ERR_FAIL_COND(!load_success); Vector<String> search_dirs; - GDMonoAssembly::fill_search_dirs(search_dirs); + GDMonoAssembly::fill_search_dirs(search_dirs, build_config); Error depend_error = _get_assembly_dependencies(scripts_assembly, search_dirs, dependencies); ERR_FAIL_COND(depend_error != OK); } diff --git a/modules/mono/editor/mono_bottom_panel.cpp b/modules/mono/editor/mono_bottom_panel.cpp index d3efa288e9..cc9822e319 100644 --- a/modules/mono/editor/mono_bottom_panel.cpp +++ b/modules/mono/editor/mono_bottom_panel.cpp @@ -156,10 +156,20 @@ void MonoBottomPanel::_build_project_pressed() { if (!FileAccess::exists(GodotSharpDirs::get_project_sln_path())) return; // No solution to build - String scripts_metadata_path = GodotSharpDirs::get_res_metadata_dir().plus_file("scripts_metadata.editor"); - Error metadata_err = CSharpProject::generate_scripts_metadata(GodotSharpDirs::get_project_csproj_path(), scripts_metadata_path); + String scripts_metadata_path_editor = GodotSharpDirs::get_res_metadata_dir().plus_file("scripts_metadata.editor"); + String scripts_metadata_path_player = GodotSharpDirs::get_res_metadata_dir().plus_file("scripts_metadata.editor_player"); + + Error metadata_err = CSharpProject::generate_scripts_metadata(GodotSharpDirs::get_project_csproj_path(), scripts_metadata_path_editor); ERR_FAIL_COND(metadata_err != OK); + if (FileAccess::exists(scripts_metadata_path_editor)) { + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + Error copy_err = da->copy(scripts_metadata_path_editor, scripts_metadata_path_player); + + ERR_EXPLAIN("Failed to copy scripts metadata file"); + ERR_FAIL_COND(copy_err != OK); + } + bool build_success = GodotSharpBuilds::get_singleton()->build_project_blocking("Tools"); if (build_success) { |