Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-i18n/librime/, app-i18n/librime/files/
Date: Mon, 28 Dec 2020 00:01:42
Message-Id: 1609113682.fe59e816cd7e2c280668084c7457bbdff4109740.floppym@gentoo
1 commit: fe59e816cd7e2c280668084c7457bbdff4109740
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
3 AuthorDate: Sun Dec 27 02:00:00 2020 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Mon Dec 28 00:01:22 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fe59e816
7
8 app-i18n/librime: Support plugins.
9
10 Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
11 Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
12
13 app-i18n/librime/files/librime-1.6.0-plugins.patch | 247 +++++++++++++++++++++
14 app-i18n/librime/files/librime-1.6.1-plugins.patch | 247 +++++++++++++++++++++
15 app-i18n/librime/librime-1.6.0.ebuild | 6 +-
16 app-i18n/librime/librime-1.6.1.ebuild | 6 +-
17 4 files changed, 504 insertions(+), 2 deletions(-)
18
19 diff --git a/app-i18n/librime/files/librime-1.6.0-plugins.patch b/app-i18n/librime/files/librime-1.6.0-plugins.patch
20 new file mode 100644
21 index 00000000000..c79072f31cb
22 --- /dev/null
23 +++ b/app-i18n/librime/files/librime-1.6.0-plugins.patch
24 @@ -0,0 +1,247 @@
25 +https://github.com/rime/librime/issues/431
26 +
27 +--- /CMakeLists.txt
28 ++++ /CMakeLists.txt
29 +@@ -11,6 +11,14 @@
30 +
31 + include(GNUInstallDirs)
32 +
33 ++if(NOT DEFINED BIN_INSTALL_DIR)
34 ++ set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
35 ++endif()
36 ++
37 ++if(NOT DEFINED LIB_INSTALL_DIR)
38 ++ set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
39 ++endif()
40 ++
41 + option(BUILD_SHARED_LIBS "Build Rime as shared library" ON)
42 + option(BUILD_MERGED_PLUGINS "Merge plugins into one Rime library" ON)
43 + option(BUILD_STATIC "Build with dependencies as static libraries" OFF)
44 +@@ -22,8 +30,11 @@
45 + option(BOOST_USE_CXX11 "Boost has been built with C++11 support" OFF)
46 + option(BOOST_USE_SIGNALS2 "Boost use signals2 instead of signals" ON)
47 + option(ENABLE_ASAN "Enable Address Sanitizer (Unix Only)" OFF)
48 ++option(INSTALL_PRIVATE_HEADERS "Install private headers (usually needed for externally built Rime plugins)" OFF)
49 ++option(ENABLE_EXTERNAL_PLUGINS "Enable loading of externally built Rime plugins (from directory set by RIME_PLUGINS_DIR variable)" OFF)
50 +
51 +-set(rime_data_dir "/share/rime-data" CACHE STRING "Target directory for Rime data")
52 ++set(RIME_DATA_DIR "share/rime-data" CACHE STRING "Target directory for Rime data")
53 ++set(RIME_PLUGINS_DIR "${LIB_INSTALL_DIR}/rime-plugins" CACHE STRING "Target directory for externally built Rime plugins")
54 +
55 + if(WIN32)
56 + set(ext ".exe")
57 +@@ -61,7 +72,7 @@
58 + set(BOOST_COMPONENTS filesystem regex system)
59 +
60 + if(BOOST_USE_SIGNALS2)
61 +- add_definitions("-DBOOST_SIGNALS2")
62 ++ set(RIME_BOOST_SIGNALS2 1)
63 + else()
64 + set(BOOST_COMPONENTS ${BOOST_COMPONENTS} signals)
65 + endif()
66 +@@ -89,7 +100,7 @@
67 + add_definitions(-DGOOGLE_GLOG_DLL_DECL=)
68 + endif()
69 +
70 +- add_definitions(-DRIME_ENABLE_LOGGING)
71 ++ set(RIME_ENABLE_LOGGING 1)
72 +
73 + endif()
74 +
75 +@@ -134,6 +145,11 @@
76 + message(WARNING "X11/keysym.h not found.")
77 + endif()
78 +
79 ++configure_file(
80 ++ "${PROJECT_SOURCE_DIR}/src/rime/build_config.h.in"
81 ++ "${PROJECT_BINARY_DIR}/src/rime/build_config.h")
82 ++
83 ++include_directories(${PROJECT_BINARY_DIR}/src)
84 + include_directories(${PROJECT_SOURCE_DIR}/src)
85 + include_directories(${PROJECT_SOURCE_DIR}/thirdparty/include)
86 + link_directories(${PROJECT_SOURCE_DIR}/thirdparty/lib)
87 +@@ -154,14 +170,6 @@
88 + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
89 + endif()
90 +
91 +-if(NOT DEFINED LIB_INSTALL_DIR)
92 +- set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
93 +-endif()
94 +-
95 +-if(NOT DEFINED BIN_INSTALL_DIR)
96 +- set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
97 +-endif()
98 +-
99 + # uninstall target
100 + configure_file(
101 + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
102 +@@ -175,7 +183,8 @@
103 + set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
104 + set(bindir "${exec_prefix}/${BIN_INSTALL_DIR}")
105 + set(libdir "${exec_prefix}/${LIB_INSTALL_DIR}")
106 +- set(pkgdatadir "${prefix}${rime_data_dir}")
107 ++ set(pkgdatadir "${prefix}/${RIME_DATA_DIR}")
108 ++ set(pluginsdir "${exec_prefix}/${RIME_PLUGINS_DIR}")
109 + set(includedir "${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
110 + configure_file(
111 + ${PROJECT_SOURCE_DIR}/rime.pc.in
112 +@@ -189,11 +198,19 @@
113 +
114 + file(GLOB rime_public_header_files ${PROJECT_SOURCE_DIR}/src/*.h)
115 + install(FILES ${rime_public_header_files} DESTINATION include)
116 ++if(INSTALL_PRIVATE_HEADERS)
117 ++ file(GLOB rime_private_header_files ${PROJECT_SOURCE_DIR}/src/rime/*.h ${PROJECT_BINARY_DIR}/src/rime/*.h)
118 ++ install(FILES ${rime_private_header_files} DESTINATION include/rime)
119 ++ foreach(rime_private_header_files_dir algo config dict gear lever)
120 ++ file(GLOB rime_private_header_files ${PROJECT_SOURCE_DIR}/src/rime/${rime_private_header_files_dir}/*.h)
121 ++ install(FILES ${rime_private_header_files} DESTINATION include/rime/${rime_private_header_files_dir})
122 ++ endforeach()
123 ++endif()
124 +
125 + if(BUILD_DATA)
126 + file(GLOB rime_preset_data_files ${PROJECT_SOURCE_DIR}/data/preset/*.yaml)
127 + install(FILES ${rime_preset_data_files}
128 +- DESTINATION ${CMAKE_INSTALL_PREFIX}${rime_data_dir})
129 ++ DESTINATION ${CMAKE_INSTALL_PREFIX}/${RIME_DATA_DIR})
130 + endif()
131 +
132 + if(BUILD_SHARED_LIBS)
133 +@@ -223,6 +240,11 @@
134 + set(rime_plugins_library rime-plugins)
135 + endif()
136 +
137 ++add_definitions("-DRIME_PLUGINS_DIR=\"${CMAKE_INSTALL_PREFIX}/${RIME_PLUGINS_DIR}\"")
138 ++if(ENABLE_EXTERNAL_PLUGINS)
139 ++ add_definitions(-DRIME_ENABLE_EXTERNAL_PLUGINS)
140 ++endif()
141 ++
142 + add_subdirectory(src)
143 +
144 + if(BUILD_SHARED_LIBS)
145 +--- /rime.pc.in
146 ++++ /rime.pc.in
147 +@@ -2,6 +2,8 @@
148 + exec_prefix=@exec_prefix@
149 + libdir=@libdir@
150 + includedir=@includedir@
151 ++pkgdatadir=@pkgdatadir@
152 ++pluginsdir=@pluginsdir@
153 +
154 + Name: Rime
155 + Description: Rime Input Method Engine
156 +--- /src/CMakeLists.txt
157 ++++ /src/CMakeLists.txt
158 +@@ -36,6 +36,9 @@
159 + if(Gflags_FOUND)
160 + set(rime_optional_deps ${rime_optional_deps} ${Gflags_LIBRARY})
161 + endif()
162 ++if(ENABLE_EXTERNAL_PLUGINS)
163 ++ set(rime_optional_deps ${rime_optional_deps} dl)
164 ++endif()
165 +
166 + set(rime_core_deps
167 + ${Boost_LIBRARIES}
168 +--- /src/rime/build_config.h.in
169 ++++ /src/rime/build_config.h.in
170 +@@ -0,0 +1,11 @@
171 ++//
172 ++// Copyright RIME Developers
173 ++// Distributed under the BSD License
174 ++//
175 ++#ifndef RIME_BUILD_CONFIG_H_
176 ++#define RIME_BUILD_CONFIG_H_
177 ++
178 ++#cmakedefine RIME_BOOST_SIGNALS2
179 ++#cmakedefine RIME_ENABLE_LOGGING
180 ++
181 ++#endif // RIME_BUILD_CONFIG_H_
182 +--- /src/rime/common.h
183 ++++ /src/rime/common.h
184 +@@ -7,6 +7,8 @@
185 + #ifndef RIME_COMMON_H_
186 + #define RIME_COMMON_H_
187 +
188 ++#include <rime/build_config.h>
189 ++
190 + #include <functional>
191 + #include <list>
192 + #include <map>
193 +@@ -20,7 +22,7 @@
194 + #include <vector>
195 + #include <boost/optional.hpp>
196 + #define BOOST_BIND_NO_PLACEHOLDERS
197 +-#ifdef BOOST_SIGNALS2
198 ++#ifdef RIME_BOOST_SIGNALS2
199 + #include <boost/signals2/connection.hpp>
200 + #include <boost/signals2/signal.hpp>
201 + #else
202 +@@ -79,7 +81,7 @@
203 + return std::make_shared<T>(std::forward<Args>(args)...);
204 + }
205 +
206 +-#ifdef BOOST_SIGNALS2
207 ++#ifdef RIME_BOOST_SIGNALS2
208 + using boost::signals2::connection;
209 + using boost::signals2::signal;
210 + #else
211 +--- /src/rime/lever/deployment_tasks.cc
212 ++++ /src/rime/lever/deployment_tasks.cc
213 +@@ -4,6 +4,9 @@
214 + //
215 + // 2011-12-10 GONG Chen <chen.sst@×××××.com>
216 + //
217 ++
218 ++#include <rime/build_config.h>
219 ++
220 + #include <algorithm>
221 + #include <boost/algorithm/string.hpp>
222 + #include <boost/filesystem.hpp>
223 +--- /src/rime/setup.cc
224 ++++ /src/rime/setup.cc
225 +@@ -5,6 +5,13 @@
226 + // 2011-10-02 GONG Chen <chen.sst@×××××.com>
227 + //
228 +
229 ++#include <rime/build_config.h>
230 ++
231 ++#ifdef RIME_ENABLE_EXTERNAL_PLUGINS
232 ++#include <dlfcn.h>
233 ++#include <glob.h>
234 ++#endif // RIME_ENABLE_EXTERNAL_PLUGINS
235 ++
236 + #ifdef RIME_ENABLE_LOGGING
237 + #include <glog/logging.h>
238 + #endif // RIME_ENABLE_LOGGING
239 +@@ -33,6 +40,32 @@
240 + mm.LoadModule(module);
241 + }
242 + }
243 ++
244 ++#ifdef RIME_ENABLE_EXTERNAL_PLUGINS
245 ++ fs::path plugins_dir = fs::path(RIME_PLUGINS_DIR);
246 ++ fs::path plugins_files = plugins_dir / "*.so";
247 ++ glob_t glob_buffer;
248 ++ if (glob(plugins_files.string().c_str(), 0, NULL, &glob_buffer) == 0) {
249 ++ for (size_t i = 0; i < glob_buffer.gl_pathc; i++) {
250 ++ fs::path plugin_file(glob_buffer.gl_pathv[i]);
251 ++ fs::path plugin_name = plugin_file.stem();
252 ++ fs::file_status plugin_file_status = fs::status(plugin_file);
253 ++ if (fs::is_regular_file(plugin_file) &&
254 ++ plugin_file_status.permissions() & (fs::owner_exe | fs::group_exe | fs::others_exe)) {
255 ++ void* handle = dlopen(plugin_file.string().c_str(), RTLD_LAZY);
256 ++ if (handle) {
257 ++ if (RimeModule* module = mm.Find(plugin_name.string())) {
258 ++ mm.LoadModule(module);
259 ++ }
260 ++ }
261 ++ else {
262 ++ LOG(ERROR) << "dlopen error: " << dlerror();
263 ++ }
264 ++ }
265 ++ }
266 ++ globfree(&glob_buffer);
267 ++ }
268 ++#endif
269 + }
270 +
271 + // assume member is a non-null pointer in struct *p.
272
273 diff --git a/app-i18n/librime/files/librime-1.6.1-plugins.patch b/app-i18n/librime/files/librime-1.6.1-plugins.patch
274 new file mode 100644
275 index 00000000000..68099d61869
276 --- /dev/null
277 +++ b/app-i18n/librime/files/librime-1.6.1-plugins.patch
278 @@ -0,0 +1,247 @@
279 +https://github.com/rime/librime/issues/431
280 +
281 +--- /CMakeLists.txt
282 ++++ /CMakeLists.txt
283 +@@ -11,6 +11,14 @@
284 +
285 + include(GNUInstallDirs)
286 +
287 ++if(NOT DEFINED BIN_INSTALL_DIR)
288 ++ set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
289 ++endif()
290 ++
291 ++if(NOT DEFINED LIB_INSTALL_DIR)
292 ++ set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
293 ++endif()
294 ++
295 + option(BUILD_SHARED_LIBS "Build Rime as shared library" ON)
296 + option(BUILD_MERGED_PLUGINS "Merge plugins into one Rime library" ON)
297 + option(BUILD_STATIC "Build with dependencies as static libraries" OFF)
298 +@@ -22,8 +30,11 @@
299 + option(BOOST_USE_CXX11 "Boost has been built with C++11 support" OFF)
300 + option(BOOST_USE_SIGNALS2 "Boost use signals2 instead of signals" ON)
301 + option(ENABLE_ASAN "Enable Address Sanitizer (Unix Only)" OFF)
302 ++option(INSTALL_PRIVATE_HEADERS "Install private headers (usually needed for externally built Rime plugins)" OFF)
303 ++option(ENABLE_EXTERNAL_PLUGINS "Enable loading of externally built Rime plugins (from directory set by RIME_PLUGINS_DIR variable)" OFF)
304 +
305 +-set(rime_data_dir "/share/rime-data" CACHE STRING "Target directory for Rime data")
306 ++set(RIME_DATA_DIR "share/rime-data" CACHE STRING "Target directory for Rime data")
307 ++set(RIME_PLUGINS_DIR "${LIB_INSTALL_DIR}/rime-plugins" CACHE STRING "Target directory for externally built Rime plugins")
308 +
309 + if(WIN32)
310 + set(ext ".exe")
311 +@@ -61,7 +72,7 @@
312 + set(BOOST_COMPONENTS filesystem regex system)
313 +
314 + if(BOOST_USE_SIGNALS2)
315 +- add_definitions("-DBOOST_SIGNALS2")
316 ++ set(RIME_BOOST_SIGNALS2 1)
317 + else()
318 + set(BOOST_COMPONENTS ${BOOST_COMPONENTS} signals)
319 + endif()
320 +@@ -89,7 +100,7 @@
321 + add_definitions(-DGOOGLE_GLOG_DLL_DECL=)
322 + endif()
323 +
324 +- add_definitions(-DRIME_ENABLE_LOGGING)
325 ++ set(RIME_ENABLE_LOGGING 1)
326 +
327 + endif()
328 +
329 +@@ -134,6 +145,11 @@
330 + message(WARNING "X11/keysym.h not found.")
331 + endif()
332 +
333 ++configure_file(
334 ++ "${PROJECT_SOURCE_DIR}/src/rime/build_config.h.in"
335 ++ "${PROJECT_BINARY_DIR}/src/rime/build_config.h")
336 ++
337 ++include_directories(${PROJECT_BINARY_DIR}/src)
338 + include_directories(${PROJECT_SOURCE_DIR}/src)
339 + include_directories(${PROJECT_SOURCE_DIR}/thirdparty/include)
340 + link_directories(${PROJECT_SOURCE_DIR}/thirdparty/lib)
341 +@@ -154,14 +170,6 @@
342 + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
343 + endif()
344 +
345 +-if(NOT DEFINED LIB_INSTALL_DIR)
346 +- set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
347 +-endif()
348 +-
349 +-if(NOT DEFINED BIN_INSTALL_DIR)
350 +- set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
351 +-endif()
352 +-
353 + # uninstall target
354 + configure_file(
355 + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
356 +@@ -175,7 +183,8 @@
357 + set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
358 + set(bindir "${exec_prefix}/${BIN_INSTALL_DIR}")
359 + set(libdir "${exec_prefix}/${LIB_INSTALL_DIR}")
360 +- set(pkgdatadir "${prefix}${rime_data_dir}")
361 ++ set(pkgdatadir "${prefix}/${RIME_DATA_DIR}")
362 ++ set(pluginsdir "${exec_prefix}/${RIME_PLUGINS_DIR}")
363 + set(includedir "${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
364 + configure_file(
365 + ${PROJECT_SOURCE_DIR}/rime.pc.in
366 +@@ -189,11 +198,19 @@
367 +
368 + file(GLOB rime_public_header_files ${PROJECT_SOURCE_DIR}/src/*.h)
369 + install(FILES ${rime_public_header_files} DESTINATION include)
370 ++if(INSTALL_PRIVATE_HEADERS)
371 ++ file(GLOB rime_private_header_files ${PROJECT_SOURCE_DIR}/src/rime/*.h ${PROJECT_BINARY_DIR}/src/rime/*.h)
372 ++ install(FILES ${rime_private_header_files} DESTINATION include/rime)
373 ++ foreach(rime_private_header_files_dir algo config dict gear lever)
374 ++ file(GLOB rime_private_header_files ${PROJECT_SOURCE_DIR}/src/rime/${rime_private_header_files_dir}/*.h)
375 ++ install(FILES ${rime_private_header_files} DESTINATION include/rime/${rime_private_header_files_dir})
376 ++ endforeach()
377 ++endif()
378 +
379 + if(BUILD_DATA)
380 + file(GLOB rime_preset_data_files ${PROJECT_SOURCE_DIR}/data/preset/*.yaml)
381 + install(FILES ${rime_preset_data_files}
382 +- DESTINATION ${CMAKE_INSTALL_PREFIX}${rime_data_dir})
383 ++ DESTINATION ${CMAKE_INSTALL_PREFIX}/${RIME_DATA_DIR})
384 + endif()
385 +
386 + if(BUILD_SHARED_LIBS)
387 +@@ -223,6 +240,11 @@
388 + set(rime_plugins_library rime-plugins)
389 + endif()
390 +
391 ++add_definitions("-DRIME_PLUGINS_DIR=\"${CMAKE_INSTALL_PREFIX}/${RIME_PLUGINS_DIR}\"")
392 ++if(ENABLE_EXTERNAL_PLUGINS)
393 ++ add_definitions(-DRIME_ENABLE_EXTERNAL_PLUGINS)
394 ++endif()
395 ++
396 + add_subdirectory(src)
397 +
398 + if(BUILD_SHARED_LIBS)
399 +--- /rime.pc.in
400 ++++ /rime.pc.in
401 +@@ -2,6 +2,8 @@
402 + exec_prefix=@exec_prefix@
403 + libdir=@libdir@
404 + includedir=@includedir@
405 ++pkgdatadir=@pkgdatadir@
406 ++pluginsdir=@pluginsdir@
407 +
408 + Name: Rime
409 + Description: Rime Input Method Engine
410 +--- /src/CMakeLists.txt
411 ++++ /src/CMakeLists.txt
412 +@@ -36,6 +36,9 @@
413 + if(Gflags_FOUND)
414 + set(rime_optional_deps ${rime_optional_deps} ${Gflags_LIBRARY})
415 + endif()
416 ++if(ENABLE_EXTERNAL_PLUGINS)
417 ++ set(rime_optional_deps ${rime_optional_deps} dl)
418 ++endif()
419 +
420 + set(rime_core_deps
421 + ${Boost_LIBRARIES}
422 +--- /src/rime/build_config.h.in
423 ++++ /src/rime/build_config.h.in
424 +@@ -0,0 +1,11 @@
425 ++//
426 ++// Copyright RIME Developers
427 ++// Distributed under the BSD License
428 ++//
429 ++#ifndef RIME_BUILD_CONFIG_H_
430 ++#define RIME_BUILD_CONFIG_H_
431 ++
432 ++#cmakedefine RIME_BOOST_SIGNALS2
433 ++#cmakedefine RIME_ENABLE_LOGGING
434 ++
435 ++#endif // RIME_BUILD_CONFIG_H_
436 +--- /src/rime/common.h
437 ++++ /src/rime/common.h
438 +@@ -7,6 +7,8 @@
439 + #ifndef RIME_COMMON_H_
440 + #define RIME_COMMON_H_
441 +
442 ++#include <rime/build_config.h>
443 ++
444 + #include <functional>
445 + #include <list>
446 + #include <map>
447 +@@ -20,7 +22,7 @@
448 + #include <vector>
449 + #include <boost/optional.hpp>
450 + #define BOOST_BIND_NO_PLACEHOLDERS
451 +-#ifdef BOOST_SIGNALS2
452 ++#ifdef RIME_BOOST_SIGNALS2
453 + #include <boost/signals2/connection.hpp>
454 + #include <boost/signals2/signal.hpp>
455 + #else
456 +@@ -79,7 +81,7 @@
457 + return std::make_shared<T>(std::forward<Args>(args)...);
458 + }
459 +
460 +-#ifdef BOOST_SIGNALS2
461 ++#ifdef RIME_BOOST_SIGNALS2
462 + using boost::signals2::connection;
463 + using boost::signals2::signal;
464 + #else
465 +--- /src/rime/lever/deployment_tasks.cc
466 ++++ /src/rime/lever/deployment_tasks.cc
467 +@@ -4,6 +4,9 @@
468 + //
469 + // 2011-12-10 GONG Chen <chen.sst@×××××.com>
470 + //
471 ++
472 ++#include <rime/build_config.h>
473 ++
474 + #include <algorithm>
475 + #include <boost/algorithm/string.hpp>
476 + #include <boost/filesystem.hpp>
477 +--- /src/rime/setup.cc
478 ++++ /src/rime/setup.cc
479 +@@ -5,6 +5,13 @@
480 + // 2011-10-02 GONG Chen <chen.sst@×××××.com>
481 + //
482 +
483 ++#include <rime/build_config.h>
484 ++
485 ++#ifdef RIME_ENABLE_EXTERNAL_PLUGINS
486 ++#include <dlfcn.h>
487 ++#include <glob.h>
488 ++#endif // RIME_ENABLE_EXTERNAL_PLUGINS
489 ++
490 + #ifdef RIME_ENABLE_LOGGING
491 + #include <glog/logging.h>
492 + #endif // RIME_ENABLE_LOGGING
493 +@@ -36,6 +43,32 @@
494 + mm.LoadModule(module);
495 + }
496 + }
497 ++
498 ++#ifdef RIME_ENABLE_EXTERNAL_PLUGINS
499 ++ fs::path plugins_dir = fs::path(RIME_PLUGINS_DIR);
500 ++ fs::path plugins_files = plugins_dir / "*.so";
501 ++ glob_t glob_buffer;
502 ++ if (glob(plugins_files.string().c_str(), 0, NULL, &glob_buffer) == 0) {
503 ++ for (size_t i = 0; i < glob_buffer.gl_pathc; i++) {
504 ++ fs::path plugin_file(glob_buffer.gl_pathv[i]);
505 ++ fs::path plugin_name = plugin_file.stem();
506 ++ fs::file_status plugin_file_status = fs::status(plugin_file);
507 ++ if (fs::is_regular_file(plugin_file) &&
508 ++ plugin_file_status.permissions() & (fs::owner_exe | fs::group_exe | fs::others_exe)) {
509 ++ void* handle = dlopen(plugin_file.string().c_str(), RTLD_LAZY);
510 ++ if (handle) {
511 ++ if (RimeModule* module = mm.Find(plugin_name.string())) {
512 ++ mm.LoadModule(module);
513 ++ }
514 ++ }
515 ++ else {
516 ++ LOG(ERROR) << "dlopen error: " << dlerror();
517 ++ }
518 ++ }
519 ++ }
520 ++ globfree(&glob_buffer);
521 ++ }
522 ++#endif
523 + }
524 +
525 + // assume member is a non-null pointer in struct *p.
526
527 diff --git a/app-i18n/librime/librime-1.6.0.ebuild b/app-i18n/librime/librime-1.6.0.ebuild
528 index 674c8ae665e..eef1faa5bd5 100644
529 --- a/app-i18n/librime/librime-1.6.0.ebuild
530 +++ b/app-i18n/librime/librime-1.6.0.ebuild
531 @@ -21,7 +21,7 @@ else
532 fi
533
534 LICENSE="BSD"
535 -SLOT="0/1"
536 +SLOT="0/1-${PV}"
537 KEYWORDS="~amd64 ~arm64 ~x86"
538 IUSE="debug test"
539 RESTRICT="!test? ( test )"
540 @@ -43,6 +43,8 @@ DEPEND="${RDEPEND}
541 DOCS=(CHANGELOG.md README.md)
542
543 src_prepare() {
544 + eapply "${FILESDIR}/${PN}-1.6.0-plugins.patch"
545 +
546 # Use headers of dev-libs/darts, dev-libs/utfcpp and x11-base/xorg-proto.
547 sed -e "/\${PROJECT_SOURCE_DIR}\/thirdparty/d" -i CMakeLists.txt || die
548 rm -r thirdparty || die
549 @@ -63,6 +65,8 @@ src_configure() {
550 -DBOOST_USE_CXX11=ON
551 -DBUILD_TEST=$(usex test ON OFF)
552 -DCMAKE_DISABLE_FIND_PACKAGE_Gflags=ON
553 + -DENABLE_EXTERNAL_PLUGINS=ON
554 + -DINSTALL_PRIVATE_HEADERS=ON
555 )
556
557 cmake_src_configure
558
559 diff --git a/app-i18n/librime/librime-1.6.1.ebuild b/app-i18n/librime/librime-1.6.1.ebuild
560 index 674c8ae665e..91cdfdf161d 100644
561 --- a/app-i18n/librime/librime-1.6.1.ebuild
562 +++ b/app-i18n/librime/librime-1.6.1.ebuild
563 @@ -21,7 +21,7 @@ else
564 fi
565
566 LICENSE="BSD"
567 -SLOT="0/1"
568 +SLOT="0/1-${PV}"
569 KEYWORDS="~amd64 ~arm64 ~x86"
570 IUSE="debug test"
571 RESTRICT="!test? ( test )"
572 @@ -43,6 +43,8 @@ DEPEND="${RDEPEND}
573 DOCS=(CHANGELOG.md README.md)
574
575 src_prepare() {
576 + eapply "${FILESDIR}/${PN}-1.6.1-plugins.patch"
577 +
578 # Use headers of dev-libs/darts, dev-libs/utfcpp and x11-base/xorg-proto.
579 sed -e "/\${PROJECT_SOURCE_DIR}\/thirdparty/d" -i CMakeLists.txt || die
580 rm -r thirdparty || die
581 @@ -63,6 +65,8 @@ src_configure() {
582 -DBOOST_USE_CXX11=ON
583 -DBUILD_TEST=$(usex test ON OFF)
584 -DCMAKE_DISABLE_FIND_PACKAGE_Gflags=ON
585 + -DENABLE_EXTERNAL_PLUGINS=ON
586 + -DINSTALL_PRIVATE_HEADERS=ON
587 )
588
589 cmake_src_configure