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

[.NET] Disable output embedding on macOS, move it to the advanced options on other platforms. #90422

Merged
merged 1 commit into from
Apr 9, 2024
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
109 changes: 0 additions & 109 deletions modules/mono/csharp_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,115 +410,6 @@ ScriptLanguage::ScriptNameCasing CSharpLanguage::preferred_file_name_casing() co
}

#ifdef TOOLS_ENABLED
struct VariantCsName {
Variant::Type variant_type;
const String cs_type;
};

static String variant_type_to_managed_name(const String &p_var_type_name) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This became unused with #87952 and it's OK to remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing it out, so I know this part of the commit should not be cherry-picked to 4.2.

if (p_var_type_name.is_empty()) {
return "Variant";
}

if (ClassDB::class_exists(p_var_type_name)) {
return pascal_to_pascal_case(p_var_type_name);
}

if (p_var_type_name == Variant::get_type_name(Variant::OBJECT)) {
return "GodotObject";
}

if (p_var_type_name == Variant::get_type_name(Variant::INT)) {
return "long";
}

if (p_var_type_name == Variant::get_type_name(Variant::FLOAT)) {
return "double";
}

if (p_var_type_name == Variant::get_type_name(Variant::STRING)) {
return "string"; // I prefer this one >:[
}

if (p_var_type_name == Variant::get_type_name(Variant::DICTIONARY)) {
return "Collections.Dictionary";
}

if (p_var_type_name.begins_with(Variant::get_type_name(Variant::ARRAY) + "[")) {
String element_type = p_var_type_name.trim_prefix(Variant::get_type_name(Variant::ARRAY) + "[").trim_suffix("]");
return "Collections.Array<" + variant_type_to_managed_name(element_type) + ">";
}

if (p_var_type_name == Variant::get_type_name(Variant::ARRAY)) {
return "Collections.Array";
}

if (p_var_type_name == Variant::get_type_name(Variant::PACKED_BYTE_ARRAY)) {
return "byte[]";
}
if (p_var_type_name == Variant::get_type_name(Variant::PACKED_INT32_ARRAY)) {
return "int[]";
}
if (p_var_type_name == Variant::get_type_name(Variant::PACKED_INT64_ARRAY)) {
return "long[]";
}
if (p_var_type_name == Variant::get_type_name(Variant::PACKED_FLOAT32_ARRAY)) {
return "float[]";
}
if (p_var_type_name == Variant::get_type_name(Variant::PACKED_FLOAT64_ARRAY)) {
return "double[]";
}
if (p_var_type_name == Variant::get_type_name(Variant::PACKED_STRING_ARRAY)) {
return "string[]";
}
if (p_var_type_name == Variant::get_type_name(Variant::PACKED_VECTOR2_ARRAY)) {
return "Vector2[]";
}
if (p_var_type_name == Variant::get_type_name(Variant::PACKED_VECTOR3_ARRAY)) {
return "Vector3[]";
}
if (p_var_type_name == Variant::get_type_name(Variant::PACKED_COLOR_ARRAY)) {
return "Color[]";
}

if (p_var_type_name == Variant::get_type_name(Variant::SIGNAL)) {
return "Signal";
}

const VariantCsName var_types[] = {
{ Variant::BOOL, "bool" },
{ Variant::INT, "long" },
{ Variant::VECTOR2, "Vector2" },
{ Variant::VECTOR2I, "Vector2I" },
{ Variant::RECT2, "Rect2" },
{ Variant::RECT2I, "Rect2I" },
{ Variant::VECTOR3, "Vector3" },
{ Variant::VECTOR3I, "Vector3I" },
{ Variant::TRANSFORM2D, "Transform2D" },
{ Variant::VECTOR4, "Vector4" },
{ Variant::VECTOR4I, "Vector4I" },
{ Variant::PLANE, "Plane" },
{ Variant::QUATERNION, "Quaternion" },
{ Variant::AABB, "Aabb" },
{ Variant::BASIS, "Basis" },
{ Variant::TRANSFORM3D, "Transform3D" },
{ Variant::PROJECTION, "Projection" },
{ Variant::COLOR, "Color" },
{ Variant::STRING_NAME, "StringName" },
{ Variant::NODE_PATH, "NodePath" },
{ Variant::RID, "Rid" },
{ Variant::CALLABLE, "Callable" },
};

