Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression from #12473 and #12388 #12475

Merged
merged 1 commit into from
Oct 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 14 additions & 23 deletions modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,24 @@ public class BuildInstance : IDisposable
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;
Expand Down Expand Up @@ -70,12 +61,12 @@ public bool Build(string loggerAssemblyPath, string loggerOutputDir, string[] cu
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;
Expand Down Expand Up @@ -114,12 +105,12 @@ public bool BuildAsync(string loggerAssemblyPath, string loggerOutputDir, string
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;
Expand Down
54 changes: 27 additions & 27 deletions modules/mono/editor/bindings_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) {
Expand All @@ -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");

Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -1183,25 +1183,25 @@ 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");
}
}

output.push_back("namespace GodotSharpBindings\n" OPEN_BLOCK);
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); \
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
29 changes: 13 additions & 16 deletions modules/mono/editor/godotsharp_builds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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())
Expand All @@ -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");
Expand All @@ -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
}

Expand Down