From e919e908241a0d34ff10111d0518060491199435 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Tue, 8 Feb 2022 16:00:27 -0500 Subject: [PATCH 1/3] inputmethod: Revert to simpler style of word engine plugin loading The new style of plugin loading seems to be failing for some of the plugins despite the metadata being correct. This results in the plugin not being loaded, and appropriate integrations not working. Reverting to the simple check of whether the plugin.so exists results in the plugin always being loaded. In the future, we should however get rid of these compiled plugin libraries and extra QML, and use simple XML or JSON for the layout definitions instead. --- src/plugin/inputmethod.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugin/inputmethod.cpp b/src/plugin/inputmethod.cpp index 02390d63..222d8725 100644 --- a/src/plugin/inputmethod.cpp +++ b/src/plugin/inputmethod.cpp @@ -773,9 +773,8 @@ bool InputMethod::languageIsSupported(const QString plugin) { void InputMethod::onLanguageChanged(const QString &language) { Q_D(InputMethod); for (const auto& languagePath : std::as_const(d->languagesPaths)) { - QPluginLoader languagePlugin(QStringLiteral("%1/%2/lib%2plugin.so").arg(languagePath, language)); - const auto& metaData = languagePlugin.metaData(); - if (metaData.value(u8"IID").toString() == QLatin1String("io.maliit.keyboard.LanguagePlugin.1")) { + QFile languagePlugin(languagePath + QDir::separator() + language + QDir::separator() + QStringLiteral("lib%1plugin.so").arg(language)); + if (languagePlugin.exists()) { Q_EMIT languagePluginChanged(languagePlugin.fileName(), language); return; } From 93566a597a5a442ce0921b24fcbfa006e5d92e95 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Tue, 8 Feb 2022 16:07:29 -0500 Subject: [PATCH 2/3] CMake: Restore Thai plug-in to not needing to link to westernsupport Link the language plugins to the common library as they should have been, and remove the abstractlanguageplugin.{cpp,h} from westernsupport as they are already included in the keyboard library, linked by common. This allows for languages using AbstractLanguagePlugin, but which don't need to link against westersupport, such as Thai, to be built properly again. --- CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f728021..edd340b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,9 +80,7 @@ set(WESTERNSUPPORT_SOURCES plugins/westernsupport/westernlanguagesplugin.h plugins/westernsupport/westernsupport.cpp plugins/westernsupport/westernsupport.h - plugins/westernsupport/westernsupport_global.h - src/lib/logic/abstractlanguageplugin.cpp - src/lib/logic/abstractlanguageplugin.h) + plugins/westernsupport/westernsupport_global.h) # TODO install logic/languageplugininterface.h and logic/abstractplugininterface.h as HEADERS @@ -215,7 +213,7 @@ if(enable-presage) list(APPEND PLUGIN_SOURCES database_${_language}.db) endif() add_library(${_language}plugin MODULE ${PLUGIN_SOURCES}) - target_link_libraries(${_language}plugin westernsupport) + target_link_libraries(${_language}plugin maliit-keyboard-common westernsupport) install(FILES plugins/${_language}/qml/Keyboard_${_language}.qml plugins/${_language}/qml/Keyboard_${_language}_email.qml plugins/${_language}/qml/Keyboard_${_language}_url.qml @@ -279,7 +277,7 @@ function(abstract_language_plugin _language _full_language) list(APPEND PLUGIN_SOURCES database_${_language}.db) endif() add_library(${_target}plugin MODULE ${PLUGIN_SOURCES}) - target_link_libraries(${_target}plugin Qt5::Core Maliit::Plugins ${abstract_language_plugin_LIBRARIES}) + target_link_libraries(${_target}plugin Qt5::Core Maliit::Plugins maliit-keyboard-common ${abstract_language_plugin_LIBRARIES}) target_include_directories(${_target}plugin PRIVATE src/lib/logic ${abstract_language_plugin_INCLUDE_DIRS}) target_compile_definitions(${_target}plugin PRIVATE ${abstract_language_plugin_DEFINITIONS}) install(TARGETS ${_target}plugin @@ -344,7 +342,7 @@ abstract_language_plugin(en@dv englishdvorak FILES src/overrides.csv LIBRARIES westernsupport) abstract_language_plugin(fr-ch french LIBRARIES westernsupport) -abstract_language_plugin(th thai LIBRARIES westernsupport DIRECTORY qml/keys) +abstract_language_plugin(th thai DIRECTORY qml/keys) if(Anthy_FOUND) abstract_language_plugin(ja japanese ABSTRACT_LANGUAGE_PLUGIN From 1fc4cce5de90b2db6cbc523f7833734a0e524813 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Tue, 8 Feb 2022 16:20:24 -0500 Subject: [PATCH 3/3] CMake: Set OUTPUT_NAME on plugin libraries to the correct language name Work around CMake's handling of @ inside argument names that then end up getting defined as variable names in language_plugin as well. We also need to set the OUTPUT_NAME of these plugins back to the unmodified language value, so that the plugins can be properly loaded by the keyboard. --- CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edd340b1..2233e11b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,6 +205,13 @@ target_include_directories(westernsupport PUBLIC src/lib/logic plugins/westernsu target_compile_definitions(westernsupport PRIVATE ${maliit-keyboard-definitions}) function(language_plugin _language _full_language _ebook) + # To support layout style variations such as en@dv we need to avoid using + # the @ character in variables, so split and replace it with _ + set(_target ${_language}) + if(${_language} MATCHES "^(.*)\@(.*)$") + set(_target ${CMAKE_MATCH_1}_${CMAKE_MATCH_2}) + endif() + set(PLUGIN_SOURCES plugins/${_language}/src/${_full_language}plugin.h plugins/${_language}/src/${_full_language}plugin.json) @@ -212,14 +219,15 @@ if(enable-presage) add_ngram(TEXT plugins/${_language}/src/${_ebook} DATABASE database_${_language}.db) list(APPEND PLUGIN_SOURCES database_${_language}.db) endif() - add_library(${_language}plugin MODULE ${PLUGIN_SOURCES}) - target_link_libraries(${_language}plugin maliit-keyboard-common westernsupport) + add_library(${_target}plugin MODULE ${PLUGIN_SOURCES}) + set_target_properties(${_target}plugin PROPERTIES OUTPUT_NAME ${_language}plugin) + target_link_libraries(${_target}plugin maliit-keyboard-common westernsupport) install(FILES plugins/${_language}/qml/Keyboard_${_language}.qml plugins/${_language}/qml/Keyboard_${_language}_email.qml plugins/${_language}/qml/Keyboard_${_language}_url.qml plugins/${_language}/qml/Keyboard_${_language}_url_search.qml DESTINATION ${MALIIT_KEYBOARD_LANGUAGES_DIR}/${_language}) - install(TARGETS ${_language}plugin + install(TARGETS ${_target}plugin LIBRARY DESTINATION ${MALIIT_KEYBOARD_LANGUAGES_DIR}/${_language}) if(enable-presage) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/database_${_language}.db @@ -277,6 +285,7 @@ function(abstract_language_plugin _language _full_language) list(APPEND PLUGIN_SOURCES database_${_language}.db) endif() add_library(${_target}plugin MODULE ${PLUGIN_SOURCES}) + set_target_properties(${_target}plugin PROPERTIES OUTPUT_NAME ${_language}plugin) target_link_libraries(${_target}plugin Qt5::Core Maliit::Plugins maliit-keyboard-common ${abstract_language_plugin_LIBRARIES}) target_include_directories(${_target}plugin PRIVATE src/lib/logic ${abstract_language_plugin_INCLUDE_DIRS}) target_compile_definitions(${_target}plugin PRIVATE ${abstract_language_plugin_DEFINITIONS})