diff options
-rw-r--r-- | modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs | 37 | ||||
-rw-r--r-- | modules/mono/editor/bindings_generator.cpp | 54 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_builds.cpp | 29 |
3 files changed, 54 insertions, 66 deletions
diff --git a/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs b/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs index bdbef82aad..04da0600cc 100644 --- a/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs +++ b/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs @@ -16,33 +16,24 @@ namespace GodotSharpTools.Build private extern static void godot_icall_BuildInstance_ExitCallback(string solution, string config, int exitCode); [MethodImpl(MethodImplOptions.InternalCall)] - private extern static MSBuildInfo godot_icall_BuildInstance_get_MSBuildInfo(); + private extern static void godot_icall_BuildInstance_get_MSBuildInfo(ref string msbuildPath, ref string frameworkPath); - [StructLayout(LayoutKind.Sequential)] private struct MSBuildInfo { - string path; - string frameworkPathOverride; - - public string MSBuildPath - { - get { return path; } - } - - public string FrameworkPathOverride - { - get { return frameworkPathOverride; } - } + public string path; + public string frameworkPathOverride; } private static MSBuildInfo GetMSBuildInfo() { - MSBuildInfo ret = godot_icall_BuildInstance_get_MSBuildInfo(); + MSBuildInfo msbuildInfo = new MSBuildInfo(); + + godot_icall_BuildInstance_get_MSBuildInfo(ref msbuildInfo.path, ref msbuildInfo.frameworkPathOverride); - if (ret.MSBuildPath == null) + if (msbuildInfo.path == null) throw new FileNotFoundException("Cannot find the MSBuild executable."); - return ret; + return msbuildInfo; } private string solution; @@ -70,12 +61,12 @@ namespace GodotSharpTools.Build if (customProperties != null) customPropertiesList.AddRange(customProperties); - if (msbuildInfo.FrameworkPathOverride.Length > 0) - customPropertiesList.Add("FrameworkPathOverride=" + msbuildInfo.FrameworkPathOverride); + if (msbuildInfo.frameworkPathOverride != null) + customPropertiesList.Add("FrameworkPathOverride=" + msbuildInfo.frameworkPathOverride); string compilerArgs = BuildArguments(loggerAssemblyPath, loggerOutputDir, customPropertiesList); - ProcessStartInfo startInfo = new ProcessStartInfo(msbuildInfo.MSBuildPath, compilerArgs); + ProcessStartInfo startInfo = new ProcessStartInfo(msbuildInfo.path, compilerArgs); // No console output, thanks startInfo.RedirectStandardOutput = true; @@ -114,12 +105,12 @@ namespace GodotSharpTools.Build if (customProperties != null) customPropertiesList.AddRange(customProperties); - if (msbuildInfo.FrameworkPathOverride.Length > 0) - customPropertiesList.Add("FrameworkPathOverride=" + msbuildInfo.FrameworkPathOverride); + if (msbuildInfo.frameworkPathOverride.Length > 0) + customPropertiesList.Add("FrameworkPathOverride=" + msbuildInfo.frameworkPathOverride); string compilerArgs = BuildArguments(loggerAssemblyPath, loggerOutputDir, customPropertiesList); - ProcessStartInfo startInfo = new ProcessStartInfo(msbuildInfo.MSBuildPath, compilerArgs); + ProcessStartInfo startInfo = new ProcessStartInfo(msbuildInfo.path, compilerArgs); // No console output, thanks startInfo.RedirectStandardOutput = true; diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 3e4b87c5df..eb504ec021 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -667,18 +667,18 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add the virtual Dispose output.push_back(MEMBER_BEGIN "public virtual void Dispose(bool disposing)\n" OPEN_BLOCK_L2 - "if (disposed) return;\n" INDENT3 - "if (" BINDINGS_PTR_FIELD " != IntPtr.Zero)\n" OPEN_BLOCK_L3 "NativeCalls.godot_icall_"); + "if (disposed) return;\n" INDENT3 + "if (" BINDINGS_PTR_FIELD " != IntPtr.Zero)\n" OPEN_BLOCK_L3 "NativeCalls.godot_icall_"); output.push_back(itype.proxy_name); output.push_back("_Dtor(" BINDINGS_PTR_FIELD ");\n" INDENT5 BINDINGS_PTR_FIELD " = IntPtr.Zero;\n" CLOSE_BLOCK_L3 INDENT3 - "GC.SuppressFinalize(this);\n" INDENT3 "disposed = true;\n" CLOSE_BLOCK_L2); + "GC.SuppressFinalize(this);\n" INDENT3 "disposed = true;\n" CLOSE_BLOCK_L2); output.push_back(MEMBER_BEGIN "internal "); output.push_back(itype.proxy_name); output.push_back("(IntPtr " BINDINGS_PTR_FIELD ")\n" OPEN_BLOCK_L2 "this." BINDINGS_PTR_FIELD " = " BINDINGS_PTR_FIELD ";\n" CLOSE_BLOCK_L2); output.push_back(MEMBER_BEGIN "public IntPtr NativeInstance\n" OPEN_BLOCK_L2 - "get { return " BINDINGS_PTR_FIELD "; }\n" CLOSE_BLOCK_L2); + "get { return " BINDINGS_PTR_FIELD "; }\n" CLOSE_BLOCK_L2); } else if (itype.is_singleton) { // Add the type name and the singleton pointer as static fields @@ -734,17 +734,17 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.push_back("(bool " CS_FIELD_MEMORYOWN ") : base(" CS_FIELD_MEMORYOWN ") {}\n"); } else { output.push_back("(bool " CS_FIELD_MEMORYOWN ")\n" OPEN_BLOCK_L2 - "this." CS_FIELD_MEMORYOWN " = " CS_FIELD_MEMORYOWN ";\n" CLOSE_BLOCK_L2); + "this." CS_FIELD_MEMORYOWN " = " CS_FIELD_MEMORYOWN ";\n" CLOSE_BLOCK_L2); } // Add methods if (!is_derived_type) { output.push_back(MEMBER_BEGIN "public IntPtr NativeInstance\n" OPEN_BLOCK_L2 - "get { return " BINDINGS_PTR_FIELD "; }\n" CLOSE_BLOCK_L2); + "get { return " BINDINGS_PTR_FIELD "; }\n" CLOSE_BLOCK_L2); output.push_back(MEMBER_BEGIN "internal static IntPtr " CS_SMETHOD_GETINSTANCE "(Object instance)\n" OPEN_BLOCK_L2 - "return instance == null ? IntPtr.Zero : instance." BINDINGS_PTR_FIELD ";\n" CLOSE_BLOCK_L2); + "return instance == null ? IntPtr.Zero : instance." BINDINGS_PTR_FIELD ";\n" CLOSE_BLOCK_L2); } if (!is_derived_type) { @@ -758,13 +758,13 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add the virtual Dispose output.push_back(MEMBER_BEGIN "public virtual void Dispose(bool disposing)\n" OPEN_BLOCK_L2 - "if (disposed) return;\n" INDENT3 - "if (" BINDINGS_PTR_FIELD " != IntPtr.Zero)\n" OPEN_BLOCK_L3 - "if (" CS_FIELD_MEMORYOWN ")\n" OPEN_BLOCK_L4 CS_FIELD_MEMORYOWN - " = false;\n" INDENT5 CS_CLASS_NATIVECALLS "." ICALL_OBJECT_DTOR - "(" BINDINGS_PTR_FIELD ");\n" INDENT5 BINDINGS_PTR_FIELD - " = IntPtr.Zero;\n" CLOSE_BLOCK_L4 CLOSE_BLOCK_L3 INDENT3 - "GC.SuppressFinalize(this);\n" INDENT3 "disposed = true;\n" CLOSE_BLOCK_L2); + "if (disposed) return;\n" INDENT3 + "if (" BINDINGS_PTR_FIELD " != IntPtr.Zero)\n" OPEN_BLOCK_L3 + "if (" CS_FIELD_MEMORYOWN ")\n" OPEN_BLOCK_L4 CS_FIELD_MEMORYOWN + " = false;\n" INDENT5 CS_CLASS_NATIVECALLS "." ICALL_OBJECT_DTOR + "(" BINDINGS_PTR_FIELD ");\n" INDENT5 BINDINGS_PTR_FIELD + " = IntPtr.Zero;\n" CLOSE_BLOCK_L4 CLOSE_BLOCK_L3 INDENT3 + "GC.SuppressFinalize(this);\n" INDENT3 "disposed = true;\n" CLOSE_BLOCK_L2); Map<String, TypeInterface>::Element *array_itype = builtin_types.find("Array"); @@ -783,7 +783,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.push_back(MEMBER_BEGIN "public " CS_CLASS_SIGNALAWAITER " ToSignal("); output.push_back(object_itype->get().cs_type); output.push_back(" source, string signal)\n" OPEN_BLOCK_L2 - "return new " CS_CLASS_SIGNALAWAITER "(source, signal, this);\n" CLOSE_BLOCK_L2); + "return new " CS_CLASS_SIGNALAWAITER "(source, signal, this);\n" CLOSE_BLOCK_L2); } } @@ -1138,7 +1138,7 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { List<String> output; output.push_back("#include \"" GLUE_HEADER_FILE "\"\n" - "\n"); + "\n"); generated_icall_funcs.clear(); @@ -1183,11 +1183,11 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { output.push_back("Object* "); output.push_back(ctor_method); output.push_back("(MonoObject* obj) " OPEN_BLOCK - "\t" C_MACRO_OBJECT_CONSTRUCT "(instance, \""); + "\t" C_MACRO_OBJECT_CONSTRUCT "(instance, \""); output.push_back(itype.name); output.push_back("\");\n" - "\t" C_METHOD_TIE_MANAGED_TO_UNMANAGED "(obj, instance);\n" - "\treturn instance;\n" CLOSE_BLOCK "\n"); + "\t" C_METHOD_TIE_MANAGED_TO_UNMANAGED "(obj, instance);\n" + "\treturn instance;\n" CLOSE_BLOCK "\n"); } } @@ -1195,13 +1195,13 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { output.push_back("uint64_t get_core_api_hash() { return "); output.push_back(itos(GDMono::get_singleton()->get_api_core_hash()) + "; }\n"); output.push_back("#ifdef TOOLS_ENABLED\n" - "uint64_t get_editor_api_hash() { return "); + "uint64_t get_editor_api_hash() { return "); output.push_back(itos(GDMono::get_singleton()->get_api_editor_hash()) + - "; }\n#endif // TOOLS_ENABLED\n"); + "; }\n#endif // TOOLS_ENABLED\n"); output.push_back("void register_generated_icalls() " OPEN_BLOCK); -#define ADD_INTERNAL_CALL_REGISTRATION(m_icall) \ - { \ +#define ADD_INTERNAL_CALL_REGISTRATION(m_icall) \ + { \ output.push_back("\tmono_add_internal_call("); \ output.push_back("\"" BINDINGS_NAMESPACE "."); \ output.push_back(m_icall.editor_only ? CS_CLASS_NATIVECALLS_EDITOR : CS_CLASS_NATIVECALLS); \ @@ -1386,7 +1386,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte String real_argc_str = itos(p_imethod.arguments.size() - 1); // Arguments count without vararg p_output.push_back("\tVector<Variant> varargs;\n" - "\tint vararg_length = mono_array_length("); + "\tint vararg_length = mono_array_length("); p_output.push_back(vararg_arg); p_output.push_back(");\n\tint total_length = "); p_output.push_back(real_argc_str); @@ -1401,11 +1401,11 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte p_output.push_back(");\n"); p_output.push_back(c_in_statements); p_output.push_back("\tfor (int i = 0; i < vararg_length; i++) " OPEN_BLOCK - "\t\tMonoObject* elem = mono_array_get("); + "\t\tMonoObject* elem = mono_array_get("); p_output.push_back(vararg_arg); p_output.push_back(", MonoObject*, i);\n" - "\t\tvarargs.set(i, GDMonoMarshal::mono_object_to_variant(elem));\n" - "\t\t" C_LOCAL_PTRCALL_ARGS ".set("); + "\t\tvarargs.set(i, GDMonoMarshal::mono_object_to_variant(elem));\n" + "\t\t" C_LOCAL_PTRCALL_ARGS ".set("); p_output.push_back(real_argc_str); p_output.push_back(" + i, &varargs[i]);\n\t" CLOSE_BLOCK); } else { diff --git a/modules/mono/editor/godotsharp_builds.cpp b/modules/mono/editor/godotsharp_builds.cpp index 8ec19e1500..aaea1bc839 100644 --- a/modules/mono/editor/godotsharp_builds.cpp +++ b/modules/mono/editor/godotsharp_builds.cpp @@ -71,15 +71,10 @@ String _find_build_engine_on_unix(const String &p_name) { } #endif -MonoString **godot_icall_BuildInstance_get_MSBuildInfo() { +void godot_icall_BuildInstance_get_MSBuildInfo(MonoString **r_msbuild_path, MonoString **r_framework_path) { GodotSharpBuilds::BuildTool build_tool = GodotSharpBuilds::BuildTool(int(EditorSettings::get_singleton()->get("mono/builds/build_tool"))); - MonoString *res[2] = { - NULL, // MSBuildPath - NULL // FrameworkPathOverride - }; - #if defined(WINDOWS_ENABLED) switch (build_tool) { case GodotSharpBuilds::MSBUILD: { @@ -89,12 +84,12 @@ MonoString **godot_icall_BuildInstance_get_MSBuildInfo() { if (!msbuild_tools_path.ends_with("\\")) msbuild_tools_path += "\\"; - res[0] = GDMonoMarshal::mono_string_from_godot(msbuild_tools_path + "MSBuild.exe"); + *r_msbuild_path = GDMonoMarshal::mono_string_from_godot(msbuild_tools_path + "MSBuild.exe"); // FrameworkPathOverride - res[1] = GDMonoMarshal::mono_string_from_godot(GDMono::get_singleton()->get_mono_reg_info().assembly_dir); + *r_framework_path = GDMonoMarshal::mono_string_from_godot(GDMono::get_singleton()->get_mono_reg_info().assembly_dir); - return res; + return; } if (OS::get_singleton()->is_stdout_verbose()) @@ -107,8 +102,9 @@ MonoString **godot_icall_BuildInstance_get_MSBuildInfo() { WARN_PRINTS("Cannot find msbuild ('mono/builds/build_tool'). Tried with path: " + msbuild_path); } - res[0] = GDMonoMarshal::mono_string_from_godot(msbuild_path); - return res; + *r_msbuild_path = GDMonoMarshal::mono_string_from_godot(msbuild_path); + + return; } break; default: ERR_EXPLAIN("You don't deserve to live"); @@ -121,19 +117,20 @@ MonoString **godot_icall_BuildInstance_get_MSBuildInfo() { if (build_tool != GodotSharpBuilds::XBUILD) { if (msbuild_path.empty()) { WARN_PRINT("Cannot find msbuild ('mono/builds/build_tool')."); - return res; + return; } } else { if (xbuild_path.empty()) { WARN_PRINT("Cannot find xbuild ('mono/builds/build_tool')."); - return res; + return; } } - res[0] = GDMonoMarshal::mono_string_from_godot(build_tool != GodotSharpBuilds::XBUILD ? msbuild_path : xbuild_path); - return res; + *r_msbuild_path = GDMonoMarshal::mono_string_from_godot(build_tool != GodotSharpBuilds::XBUILD ? msbuild_path : xbuild_path); + + return; #else - return res; + return; #endif } |