Skip to content

Commit fb649b5

Browse files
committed
drop upstreamed patch
1 parent 934524a commit fb649b5

File tree

9 files changed

+146
-245
lines changed

9 files changed

+146
-245
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
export EMCC_FORCE_STDLIBS=libc++
5252
export FCITX_DISTRIBUTION=fcitx5-js
5353
pushd fcitx5 && git apply ../patches/fcitx5.patch && popd
54-
PKG_CONFIG_PATH="build/sysroot/usr/share/pkgconfig;build/sysroot/usr/lib/pkgconfig" emcmake cmake -B build -G Ninja \
54+
emcmake cmake -B build -G Ninja \
5555
-DCMAKE_BUILD_TYPE=Release \
5656
-DCMAKE_FIND_ROOT_PATH="$(pwd)/build/sysroot/usr" \
5757
-DCMAKE_INSTALL_PREFIX=/usr

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-sSIDE_MODULE")
1111
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-sSIDE_MODULE")
1212
add_compile_options(-fPIC -fexceptions)
1313

14+
set(ENV{PKG_CONFIG_PATH} "build/sysroot/usr/share/pkgconfig;build/sysroot/usr/lib/pkgconfig")
15+
1416
set(fmt_DIR "build/sysroot/usr/lib/cmake/fmt")
1517
find_package(fmt REQUIRED)
1618
set(ECM_DIR "/usr/share/ECM/cmake")

patches/fcitx5.patch

