Skip to content

Commit

Permalink
Merge pull request #404 from chewing/rust/test-msrv
Browse files Browse the repository at this point in the history
build: test both msrv and stable rust
  • Loading branch information
kanru authored Jul 16, 2023
2 parents b70e8b2 + 4b730f9 commit 712260d
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 9 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous Integration
name: CI

on:
push:
Expand All @@ -14,18 +14,28 @@ env:

jobs:
build:
continue-on-error: ${{ matrix.os == 'windows-latest' }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
with_rust: ['true', 'false']
rust_version: ['1.64', 'stable']
exclude:
- with_rust: 'false'
rust_version: 'stable'
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}, with_rust=${{ matrix.with_rust }}
name: ${{ matrix.os }}, with_rust=${{ matrix.with_rust }}, rust_version=${{ matrix.rust_version }}

steps:
- uses: actions/checkout@v3
with:
submodules: 'true'

- name: Setup rustup
run: |
rustup default ${{ matrix.rust_version }}
rustup update
- name: Build
run: cargo xtask build --build-type ${{env.BUILD_TYPE}} --with-rust ${{matrix.with_rust}} --verbose true

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ if (BUILD_DLL OR NOT MSVC)
target_link_options(chewing_shared PRIVATE "-Wl,-dead_strip")
elseif (MSVC)
target_link_options(chewing_shared PRIVATE "/DEF ${CMAKE_BINARY_DIR}/symbols.map")
set_target_properties(chewing_shared PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()
endif()

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description = "The Chewing (酷音) intelligent Zhuyin input method."
license = "LGPL-2.1-or-later"
documentation = "https://docs.rs/chewing"
version = "0.5.1-alpha.2"
rust-version = "1.64"
edition = "2021"

include = [
Expand Down
3 changes: 3 additions & 0 deletions capi/chewing-internal/include/chewing_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ typedef struct ChewingData {
struct ChewingConversionEngine *ce;
struct UserphraseDbAndEstimate *ue;
void *phraseIter;
void *phraseEnumIter;
} ChewingData;

typedef struct Phrase {
Expand Down Expand Up @@ -554,6 +555,8 @@ void UserUpdatePhraseEnd(struct ChewingData *_pgdata);

void *UserEnumeratePhrase(const struct UserphraseDbAndEstimate *ue);

void UserEnumeratePhraseEnd(void *iter_ptr);

bool UserEnumerateHasNext(void *iter_ptr, unsigned int *phrase_len_ptr, unsigned int *bopomofo_len);

int UserEnumerateGet(void *iter_ptr,
Expand Down
1 change: 1 addition & 0 deletions capi/chewing-internal/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ pub struct ChewingData {
pub ce: Option<Box<ChewingConversionEngine>>,
pub ue: Option<Box<UserphraseDbAndEstimate>>,
pub phrase_iter: *mut c_void,
pub phrase_enum_iter: *mut c_void,
}

#[repr(C)]
Expand Down
8 changes: 8 additions & 0 deletions capi/chewing-internal/src/userphrase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ pub extern "C" fn UserEnumeratePhrase(ue: &UserphraseDbAndEstimate) -> *mut c_vo
Box::into_raw(Box::new(ue.db.entries().peekable()) as Box<Peekable<DictEntries>>).cast()
}

#[no_mangle]
pub extern "C" fn UserEnumeratePhraseEnd(iter_ptr: *mut c_void) {
if !iter_ptr.is_null() {
let iter_ptr: *mut Peekable<DictEntries> = iter_ptr.cast();
let _ = unsafe { Box::from_raw(iter_ptr) };
}
}

#[no_mangle]
pub unsafe extern "C" fn UserEnumerateHasNext(
iter_ptr: *mut c_void,
Expand Down
2 changes: 1 addition & 1 deletion cmake/corrosion
Submodule corrosion updated 68 files
+1 −0 .github/FUNDING.yml
+81 −0 .github/ISSUE_TEMPLATE/bug_report.yml
+2 −1 .github/actions/setup_test/action.yaml
+62 −0 .github/workflows/gh-pages.yaml
+30 −15 .github/workflows/test.yaml
+10 −1 CMakeLists.txt
+15 −405 README.md
+113 −8 RELEASES.md
+0 −5 bors.toml
+611 −341 cmake/Corrosion.cmake
+133 −61 cmake/CorrosionGenerator.cmake
+288 −16 cmake/FindRust.cmake
+1 −0 doc/.gitignore
+5 −0 doc/book.toml
+9 −0 doc/src/SUMMARY.md
+96 −0 doc/src/advanced.md
+88 −0 doc/src/common_issues.md
+43 −0 doc/src/ffi_bindings.md
+13 −0 doc/src/introduction.md
+36 −0 doc/src/quick_start.md
+89 −0 doc/src/setup_corrosion.md
+320 −0 doc/src/usage.md
+30 −28 generator/Cargo.lock
+7 −1 generator/Cargo.toml
+19 −3 generator/src/main.rs
+59 −13 generator/src/subcommands/gen_cmake.rs
+43 −25 generator/src/subcommands/gen_cmake/target.rs
+0 −14 generator/src/subcommands/print_root.rs
+4 −2 test/CMakeLists.txt
+2 −1 test/ConfigureAndBuild.cmake
+9 −0 test/cbindgen/CMakeLists.txt
+10 −0 test/cbindgen/rust2cpp/CMakeLists.txt
+19 −0 test/cbindgen/rust2cpp/main.cpp
+5 −0 test/cbindgen/rust2cpp/rust/Cargo.lock
+10 −0 test/cbindgen/rust2cpp/rust/Cargo.toml
+2 −0 test/cbindgen/rust2cpp/rust/cbindgen.toml
+30 −0 test/cbindgen/rust2cpp/rust/src/lib.rs
+4 −0 test/cpp2rust/cpp2rust/rust/build.rs
+9 −2 test/custom_profiles/CMakeLists.txt
+10 −1 test/custom_profiles/custom_profiles/CMakeLists.txt
+15 −3 test/cxxbridge/CMakeLists.txt
+0 −8 test/cxxbridge/cxxbridge/main.cpp
+0 −10 test/cxxbridge/cxxbridge/rust/src/foo/mod.rs
+0 −12 test/cxxbridge/cxxbridge/rust/src/lib.rs
+39 −0 test/cxxbridge/cxxbridge_cpp2rust/CMakeLists.txt
+15 −0 test/cxxbridge/cxxbridge_cpp2rust/cpplib.cpp
+5 −0 test/cxxbridge/cxxbridge_cpp2rust/include/cpplib.h
+89 −0 test/cxxbridge/cxxbridge_cpp2rust/rust/Cargo.lock
+10 −0 test/cxxbridge/cxxbridge_cpp2rust/rust/Cargo.toml
+26 −0 test/cxxbridge/cxxbridge_cpp2rust/rust/src/lib.rs
+14 −0 test/cxxbridge/cxxbridge_cpp2rust/rust/src/main.rs
+5 −0 test/cxxbridge/cxxbridge_rust2cpp/CMakeLists.txt
+11 −0 test/cxxbridge/cxxbridge_rust2cpp/main.cpp
+18 −18 test/cxxbridge/cxxbridge_rust2cpp/rust/Cargo.lock
+0 −0 test/cxxbridge/cxxbridge_rust2cpp/rust/Cargo.toml
+10 −0 test/cxxbridge/cxxbridge_rust2cpp/rust/src/foo/mod.rs
+12 −0 test/cxxbridge/cxxbridge_rust2cpp/rust/src/lib.rs
+1 −0 test/find_rust/CMakeLists.txt
+47 −0 test/find_rust/rustup_proxy/CMakeLists.txt
+1 −1 test/gensource/gensource/generator/CMakeLists.txt
+5 −0 test/parse_target_triple/CMakeLists.txt
+6 −6 test/parse_target_triple/parse_target_triple/CMakeLists.txt
+0 −1 test/parse_target_triple/parse_target_triple/Cargo.toml
+1 −5 test/parse_target_triple/parse_target_triple_should_fail/CMakeLists.txt
+0 −1 test/parse_target_triple/parse_target_triple_should_fail/Cargo.toml
+4 −0 test/rust2cpp/rust2cpp/rust/build.rs
+24 −1 test/workspace/workspace/CMakeLists.txt
+3 −0 test/workspace/workspace/Cargo.toml
2 changes: 0 additions & 2 deletions rust-toolchain.toml

This file was deleted.

10 changes: 6 additions & 4 deletions src/chewingio.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ CHEWING_API void chewing_delete(ChewingContext *ctx)
#ifdef WITH_RUST
FreePhoneticEditor(ctx->data->bopomofoData.editorWithKeymap);
UserGetPhraseEnd(ctx->data, NULL);
UserEnumeratePhraseEnd(ctx->data->phraseEnumIter);
ctx->data->phraseEnumIter = NULL;
#endif
TerminateUserphrase(ctx->data);
TerminateTree(ctx->data);
Expand Down Expand Up @@ -1951,8 +1953,8 @@ CHEWING_API int chewing_userphrase_enumerate(ChewingContext *ctx)
}

#ifdef WITH_RUST
UserGetPhraseEnd(ctx->data, NULL);
ctx->data->phraseIter = UserEnumeratePhrase(ctx->data->ue);
UserEnumeratePhraseEnd(ctx->data->phraseEnumIter);
ctx->data->phraseEnumIter = UserEnumeratePhrase(ctx->data->ue);
#else
#if WITH_SQLITE3
int ret;
Expand Down Expand Up @@ -1985,7 +1987,7 @@ CHEWING_API int chewing_userphrase_has_next(ChewingContext *ctx, unsigned int *p
}

#ifdef WITH_RUST
return UserEnumerateHasNext(ctx->data->phraseIter, phrase_len, bopomofo_len);
return UserEnumerateHasNext(ctx->data->phraseEnumIter, phrase_len, bopomofo_len);
#else
#if WITH_SQLITE3
int ret;
Expand Down Expand Up @@ -2037,7 +2039,7 @@ CHEWING_API int chewing_userphrase_get(ChewingContext *ctx,
}

#ifdef WITH_RUST
return UserEnumerateGet(ctx->data->phraseIter, phrase_buf, phrase_len, bopomofo_buf, bopomofo_len);
return UserEnumerateGet(ctx->data->phraseEnumIter, phrase_buf, phrase_len, bopomofo_buf, bopomofo_len);
#else
#if WITH_SQLITE3
const char *phrase;
Expand Down

0 comments on commit 712260d

Please sign in to comment.