Skip to content

Commit efed85a

Browse files
authored
build with clang64 (#6)
1 parent 14a8694 commit efed85a

File tree

7 files changed

+126
-15
lines changed

7 files changed

+126
-15
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@ on:
1010
jobs:
1111
build-fcitx5:
1212
runs-on: windows-2025
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
env: [msys, clang64]
1317
steps:
1418
- uses: actions/checkout@v4
1519
with:
1620
submodules: recursive
1721

18-
- name: Install dependencies
22+
- name: Install dependencies (msys)
23+
if: ${{ matrix.env == 'msys' }}
1924
run: |
2025
C:/msys64/usr/bin/pacman -Syu --noconfirm
2126
C:/msys64/usr/bin/pacman -S --noconfirm `
22-
mingw-w64-ucrt-x86_64-extra-cmake-modules `
27+
mingw-w64-clang-x86_64-extra-cmake-modules `
2328
cmake `
2429
fmt `
2530
gcc `
@@ -30,12 +35,38 @@ jobs:
3035
cp -r its C:/msys64/usr/share/gettext
3136
Add-Content $env:GITHUB_PATH "C:/msys64/usr/bin"
3237
38+
- name: Install dependencies (clang)
39+
if: ${{ matrix.env == 'clang64' }}
40+
run: |
41+
C:/msys64/usr/bin/pacman -Syu --noconfirm
42+
C:/msys64/usr/bin/pacman -S --noconfirm `
43+
mingw-w64-clang-x86_64-extra-cmake-modules `
44+
mingw-w64-clang-x86_64-clang `
45+
mingw-w64-clang-x86_64-cmake `
46+
mingw-w64-clang-x86_64-dlfcn `
47+
mingw-w64-clang-x86_64-fmt `
48+
mingw-w64-clang-x86_64-libuv `
49+
mingw-w64-clang-x86_64-pkgconf `
50+
gettext `
51+
ninja
52+
mkdir -p C:/msys64/usr/share/gettext
53+
cp -r its C:/msys64/usr/share/gettext
54+
Add-Content $env:GITHUB_PATH "C:/msys64/clang64/bin"
55+
git apply --directory=fcitx5 patches/fcitx5.patch
56+
3357
- name: Build
3458
run: |
3559
cmake -B build -G Ninja `
3660
-DCMAKE_BUILD_TYPE=Release
3761
cmake --build build
3862
63+
- name: Package
64+
if: ${{ matrix.env == 'clang64' }}
65+
env:
66+
DESTDIR: dist
67+
run: |
68+
cmake --install build
69+
3970
- name: Setup tmate session
4071
if: ${{ failure() }}
4172
uses: mxschmitt/action-tmate@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
build
2+
dist
23
.cache

CMakeLists.txt

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.27)
22

33
project(fcitx5-windows VERSION 0.1.0)
44

5+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6+
57
set(CMAKE_CXX_STANDARD 17)
68

79
option(ENABLE_TESTING_ADDONS "" OFF)
@@ -18,18 +20,34 @@ option(USE_SYSTEMD "" OFF)
1820
option(ENABLE_XDGAUTOSTART "" OFF)
1921
option(ENABLE_EMOJI "" OFF)
2022
option(ENABLE_LIBUUID "" OFF)
23+
option(BUILD_SPELL_DICT "" ${CYGWIN})
24+
25+
if (CYGWIN)
26+
set(CMAKE_INSTALL_PREFIX /usr)
27+
set(ECM_DIR /clang64/share/ECM/cmake)
28+
add_compile_definitions(-D_GNU_SOURCE)
29+
else()
30+
set(CMAKE_INSTALL_PREFIX C:)
31+
set(ECM_DIR C:/msys64/clang64/share/ECM/cmake)
32+
set(GETTEXT_MSGMERGE_EXECUTABLE C:/msys64/usr/bin/msgmerge.exe)
33+
set(GETTEXT_MSGFMT_EXECUTABLE C:/msys64/usr/bin/msgfmt.exe)
34+
endif()
2135