Lines changed: 2 additions & 242 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,3 @@
1-
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index ac1e1dcb..b4641520 100644
3-
--- a/CMakeLists.txt
4-
+++ b/CMakeLists.txt
5-
@@ -36,6 +36,7 @@ option(ENABLE_XDGAUTOSTART "Enable xdg autostart desktop file installation" On)
6-
option(USE_FLATPAK_ICON "Use flatpak icon name for desktop files" Off)
7-
option(ENABLE_EMOJI "Enable emoji module" On)
8-
option(ENABLE_LIBUUID "Use libuuid for uuid generation" On)
9-
+option(BUILD_SPELL_DICT "Build en_dict.fscd for English spell check" On)
10-
set(NO_PREEDIT_APPS "gvim.*,wps.*,wpp.*,et.*" CACHE STRING "Disable preedit for follwing app by default.")
11-
12-
if (ENABLE_EMOJI)
13-
@@ -69,7 +70,7 @@ if (NOT TARGET Systemd::Systemd)
14-
pkg_get_variable(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "dbus-1" "system_bus_default_address")
15-
endif()
16-
17-
- if (NOT LIBUV_TARGET)
18-
+ if (NOT LIBUV_TARGET AND NOT EMSCRIPTEN)
19-
if (NOT (TARGET PkgConfig::LibUV))
20-
pkg_check_modules(LibUV REQUIRED IMPORTED_TARGET "libuv")
21-
endif()
22-
diff --git a/cmake/Fcitx5CompilerSettings.cmake b/cmake/Fcitx5CompilerSettings.cmake
23-
index 66136f0b..5e766d30 100644
24-
--- a/cmake/Fcitx5CompilerSettings.cmake
25-
+++ b/cmake/Fcitx5CompilerSettings.cmake
26-
@@ -8,7 +8,7 @@ set(CMAKE_C_STANDARD 99)
27-
set(CMAKE_C_FLAGS "-Wall -Wextra ${CMAKE_C_FLAGS}")
28-
set(CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}")
29-
30-
-if(NOT APPLE)
31-
+if(NOT APPLE AND NOT EMSCRIPTEN)
32-
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined -Wl,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}")
33-
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined -Wl,--as-needed ${CMAKE_MODULE_LINKER_FLAGS}")
34-
endif()
351
diff --git a/src/lib/fcitx-config/CMakeLists.txt b/src/lib/fcitx-config/CMakeLists.txt
362
index 85c9865b..3a995ca1 100644
373
--- a/src/lib/fcitx-config/CMakeLists.txt
@@ -47,32 +13,10 @@ index 85c9865b..3a995ca1 100644
4713
)
4814
target_include_directories(Fcitx5Config PUBLIC
4915
diff --git a/src/lib/fcitx-utils/CMakeLists.txt b/src/lib/fcitx-utils/CMakeLists.txt
50-
index dd67e07d..21680660 100644
16+
index 15ad8c8a..5532dc33 100644
5117
--- a/src/lib/fcitx-utils/CMakeLists.txt
5218
+++ b/src/lib/fcitx-utils/CMakeLists.txt
53-
@@ -27,14 +27,18 @@ if (ENABLE_DBUS)
54-
endif()
55-
endif()
56-
57-
-if (NOT TARGET Systemd::Systemd)
58-
+if (TARGET Systemd::Systemd)
59-
set(FCITX_UTILS_SOURCES
60-
${FCITX_UTILS_SOURCES}
61-
- event_libuv.cpp)
62-
+ event_sdevent.cpp)
63-
+elseif (EMSCRIPTEN)
64-
+ set(FCITX_UTILS_SOURCES
65-
+ ${FCITX_UTILS_SOURCES}
66-
+ event_js.cpp)
67-
else()
68-
set(FCITX_UTILS_SOURCES
69-
${FCITX_UTILS_SOURCES}
70-
- event_sdevent.cpp)
71-
+ event_libuv.cpp)
72-
endif()
73-
74-
set(FCITX_UTILS_SOURCES
75-
@@ -121,8 +125,7 @@ ecm_setup_version(PROJECT
19+
@@ -127,8 +127,7 @@ ecm_setup_version(PROJECT
7620

7721
add_library(Fcitx5Utils SHARED ${FCITX_UTILS_SOURCES})
7822
set_target_properties(Fcitx5Utils
@@ -82,173 +26,6 @@ index dd67e07d..21680660 100644
8226
EXPORT_NAME Utils
8327
)
8428
target_include_directories(Fcitx5Utils PUBLIC
85-
@@ -135,7 +138,7 @@ if(LIBKVM_FOUND)
86-
endif()
87-
88-
if (NOT TARGET Systemd::Systemd)
89-
- target_link_libraries(Fcitx5Utils PRIVATE ${LIBUV_TARGET})
90-
+ # target_link_libraries(Fcitx5Utils PRIVATE ${LIBUV_TARGET})
91-
if (ENABLE_DBUS)
92-
target_link_libraries(Fcitx5Utils PRIVATE PkgConfig::DBus)
93-
endif()
94-
diff --git a/src/lib/fcitx-utils/endian_p.h b/src/lib/fcitx-utils/endian_p.h
95-
index d524dfa2..524a26fa 100644
96-
--- a/src/lib/fcitx-utils/endian_p.h
97-
+++ b/src/lib/fcitx-utils/endian_p.h
98-
@@ -8,7 +8,7 @@
99-
#define _FCITX_UTILS_ENDIAN_P_H_
100-
101-
#include <cstdint>
102-
-#if defined(__linux__) || defined(__GLIBC__)
103-
+#if defined(__linux__) || defined(__GLIBC__) || defined(__EMSCRIPTEN__)
104-
#include <endian.h>
105-
#elif defined(__APPLE__)
106-
107-
diff --git a/src/lib/fcitx-utils/event_js.cpp b/src/lib/fcitx-utils/event_js.cpp
108-
new file mode 100644
109-
index 00000000..68f7ee7f
110-
--- /dev/null
111-
+++ b/src/lib/fcitx-utils/event_js.cpp
112-
@@ -0,0 +1,139 @@
113-
+#include <cassert>
114-
+#include <emscripten.h>
115-
+#include "event.h"
116-
+#include "log.h"
117-
+
118-
+namespace fcitx {
119-
+
120-
+template <typename Interface>
121-
+struct JSEventSourceBase : public Interface {
122-
+public:
123-
+ ~JSEventSourceBase() override {}
124-
+
125-
+ bool isEnabled() const override { return enabled_; }
126-
+
127-
+ void setEnabled(bool enabled) override { enabled_ = enabled; }
128-
+
129-
+ bool isOneShot() const override { return oneShot_; }
130-
+
131-
+ void setOneShot() override { oneShot_ = true; }
132-
+
133-
+private:
134-
+ bool enabled_ = false;
135-
+ bool oneShot_ = false;
136-
+};
137-
+
138-
+struct JSEventSource : public JSEventSourceBase<EventSource> {
139-
+ JSEventSource(EventCallback _callback)
140-
+ : callback_(std::make_shared<EventCallback>(std::move(_callback))) {}
141-
+
142-
+ std::shared_ptr<EventCallback> callback_;
143-
+};
144-
+
145-
+struct JSEventSourceIO : public JSEventSourceBase<EventSourceIO> {
146-
+ JSEventSourceIO(IOCallback _callback) {}
147-
+
148-
+ int fd() const override { return 0; }
149-
+
150-
+ void setFd(int fd) override {}
151-
+
152-
+ IOEventFlags events() const override { return IOEventFlag::In; }
153-
+
154-
+ void setEvents(IOEventFlags flags) override {}
155-
+
156-
+ IOEventFlags revents() const override { return IOEventFlag::In; }
157-
+};
158-
+
159-
+void TimeEventCallback(void *arg);
160-
+
161-
+struct JSEventSourceTime : public JSEventSourceBase<EventSourceTime> {
162-
+ JSEventSourceTime(TimeCallback _callback, uint64_t time, clockid_t clockid)
163-
+ : callback_(std::make_shared<TimeCallback>(std::move(_callback))),
164-
+ time_(time), clockid_(clockid) {
165-
+ assert(clockid == CLOCK_MONOTONIC);
166-
+ setOneShot();
167-
+ }
168-
+
169-
+ void setOneShot() override {
170-
+ int t = std::max<int64_t>(0, time_ - now(CLOCK_MONOTONIC)) / 1000;
171-
+ emscripten_async_call(TimeEventCallback, this, t);
172-
+ }
173-
+
174-
+ uint64_t time() const override { return time_; }
175-
+
176-
+ void setTime(uint64_t time) override { time_ = time; }
177-
+
178-
+ uint64_t accuracy() const override { return 0; }
179-
+
180-
+ void setAccuracy(uint64_t time) override {}
181-
+
182-
+ clockid_t clock() const override { return clockid_; }
183-
+
184-
+ std::shared_ptr<TimeCallback> callback_;
185-
+
186-
+private:
187-
+ uint64_t time_;
188-
+ clockid_t clockid_;
189-
+};
190-
+
191-
+void TimeEventCallback(void *arg) {
192-
+ auto source = static_cast<JSEventSourceTime *>(arg);
193-
+ (*source->callback_)(source, source->time());
194-
+}
195-
+
196-
+class EventLoopPrivate {
197-
+public:
198-
+ EventLoopPrivate() {}
199-
+
200-
+ ~EventLoopPrivate() {}
201-
+};
202-
+
203-
+EventLoop::EventLoop() : d_ptr(std::make_unique<EventLoopPrivate>()) {}
204-
+
205-
+EventLoop::~EventLoop() = default;
206-
+
207-
+const char *EventLoop::impl() { return "js-event"; }
208-
+
209-
+void *EventLoop::nativeHandle() { return nullptr; }
210-
+
211-
+bool EventLoop::exec() { return true; }
212-
+
213-
+void EventLoop::exit() {}
214-
+
215-
+std::unique_ptr<EventSourceIO> EventLoop::addIOEvent(int fd, IOEventFlags flags,
216-
+ IOCallback callback) {
217-
+ FCITX_D();
218-
+ auto source = std::make_unique<JSEventSourceIO>(std::move(callback));
219-
+ return source;
220-
+}
221-
+
222-
+std::unique_ptr<EventSourceTime>
223-
+EventLoop::addTimeEvent(clockid_t clock, uint64_t usec, uint64_t accuracy,
224-
+ TimeCallback callback) {
225-
+ auto source =
226-
+ std::make_unique<JSEventSourceTime>(std::move(callback), usec, clock);
227-
+ return source;
228-
+}
229-
+
230-
+std::unique_ptr<EventSource> EventLoop::addExitEvent(EventCallback callback) {
231-
+ FCITX_D();
232-
+ auto source = std::make_unique<JSEventSource>(std::move(callback));
233-
+ return source;
234-
+}
235-
+
236-
+std::unique_ptr<EventSource> EventLoop::addDeferEvent(EventCallback callback) {
237-
+ return addTimeEvent(
238-
+ CLOCK_MONOTONIC, now(CLOCK_MONOTONIC), 0,
239-
+ [callback = std::move(callback)](EventSourceTime *source, uint64_t) {
240-
+ return callback(source);
241-
+ });
242-
+}
243-
+
244-
+std::unique_ptr<EventSource> EventLoop::addPostEvent(EventCallback callback) {
245-
+ return addTimeEvent(
246-
+ CLOCK_MONOTONIC, now(CLOCK_MONOTONIC), 0,
247-
+ [callback = std::move(callback)](EventSourceTime *source, uint64_t) {
248-
+ return callback(source);
249-
+ });
250-
+}
251-
+} // namespace fcitx
25229
diff --git a/src/lib/fcitx/CMakeLists.txt b/src/lib/fcitx/CMakeLists.txt
25330
index df15dd57..36312bab 100644
25431
--- a/src/lib/fcitx/CMakeLists.txt
@@ -263,20 +40,3 @@ index df15dd57..36312bab 100644
26340
EXPORT_NAME Core
26441
)
26542
target_include_directories(Fcitx5Core PUBLIC
266-
diff --git a/src/modules/spell/CMakeLists.txt b/src/modules/spell/CMakeLists.txt
267-
index 094e1a58..ab1ce4df 100644
268-
--- a/src/modules/spell/CMakeLists.txt
269-
+++ b/src/modules/spell/CMakeLists.txt
270-
@@ -17,6 +17,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/spell.conf" DESTINATION "${FCITX_INST
271-
COMPONENT config)
272-
fcitx5_export_module(Spell TARGET spell BUILD_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}" HEADERS spell_public.h INSTALL)
273-
274-
+if (BUILD_SPELL_DICT)
275-
set(DICT_COMP_SRC
276-
comp_spell_dict.cpp
277-
)
278-
@@ -46,3 +47,4 @@ add_custom_command(
279-
"${SPELL_EN_DICT_SRC}" "${SPELL_EN_DICT}")
280-
add_custom_target(spell_en_dict ALL DEPENDS "${SPELL_EN_DICT}")
281-
install(FILES "${SPELL_EN_DICT}" DESTINATION "${FCITX_INSTALL_PKGDATADIR}/spell")
282-
+endif()

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ add_executable(Fcitx5
44
input_method.cpp
55
config.cpp
66
action.cpp
7+
event_js.cpp
78
)
89

910
target_include_directories(Fcitx5 PRIVATE

0 commit comments

Comments
 (0)