diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 015cf140..dcf40fd8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: types: [checks_requested] env: - RUST_VERSION: "1.70" + RUST_VERSION: "1.77" CMAKE_GENERATOR: Ninja jobs: diff --git a/Cargo.lock b/Cargo.lock index 2b10b59f..2d3be1bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,7 +95,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chewing" -version = "0.8.5" +version = "0.9.0-alpha.1" dependencies = [ "der", "directories", @@ -106,7 +106,7 @@ dependencies = [ [[package]] name = "chewing-cli" -version = "0.8.5" +version = "0.9.0-alpha.1" dependencies = [ "anyhow", "chewing", @@ -116,7 +116,7 @@ dependencies = [ [[package]] name = "chewing_capi" -version = "0.8.5" +version = "0.9.0-alpha.1" dependencies = [ "chewing", "env_logger", diff --git a/Cargo.toml b/Cargo.toml index 86773937..cbddd160 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ name = "chewing" description = "The Chewing (酷音) intelligent Zhuyin input method." documentation = "https://docs.rs/chewing" license = "LGPL-2.1-or-later" -version = "0.8.5" -rust-version = "1.70" +version = "0.9.0-alpha.1" +rust-version = "1.77.0" edition = "2021" include = [ diff --git a/README.md b/README.md index 9cd2a97a..63f9a35d 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ be built. - cmake >= 3.21.0 + Toolchain / IDE: - clang >= 3.2 OR gcc >= 4.6.3 - - Rust >= 1.70 + - Rust >= 1.77 - Build Tools for Visual Studio 2022 for MSVC build + Documentation tools: - texinfo >= 4.8 @@ -185,7 +185,7 @@ To ensure libchewing can be built on various Linux distributions, we use the minimum rust version available from major distributions' next release branch. Data source: https://repology.org/project/rust/versions -* Current MSRV: 1.70.0 (Debian unstable) +* Current MSRV: 1.77.0 (Debian unstable) ## Usage diff --git a/capi/Cargo.toml b/capi/Cargo.toml index 9a7c69fa..14834add 100644 --- a/capi/Cargo.toml +++ b/capi/Cargo.toml @@ -2,15 +2,15 @@ name = "chewing_capi" description = "The Chewing (酷音) intelligent Zhuyin input method." license = "LGPL-2.1-or-later" -version = "0.8.5" -rust-version = "1.70" +version = "0.9.0-alpha.1" +rust-version = "1.77" edition = "2021" [lib] crate-type = ["rlib", "staticlib"] [dependencies] -chewing = { version = "0.8.5", path = ".." } +chewing = { version = "0.9.0-alpha.1", path = ".." } env_logger = { version = ">= 0.10.2", default-features = false } log = { workspace = true } diff --git a/capi/src/io.rs b/capi/src/io.rs index a352c577..274899c0 100644 --- a/capi/src/io.rs +++ b/capi/src/io.rs @@ -303,7 +303,7 @@ pub unsafe extern "C" fn chewing_config_has_option( | "chewing.selection_keys" | "chewing.character_form" | "chewing.space_is_select_key" - | "chewing.fuzzy_searcy_mode" => true, + | "chewing.fuzzy_search_mode" => true, _ => false, }; diff --git a/capi/src/lib.rs b/capi/src/lib.rs index 768cec09..c42b3acd 100644 --- a/capi/src/lib.rs +++ b/capi/src/lib.rs @@ -33,6 +33,8 @@ mod io; mod logger; mod public; +pub mod version; + /// Initializes chewing context and environment settings. /// /// Most of the Chewing IM APIs require a diff --git a/capi/src/symbols-elf.map b/capi/src/symbols-elf.map index 8fd268f8..b60033c3 100644 --- a/capi/src/symbols-elf.map +++ b/capi/src/symbols-elf.map @@ -128,4 +128,9 @@ CHEWING_0.9 { chewing_config_get_int; chewing_config_set_str; chewing_config_get_str; + chewing_version; + chewing_version_major; + chewing_version_minor; + chewing_version_patch; + chewing_version_extra; } CHEWING_0.5; \ No newline at end of file diff --git a/capi/src/symbols-mach_o.map b/capi/src/symbols-mach_o.map index f795cfef..d5ae7f5c 100644 --- a/capi/src/symbols-mach_o.map +++ b/capi/src/symbols-mach_o.map @@ -120,4 +120,9 @@ _chewing_config_has_option _chewing_config_set_int _chewing_config_get_int _chewing_config_set_str -_chewing_config_get_str \ No newline at end of file +_chewing_config_get_str +_chewing_version +_chewing_version_major +_chewing_version_minor +_chewing_version_patch +_chewing_version_extra \ No newline at end of file diff --git a/capi/src/symbols-msvc.def b/capi/src/symbols-msvc.def index c1bc4510..230e20cc 100644 --- a/capi/src/symbols-msvc.def +++ b/capi/src/symbols-msvc.def @@ -121,4 +121,9 @@ EXPORTS chewing_config_set_int; chewing_config_get_int; chewing_config_set_str; - chewing_config_get_str; \ No newline at end of file + chewing_config_get_str; + chewing_version; + chewing_version_major; + chewing_version_minor; + chewing_version_patch; + chewing_version_extra; \ No newline at end of file diff --git a/capi/src/version.rs b/capi/src/version.rs new file mode 100644 index 00000000..a2485019 --- /dev/null +++ b/capi/src/version.rs @@ -0,0 +1,26 @@ +use std::ffi::{c_char, c_int}; + +#[no_mangle] +pub extern "C" fn chewing_version() -> *const c_char { + c"0.9.0-alpha.1".as_ptr() +} + +#[no_mangle] +pub extern "C" fn chewing_version_major() -> c_int { + 0 +} + +#[no_mangle] +pub extern "C" fn chewing_version_minor() -> c_int { + 9 +} + +#[no_mangle] +pub extern "C" fn chewing_version_patch() -> c_int { + 0 +} + +#[no_mangle] +pub extern "C" fn chewing_version_extra() -> *const c_char { + c"-alpha.1".as_ptr() +} diff --git a/fuzzer/Cargo.toml b/fuzzer/Cargo.toml index 2a42586b..ab240598 100644 --- a/fuzzer/Cargo.toml +++ b/fuzzer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -chewing = { version = "0.8.5", path = ".." } -chewing_capi = { version = "0.8.5", path = "../capi" } +chewing = { version = "0.9.0-alpha.1", path = ".." } +chewing_capi = { version = "0.9.0-alpha.1", path = "../capi" } log = "0.4.21" env_logger = { version = ">= 0.10.2", default-features = false } diff --git a/include/chewing.h b/include/chewing.h index d9e5b27f..646b0a3b 100644 --- a/include/chewing.h +++ b/include/chewing.h @@ -1080,6 +1080,16 @@ void chewing_set_hsuSelKeyType(struct ChewingContext *_ctx, int mode); */ int chewing_get_hsuSelKeyType(struct ChewingContext *_ctx); +const char *chewing_version(void); + +int chewing_version_major(void); + +int chewing_version_minor(void); + +int chewing_version_patch(void); + +const char *chewing_version_extra(void); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/test-config.c b/tests/test-config.c index 5ac3b506..5c7a171f 100644 --- a/tests/test-config.c +++ b/tests/test-config.c @@ -8,6 +8,7 @@ * of this file. */ +#include #ifdef HAVE_CONFIG_H # include #endif @@ -53,6 +54,7 @@ void test_has_option() ,"chewing.selection_keys" ,"chewing.character_form" ,"chewing.space_is_select_key" + ,"chewing.fuzzy_search_mode" }; ctx = chewing_new(); @@ -161,6 +163,9 @@ void test_default_value_options() ok(chewing_config_get_int(ctx, "chewing.character_form") == HALFSHAPE_MODE, "default chewing.character_form shall be %d", HALFSHAPE_MODE); + ok(chewing_config_get_int(ctx, "chewing.fuzzy_search_mode") == 0, + "default chewing.fuzzy_search_mode shall be 0"); + chewing_delete(ctx); } @@ -722,6 +727,21 @@ void test_new2() test_new2_userpath(); } +void test_runtime_version() +{ + char buf[256]; + int major = chewing_version_major(); + int minor = chewing_version_minor(); + int patch = chewing_version_patch(); + const char *extra = chewing_version_extra(); + const char *version = chewing_version(); + + ok(version != NULL, "chewing_version returns a version string"); + + sprintf(buf, "%d.%d.%d%s", major, minor, patch, extra); + ok(strcmp(buf, version) == 0, "chewing_version can be created from components"); +} + int main(int argc, char *argv[]) { char *logname; @@ -760,6 +780,8 @@ int main(int argc, char *argv[]) test_new2(); + test_runtime_version(); + fclose(fd); return exit_status(); diff --git a/tests/testhelper/Cargo.toml b/tests/testhelper/Cargo.toml index 6e9cbe22..76253c2d 100644 --- a/tests/testhelper/Cargo.toml +++ b/tests/testhelper/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -chewing = { version = "0.8.5", path = "../.." } +chewing = { version = "0.9.0-alpha.1", path = "../.." } [features] sqlite = ["chewing/sqlite"] diff --git a/tools/Cargo.toml b/tools/Cargo.toml index dc4efc7a..fccda425 100644 --- a/tools/Cargo.toml +++ b/tools/Cargo.toml @@ -2,12 +2,12 @@ name = "chewing-cli" description = "Tools of the Chewing (酷音) intelligent Zhuyin input method." license = "LGPL-2.1-or-later" -version = "0.8.5" +version = "0.9.0-alpha.1" edition = "2021" [dependencies] anyhow = "1.0.0" -chewing = { version = "0.8.5", path = "..", features = ["sqlite"] } +chewing = { version = "0.9.0-alpha.1", path = "..", features = ["sqlite"] } clap = { version = "4.4.18", features = ["derive"] } clap_mangen = { version = "0.2.12", optional = true }