22-
set(ECM_DIR /ucrt64/share/ECM/cmake)
23-
add_definitions(-DFcitx5Core_EXPORTS -DFcitx5Utils_EXPORTS -D_GNU_SOURCE)
2436
add_subdirectory(fcitx5)
37+
target_compile_definitions(Fcitx5Utils PUBLIC -DFcitx5Utils_EXPORTS)
38+
target_compile_definitions(Fcitx5Core PUBLIC -DFcitx5Core_EXPORTS)
39+
40+
if (CYGWIN)
41+
# exe needs dll in the same directory.
42+
set(FCITX5UTILS_DLL_NAME msys-Fcitx5Utils-2.dll)
43+
set(FCITX5UTILS_COPY "${PROJECT_BINARY_DIR}/fcitx5/src/modules/spell/${FCITX5UTILS_DLL_NAME}")
44+
add_custom_command(
45+
OUTPUT "${FCITX5UTILS_COPY}"
46+
DEPENDS Fcitx5Utils
47+
COMMAND cp "$<TARGET_FILE:Fcitx5Utils>" "${FCITX5UTILS_COPY}"
48+
)
49+
add_custom_target(copy_fcitx5utils ALL DEPENDS "${FCITX5UTILS_COPY}")
50+
add_dependencies(spell_en_dict copy_fcitx5utils)
51+
endif()
2552

26-
# exe needs dll in the same directory.
27-
set(FCITX5UTILS_DLL_NAME msys-Fcitx5Utils-2.dll)
28-
set(FCITX5UTILS_COPY "${PROJECT_BINARY_DIR}/fcitx5/src/modules/spell/${FCITX5UTILS_DLL_NAME}")
29-
add_custom_command(
30-
OUTPUT "${FCITX5UTILS_COPY}"
31-
DEPENDS Fcitx5Utils
32-
COMMAND cp "$<TARGET_FILE:Fcitx5Utils>" "${FCITX5UTILS_COPY}"
33-
)
34-
add_custom_target(copy_fcitx5utils ALL DEPENDS "${FCITX5UTILS_COPY}")
35-
add_dependencies(spell_en_dict copy_fcitx5utils)
53+
add_subdirectory(src)

fcitx5

Submodule fcitx5 updated 133 files

patches/fcitx5.patch

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
diff --git a/src/lib/fcitx-utils/standardpath.cpp b/src/lib/fcitx-utils/standardpath.cpp
2+
index 3312214c..c2e7412c 100644
3+
--- a/src/lib/fcitx-utils/standardpath.cpp
4+
+++ b/src/lib/fcitx-utils/standardpath.cpp
5+
@@ -222,6 +222,7 @@ private:
6+
}
7+
dir = stringutils::joinPath(*home, defaultPath);
8+
} else {
9+
+#ifndef _WIN32
10+
if (env && strcmp(env, "XDG_RUNTIME_DIR") == 0) {
11+
dir = stringutils::joinPath(
12+
defaultPath,
13+
@@ -232,11 +233,15 @@ private:
14+
}
15+
}
16+
} else {
17+
+#endif
18+
dir = defaultPath;
19+
+#ifndef _WIN32
20+
}
21+
+#endif
22+
}
23+
}
24+
25+
+#ifndef _WIN32
26+
if (!dir.empty() && env && strcmp(env, "XDG_RUNTIME_DIR") == 0) {
27+
struct stat buf;
28+
if (stat(dir.c_str(), &buf) != 0 || buf.st_uid != geteuid() ||
29+
@@ -244,6 +249,7 @@ private:
30+
return {};
31+
}
32+
}
33+
+#endif
34+
return dir;
35+
}
36+

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_executable(Fcitx5 main.cpp)
2+
target_link_libraries(Fcitx5 Fcitx5::Core)
3+
4+
install(TARGETS Fcitx5 DESTINATION "${FCITX_INSTALL_BINDIR}")

src/main.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <fcitx-utils/event.h>
2+
#include <fcitx-utils/eventdispatcher.h>
3+
#include <fcitx/instance.h>
4+
5+
namespace fcitx {
6+
std::unique_ptr<Instance> instance;
7+
std::unique_ptr<fcitx::EventDispatcher> dispatcher;
8+
9+
void start() {
10+
instance = std::make_unique<Instance>(0, nullptr);
11+
instance->initialize();
12+
dispatcher = std::make_unique<fcitx::EventDispatcher>();
13+
dispatcher->attach(&instance->eventLoop());
14+
instance->eventLoop().exec();
15+
}
16+
} // namespace fcitx
17+
18+
int main() {
19+
fcitx::start();
20+
return 0;
21+
}

0 commit comments

Comments
 (0)