GDNative export: do not add fake lookup table if static lib is not used

This commit is contained in:
Sergey Minakov 2020-07-02 12:47:58 +03:00
parent 8fff25df09
commit 0e2bc779ed
1 changed files with 73 additions and 34 deletions

View File

@ -144,7 +144,45 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
}
}
// Add symbols for staticaly linked libraries on iOS
if (p_features.has("iOS")) {
bool should_fake_dynamic = false;
List<String> entry_keys;
config->get_section_keys("entry", &entry_keys);
for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) {
String key = E->get();
Vector<String> tags = key.split(".");
bool skip = false;
for (int i = 0; i < tags.size(); i++) {
bool has_feature = p_features.has(tags[i]);
if (!has_feature) {
skip = true;
break;
}
}
if (skip) {
continue;
}
String entry_lib_path = config->get_value("entry", key);
if (entry_lib_path.begins_with("res://") && entry_lib_path.ends_with(".a")) {
// If we find static library that was used for export
// we should add a fake loopup table.
// In case of dynamic library being used,
// this symbols will not cause any issues with library loading.
should_fake_dynamic = true;
break;
}
}
if (should_fake_dynamic) {
// Register symbols in the "fake" dynamic lookup table, because dlsym does not work well on iOS.
LibrarySymbol expected_symbols[] = {
{ "gdnative_init", true },
@ -187,6 +225,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
add_ios_linker_flags(linker_flags);
}
}
}
static void editor_init_callback() {