Skip to content

Commit d5c544a

Browse files
authored
port to StandardPaths (#13)
1 parent 9358efc commit d5c544a

8 files changed

Lines changed: 10 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
container: archlinux:latest
2626
env:
2727
XDG_DATA_DIRS: /opt/fcitx/share # for test
28+
FCITX_DATA_DIRS: /opt/fcitx/share/fcitx5/testing/addon:/opt/fcitx/share/fcitx5/testing
2829
steps:
2930
- name: Install dependencies
3031
run: pacman -Syu --noconfirm base-devel clang cmake ninja extra-cmake-modules fmt libuv marisa

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.6.0)
22

3-
project(fcitx5-hallelujah VERSION 5.0.2)
3+
project(fcitx5-hallelujah VERSION 5.0.3)
44

55
find_package(ECM 1.0.0 REQUIRED)
66
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
@@ -12,7 +12,7 @@ option(ENABLE_TEST "Build Test" On)
1212
option(BUILD_DATA "Build data" On)
1313

1414
find_package(Gettext REQUIRED)
15-
find_package(Fcitx5Core 5.1.12 REQUIRED)
15+
find_package(Fcitx5Core 5.1.13 REQUIRED)
1616
find_package(Fcitx5Module REQUIRED COMPONENTS Spell TestFrontend)
1717
find_package(PkgConfig REQUIRED)
1818

src/hallelujah.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "hallelujah.h"
22
#include <algorithm>
33
#include <cctype>
4-
#include <fcitx-utils/standardpath.h>
4+
#include <fcitx-utils/standardpaths.h>
55
#include <fcitx/candidatelist.h>
66
#include <fcitx/inputpanel.h>
77
#include <fmt/format.h>
@@ -286,8 +286,8 @@ void HallelujahEngine::reset(const InputMethodEntry &,
286286
}
287287

288288
void HallelujahEngine::loadTrie() {
289-
const auto &sp = fcitx::StandardPath::global();
290-
std::string trie_path = sp.locate(fcitx::StandardPath::Type::Data,
289+
const auto &sp = fcitx::StandardPaths::global();
290+
std::string trie_path = sp.locate(fcitx::StandardPathsType::Data,
291291
"hallelujah/google_227800_words.bin");
292292
if (trie_path.empty()) {
293293
throw std::runtime_error("Failed to load google_227800_words.bin");
@@ -296,9 +296,9 @@ void HallelujahEngine::loadTrie() {
296296
}
297297

298298
void HallelujahEngine::loadWords() {
299-
const auto &sp = fcitx::StandardPath::global();
299+
const auto &sp = fcitx::StandardPaths::global();
300300
std::string words_path =
301-
sp.locate(fcitx::StandardPath::Type::Data, "hallelujah/words.json");
301+
sp.locate(fcitx::StandardPathsType::Data, "hallelujah/words.json");
302302
if (words_path.empty()) {
303303
throw std::runtime_error("Failed to load words.json");
304304
}
@@ -335,9 +335,9 @@ void HallelujahEngine::loadWords() {
335335
}
336336

337337
void HallelujahEngine::loadPinyin() {
338-
const auto &sp = fcitx::StandardPath::global();
338+
const auto &sp = fcitx::StandardPaths::global();
339339
std::string pinyin_path =
340-
sp.locate(fcitx::StandardPath::Type::Data, "hallelujah/cedict.json");
340+
sp.locate(fcitx::StandardPathsType::Data, "hallelujah/cedict.json");
341341
if (pinyin_path.empty()) {
342342
throw std::runtime_error("Failed to load cedict.json");
343343
}

test/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
configure_file(testdir.h.in ${CMAKE_CURRENT_BINARY_DIR}/testdir.h @ONLY)
2-
include_directories(${CMAKE_CURRENT_BINARY_DIR})
3-
4-
add_subdirectory(addon)
5-
add_subdirectory(inputmethod)
6-
71
add_executable(testhallelujah testhallelujah.cpp)
82
target_link_libraries(testhallelujah Fcitx5::Core Fcitx5::Module::TestFrontend)
9-
add_dependencies(testhallelujah hallelujah copy-addon copy-im)
103
add_test(NAME testhallelujah COMMAND testhallelujah)

test/addon/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/inputmethod/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/testdir.h.in

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/testhallelujah.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
#include "testdir.h"
21
#include "testfrontend_public.h"
32
#include <fcitx-utils/eventdispatcher.h>
43
#include <fcitx-utils/log.h>
5-
#include <fcitx-utils/standardpath.h>
6-
#include <fcitx-utils/testing.h>
74
#include <fcitx/addonmanager.h>
85
#include <fcitx/inputmethodmanager.h>
96
#include <fcitx/instance.h>
@@ -62,9 +59,6 @@ void scheduleEvent(EventDispatcher *dispatcher, Instance *instance) {
6259
}
6360

6461
int main() {
65-
setupTestingEnvironment(
66-
TESTING_BINARY_DIR, {TESTING_BINARY_DIR "/src"},
67-
{TESTING_BINARY_DIR "/test", StandardPath::fcitxPath("pkgdatadir")});
6862
char arg0[] = "testhallelujah";
6963
char arg1[] = "--disable=all";
7064
char arg2[] = "--enable=testim,testfrontend,spell,hallelujah";

0 commit comments

Comments
 (0)