Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 6f919bf

Browse files
authored
libime (#6)
1 parent 1e0a6e9 commit 6f919bf

File tree

12 files changed

+171
-4
lines changed

12 files changed

+171
-4
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
run: |
2626
sudo apt install -y ninja-build \
2727
meson
28+
./install-deps.sh
2829
2930
- name: Install emsdk
3031
run: |
@@ -37,6 +38,7 @@ jobs:
3738
run: |
3839
. emsdk/emsdk_env.sh
3940
python scripts/boost.py
41+
python scripts/extra-cmake-modules.py
4042
python scripts/fmt.py
4143
python scripts/glog.py
4244
python scripts/iso-codes.py
@@ -50,6 +52,8 @@ jobs:
5052
python scripts/opencc.py
5153
python scripts/xkeyboard-config.py
5254
python scripts/yaml-cpp.py
55+
python scripts/zstd.py
56+
python scripts/libime.py
5357
python scripts/librime.py
5458
5559
- name: Release

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,12 @@
4040
[submodule "librime"]
4141
path = librime
4242
url = https://github.com/rime/librime
43+
[submodule "zstd"]
44+
path = zstd
45+
url = https://github.com/facebook/zstd
46+
[submodule "libime"]
47+
path = libime
48+
url = https://github.com/fcitx/libime
49+
[submodule "extra-cmake-modules"]
50+
path = extra-cmake-modules
51+
url = https://github.com/KDE/extra-cmake-modules

extra-cmake-modules

Submodule extra-cmake-modules added at c952c10

install-deps.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set -e
2+
3+
EXTRACT_DIR=build/sysroot/usr
4+
mkdir -p $EXTRACT_DIR
5+
6+
file=fcitx5-js-dev.tar.bz2
7+
[[ -f cache/$file ]] || wget -P cache https://github.com/fcitx-contrib/fcitx5-js/releases/download/latest/$file
8+
tar xjvf cache/$file -C $EXTRACT_DIR

libime

Submodule libime added at c2124c9

patches/libime.patch

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index a835346..b1585f7 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -32,9 +32,9 @@ find_package(PkgConfig REQUIRED)
6+
pkg_check_modules(ZSTD REQUIRED IMPORTED_TARGET "libzstd")
7+
8+
find_package(Fcitx5Utils REQUIRED)
9+
-include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
10+
+include("../build/sysroot${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
11+
12+
-find_package(Boost 1.61 REQUIRED COMPONENTS iostreams filesystem)
13+
+find_package(Boost 1.61 REQUIRED COMPONENTS iostreams)
14+
set(LIBIME_INSTALL_PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/libime")
15+
set(LIBIME_INSTALL_LIBDATADIR "${CMAKE_INSTALL_FULL_LIBDIR}/libime")
16+
17+
@@ -56,7 +56,6 @@ if(ENABLE_TEST)
18+
endif()
19+
20+
add_subdirectory(src)
21+
-add_subdirectory(tools)
22+
23+
if (ENABLE_DATA)
24+
add_subdirectory(data)
25+
diff --git a/src/libime/core/CMakeLists.txt b/src/libime/core/CMakeLists.txt
26+
index 89dd191..ed3f1b5 100644
27+
--- a/src/libime/core/CMakeLists.txt
28+
+++ b/src/libime/core/CMakeLists.txt
29+
@@ -68,7 +68,7 @@ ecm_setup_version(PROJECT
30+
# the cmake if will
31+
set(IMECore_SOVERSION 0)
32+
33+
-add_library(IMECore SHARED ${LIBIME_SRCS})
34+
+add_library(IMECore STATIC ${LIBIME_SRCS})
35+
set_target_properties(IMECore
36+
PROPERTIES VERSION ${IMECore_VERSION}
37+
SOVERSION ${IMECore_SOVERSION}
38+
@@ -81,7 +81,7 @@ target_include_directories(IMECore PUBLIC
39+
40+
target_link_libraries(IMECore PUBLIC Fcitx5::Utils Boost::boost PRIVATE kenlm Boost::iostreams PkgConfig::ZSTD)
41+
42+
-install(TARGETS IMECore EXPORT LibIMECoreTargets LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib)
43+
+install(TARGETS IMECore kenlm EXPORT LibIMECoreTargets LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib)
44+
install(FILES ${LIBIME_HDRS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibIME/libime/core" COMPONENT header)
45+
46+
add_library(LibIME::Core ALIAS IMECore)
47+
diff --git a/src/libime/core/utils_p.h b/src/libime/core/utils_p.h
48+
index 5915fd0..d9ad2d8 100644
49+
--- a/src/libime/core/utils_p.h
50+
+++ b/src/libime/core/utils_p.h
51+
@@ -12,7 +12,7 @@
52+
#include <utility>
53+
#include <vector>
54+
55+
-#if defined(__linux__) || defined(__GLIBC__)
56+
+#if defined(__linux__) || defined(__GLIBC__) || defined(__EMSCRIPTEN__)
57+
#include <endian.h>
58+
#elif defined(__APPLE__)
59+
#include <libkern/OSByteOrder.h>
60+
diff --git a/src/libime/pinyin/CMakeLists.txt b/src/libime/pinyin/CMakeLists.txt
61+
index a5e6d35..601d559 100644
62+
--- a/src/libime/pinyin/CMakeLists.txt
63+
+++ b/src/libime/pinyin/CMakeLists.txt
64+
@@ -32,7 +32,7 @@ ecm_setup_version(PROJECT
65+
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LibIMEPinyinConfigVersion.cmake")
66+
set(IMEPinyin_SOVERSION 0)
67+
68+
-add_library(IMEPinyin SHARED ${LIBIME_PINYIN_SRCS})
69+
+add_library(IMEPinyin STATIC ${LIBIME_PINYIN_SRCS})
70+
set_target_properties(IMEPinyin PROPERTIES
71+
VERSION ${IMEPinyin_VERSION}
72+
SOVERSION ${IMEPinyin_SOVERSION}
73+
diff --git a/src/libime/table/CMakeLists.txt b/src/libime/table/CMakeLists.txt
74+
index 62317bd..dd47d0b 100644
75+
--- a/src/libime/table/CMakeLists.txt
76+
+++ b/src/libime/table/CMakeLists.txt
77+
@@ -23,7 +23,7 @@ ecm_setup_version(PROJECT
78+
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LibIMETableConfigVersion.cmake")
79+
set(IMETable_SOVERSION 0)
80+
81+
-add_library(IMETable SHARED ${LIBIME_TABLE_SRCS})
82+
+add_library(IMETable STATIC ${LIBIME_TABLE_SRCS})
83+
set_target_properties(IMETable
84+
PROPERTIES VERSION ${IMETable_VERSION}
85+
SOVERSION ${IMETable_SOVERSION}

scripts/common.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,20 @@ def cache(url: str):
3737
])
3838

3939
class Builder:
40-
def __init__(self, name: str, options: list[str] | None=None, src='.', dep=False):
40+
def __init__(self, name: str, options: list[str] | None=None, src='.', build='build', dep=False):
4141
self.name = name
4242
self.root = os.getcwd()
4343
self.destdir = f'{self.root}/build/{self.name}'
4444
self.options = options or []
4545
self.src = src
46+
self.build_ = build
4647
self.dep = dep
4748

4849
def configure(self):
50+
os.environ['PKG_CONFIG_PATH'] = f'{self.root}/build/sysroot/usr/lib/pkgconfig'
4951
os.chdir(f'{self.root}/{self.name}')
5052
ensure('emcmake', ['cmake',
51-
'-B', 'build', '-G', 'Ninja',
53+
'-B', self.build_, '-G', 'Ninja',
5254
'-S', self.src,
5355
'-DBUILD_SHARED_LIBS=OFF',
5456
f'-DCMAKE_INSTALL_PREFIX={INSTALL_PREFIX}',
@@ -60,11 +62,11 @@ def configure(self):
6062
])
6163

6264
def build(self):
63-
ensure('cmake', ['--build', 'build'])
65+
ensure('cmake', ['--build', self.build_])
6466

6567
def install(self):
6668
os.environ['DESTDIR'] = self.destdir
67-
ensure('cmake', ['--install', 'build'])
69+
ensure('cmake', ['--install', self.build_])
6870

6971
def package(self):
7072
os.chdir(f'{self.destdir}{INSTALL_PREFIX}')

scripts/extra-cmake-modules.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from common import Builder
2+
3+
Builder('extra-cmake-modules', [
4+
'-DBUILD_TESTING=OFF'
5+
], dep=True).exec()

scripts/json-c.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from common import Builder
22

33
Builder('json-c', [
4+
'-DBUILD_TESTING=OFF',
5+
'-DBUILD_APPS=OFF',
46
'-DDISABLE_EXTRA_LIBS=ON'
57
]).exec()

scripts/libime.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os
2+
from common import Builder, cache, ensure, patch
3+
4+
root = os.getcwd()
5+
6+
ensure('sed', [
7+
'-i',
8+
f'"s|\\"/usr/include|\\"{root}/build/sysroot/usr/include|g"',
9+
'$(find build/sysroot/usr -name "*.cmake")'
10+
])
11+
12+
ensure('sed', [
13+
'-i',
14+
f'"s|prefix=/usr|prefix={root}/build/sysroot/usr|g"',
15+
'build/sysroot/usr/lib/pkgconfig/libzstd.pc'
16+
])
17+
18+
prebuilt = 'libime-arm64.tar.bz2'
19+
url = f'https://github.com/fcitx-contrib/fcitx5-macos-prebuilder/releases/download/latest/{prebuilt}'
20+
21+
cache(url)
22+
directory = 'build/libime/usr'
23+
ensure('mkdir', ['-p', directory])
24+
ensure('tar', [
25+
'xjvf',
26+
f'cache/{prebuilt}',
27+
'-C',
28+
directory,
29+
'lib/libime',
30+
'share'
31+
])
32+
33+
project = 'libime'
34+
35+
patch(project)
36+
37+
Builder(project, [
38+
'-DENABLE_TEST=OFF',
39+
'-DENABLE_DATA=OFF'
40+
]).exec()

0 commit comments

Comments
 (0)