for (unsigned int i = 0; i < sizeof(var_types) / sizeof(VariantCsName); i++) {
if (p_var_type_name == Variant::get_type_name(var_types[i].variant_type)) {
return var_types[i].cs_type;
}
}

return "Variant";
}

String CSharpLanguage::make_function(const String &, const String &p_name, const PackedStringArray &p_args) const {
// The make_function() API does not work for C# scripts.
// It will always append the generated function at the very end of the script. In C#, it will break compilation by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long

List<string> outputPaths = new();

bool embedBuildResults = (bool)GetOption("dotnet/embed_build_outputs") || platform == OS.Platforms.Android;
bool embedBuildResults = ((bool)GetOption("dotnet/embed_build_outputs") || platform == OS.Platforms.Android) && platform != OS.Platforms.MacOS;

foreach (PublishConfig config in targets)
{
Expand Down
2 changes: 2 additions & 0 deletions modules/mono/mono_gd/gd_mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ class GDMono {
void _try_load_project_assembly();
#endif

#ifdef DEBUG_METHODS_ENABLED
uint64_t api_core_hash = 0;
#endif
#ifdef TOOLS_ENABLED
uint64_t api_editor_hash = 0;
#endif
Expand Down
6 changes: 6 additions & 0 deletions platform/android/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,12 @@ bool EditorExportPlatformAndroid::get_export_option_visibility(const EditorExpor
// The APK templates are ignored if Gradle build is enabled.
return advanced_options_enabled && !bool(p_preset->get("gradle_build/use_gradle_build"));
}

// Hide .NET embedding option (always enabled).
if (p_option == "dotnet/embed_build_outputs") {
return false;
}

return true;
}

Expand Down
5 changes: 5 additions & 0 deletions platform/ios/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ void EditorExportPlatformIOS::_notification(int p_what) {
}

bool EditorExportPlatformIOS::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const {
// Hide unsupported .NET embedding option.
if (p_option == "dotnet/embed_build_outputs") {
return false;
}

return true;
}

Expand Down
19 changes: 13 additions & 6 deletions platform/linuxbsd/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,19 @@ List<String> EditorExportPlatformLinuxBSD::get_binary_extensions(const Ref<Edito
}

bool EditorExportPlatformLinuxBSD::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const {
if (p_preset) {
// Hide SSH options.
bool ssh = p_preset->get("ssh_remote_deploy/enabled");
if (!ssh && p_option != "ssh_remote_deploy/enabled" && p_option.begins_with("ssh_remote_deploy/")) {
return false;
}
if (p_preset == nullptr) {
return true;
}

bool advanced_options_enabled = p_preset->are_advanced_options_enabled();

// Hide SSH options.
bool ssh = p_preset->get("ssh_remote_deploy/enabled");
if (!ssh && p_option != "ssh_remote_deploy/enabled" && p_option.begins_with("ssh_remote_deploy/")) {
return false;
}
if (p_option == "dotnet/embed_build_outputs") {
return advanced_options_enabled;
}
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions platform/macos/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ bool EditorExportPlatformMacOS::get_export_option_visibility(const EditorExportP
return false;
}
}

// Hide unsupported .NET embedding option.
if (p_option == "dotnet/embed_build_outputs") {
return false;
}

return true;
}

Expand Down
9 changes: 9 additions & 0 deletions platform/windows/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,17 @@ String EditorExportPlatformWindows::get_export_option_warning(const EditorExport
}

bool EditorExportPlatformWindows::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const {
if (p_preset == nullptr) {
return true;
}

// This option is not supported by "osslsigncode", used on non-Windows host.
if (!OS::get_singleton()->has_feature("windows") && p_option == "codesign/identity_type") {
return false;
}

bool advanced_options_enabled = p_preset->are_advanced_options_enabled();

// Hide codesign.
bool codesign = p_preset->get("codesign/enable");
if (!codesign && p_option != "codesign/enable" && p_option.begins_with("codesign/")) {
Expand All @@ -390,6 +396,9 @@ bool EditorExportPlatformWindows::get_export_option_visibility(const EditorExpor
return false;
}

if (p_option == "dotnet/embed_build_outputs") {
return advanced_options_enabled;
}
return true;
}

Expand Down
Loading