Skip to content

Commit

Permalink
build with clang64 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Feb 7, 2025
1 parent 14a8694 commit efed85a
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 15 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ on:
jobs:
build-fcitx5:
runs-on: windows-2025
strategy:
fail-fast: false
matrix:
env: [msys, clang64]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
- name: Install dependencies (msys)
if: ${{ matrix.env == 'msys' }}
run: |
C:/msys64/usr/bin/pacman -Syu --noconfirm
C:/msys64/usr/bin/pacman -S --noconfirm `
mingw-w64-ucrt-x86_64-extra-cmake-modules `
mingw-w64-clang-x86_64-extra-cmake-modules `
cmake `
fmt `
gcc `
Expand All @@ -30,12 +35,38 @@ jobs:
cp -r its C:/msys64/usr/share/gettext
Add-Content $env:GITHUB_PATH "C:/msys64/usr/bin"
- name: Install dependencies (clang)
if: ${{ matrix.env == 'clang64' }}
run: |
C:/msys64/usr/bin/pacman -Syu --noconfirm
C:/msys64/usr/bin/pacman -S --noconfirm `
mingw-w64-clang-x86_64-extra-cmake-modules `
mingw-w64-clang-x86_64-clang `
mingw-w64-clang-x86_64-cmake `
mingw-w64-clang-x86_64-dlfcn `
mingw-w64-clang-x86_64-fmt `
mingw-w64-clang-x86_64-libuv `
mingw-w64-clang-x86_64-pkgconf `
gettext `
ninja
mkdir -p C:/msys64/usr/share/gettext
cp -r its C:/msys64/usr/share/gettext
Add-Content $env:GITHUB_PATH "C:/msys64/clang64/bin"
git apply --directory=fcitx5 patches/fcitx5.patch
- name: Build
run: |
cmake -B build -G Ninja `
-DCMAKE_BUILD_TYPE=Release
cmake --build build
- name: Package
if: ${{ matrix.env == 'clang64' }}
env:
DESTDIR: dist
run: |
cmake --install build
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
dist
.cache
42 changes: 30 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.27)

project(fcitx5-windows VERSION 0.1.0)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_STANDARD 17)

option(ENABLE_TESTING_ADDONS "" OFF)
Expand All @@ -18,18 +20,34 @@ option(USE_SYSTEMD "" OFF)
option(ENABLE_XDGAUTOSTART "" OFF)
option(ENABLE_EMOJI "" OFF)
option(ENABLE_LIBUUID "" OFF)
option(BUILD_SPELL_DICT "" ${CYGWIN})

if (CYGWIN)
set(CMAKE_INSTALL_PREFIX /usr)
set(ECM_DIR /clang64/share/ECM/cmake)
add_compile_definitions(-D_GNU_SOURCE)
else()
set(CMAKE_INSTALL_PREFIX C:)
set(ECM_DIR C:/msys64/clang64/share/ECM/cmake)
set(GETTEXT_MSGMERGE_EXECUTABLE C:/msys64/usr/bin/msgmerge.exe)
set(GETTEXT_MSGFMT_EXECUTABLE C:/msys64/usr/bin/msgfmt.exe)
endif()

set(ECM_DIR /ucrt64/share/ECM/cmake)
add_definitions(-DFcitx5Core_EXPORTS -DFcitx5Utils_EXPORTS -D_GNU_SOURCE)
add_subdirectory(fcitx5)
target_compile_definitions(Fcitx5Utils PUBLIC -DFcitx5Utils_EXPORTS)
target_compile_definitions(Fcitx5Core PUBLIC -DFcitx5Core_EXPORTS)

if (CYGWIN)
# exe needs dll in the same directory.
set(FCITX5UTILS_DLL_NAME msys-Fcitx5Utils-2.dll)
set(FCITX5UTILS_COPY "${PROJECT_BINARY_DIR}/fcitx5/src/modules/spell/${FCITX5UTILS_DLL_NAME}")
add_custom_command(
OUTPUT "${FCITX5UTILS_COPY}"
DEPENDS Fcitx5Utils
COMMAND cp "$<TARGET_FILE:Fcitx5Utils>" "${FCITX5UTILS_COPY}"
)
add_custom_target(copy_fcitx5utils ALL DEPENDS "${FCITX5UTILS_COPY}")
add_dependencies(spell_en_dict copy_fcitx5utils)
endif()

# exe needs dll in the same directory.
set(FCITX5UTILS_DLL_NAME msys-Fcitx5Utils-2.dll)
set(FCITX5UTILS_COPY "${PROJECT_BINARY_DIR}/fcitx5/src/modules/spell/${FCITX5UTILS_DLL_NAME}")
add_custom_command(
OUTPUT "${FCITX5UTILS_COPY}"
DEPENDS Fcitx5Utils
COMMAND cp "$<TARGET_FILE:Fcitx5Utils>" "${FCITX5UTILS_COPY}"
)
add_custom_target(copy_fcitx5utils ALL DEPENDS "${FCITX5UTILS_COPY}")
add_dependencies(spell_en_dict copy_fcitx5utils)
add_subdirectory(src)
2 changes: 1 addition & 1 deletion fcitx5
Submodule fcitx5 updated 133 files
36 changes: 36 additions & 0 deletions patches/fcitx5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/src/lib/fcitx-utils/standardpath.cpp b/src/lib/fcitx-utils/standardpath.cpp
index 3312214c..c2e7412c 100644
--- a/src/lib/fcitx-utils/standardpath.cpp
+++ b/src/lib/fcitx-utils/standardpath.cpp
@@ -222,6 +222,7 @@ private:
}
dir = stringutils::joinPath(*home, defaultPath);
} else {
+#ifndef _WIN32
if (env && strcmp(env, "XDG_RUNTIME_DIR") == 0) {
dir = stringutils::joinPath(
defaultPath,
@@ -232,11 +233,15 @@ private:
}
}
} else {
+#endif
dir = defaultPath;
+#ifndef _WIN32
}
+#endif
}
}

+#ifndef _WIN32
if (!dir.empty() && env && strcmp(env, "XDG_RUNTIME_DIR") == 0) {
struct stat buf;
if (stat(dir.c_str(), &buf) != 0 || buf.st_uid != geteuid() ||
@@ -244,6 +249,7 @@ private:
return {};
}
}
+#endif
return dir;
}

4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_executable(Fcitx5 main.cpp)
target_link_libraries(Fcitx5 Fcitx5::Core)

install(TARGETS Fcitx5 DESTINATION "${FCITX_INSTALL_BINDIR}")
21 changes: 21 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <fcitx-utils/event.h>
#include <fcitx-utils/eventdispatcher.h>
#include <fcitx/instance.h>

namespace fcitx {
std::unique_ptr<Instance> instance;
std::unique_ptr<fcitx::EventDispatcher> dispatcher;

void start() {
instance = std::make_unique<Instance>(0, nullptr);
instance->initialize();
dispatcher = std::make_unique<fcitx::EventDispatcher>();
dispatcher->attach(&instance->eventLoop());
instance->eventLoop().exec();
}
} // namespace fcitx

int main() {
fcitx::start();
return 0;
}

0 comments on commit efed85a

Please sign in to comment.