Skip to content

Commit

Permalink
refactor(dict): reimplement cdb dictionary and make sqlite optional
Browse files Browse the repository at this point in the history
  • Loading branch information
kanru committed Jan 6, 2024
1 parent b003b73 commit b8140a6
Show file tree
Hide file tree
Showing 13 changed files with 615 additions and 249 deletions.
31 changes: 11 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
with_rust: ['true', 'false']
with_hash: ['true', 'false']
rust_version: ['1.70']
include:
- os: ubuntu-latest
with_rust: true
rust_version: stable
with_hash: true
- os: ubuntu-latest
with_rust: true
rust_version: stable
with_hash: false
exclude:
- with_rust: 'false'
rust_version: 'stable'
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}, with_rust=${{ matrix.with_rust }}, rust_version=${{ matrix.rust_version }}
name: ${{ matrix.os }}, with_rust=${{ matrix.with_rust }}, with_hash=${{ matrix.with_hash }} rust_version=${{ matrix.rust_version }}

steps:
- uses: actions/checkout@v3
Expand All @@ -51,23 +57,7 @@ jobs:
rustup update
- name: Build
run: cargo xtask build --build-type ${{env.BUILD_TYPE}} --with-rust ${{matrix.with_rust}} --verbose true

- name: Test
run: cargo xtask test --build-type ${{env.BUILD_TYPE}}

build_with_hash:
runs-on: ubuntu-latest

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

- run: sudo apt-get install ninja-build

- name: Build
run: cargo xtask build --build-type ${{env.BUILD_TYPE}} --with-rust false --with-hash true --verbose true
run: cargo xtask build --build-type ${{env.BUILD_TYPE}} --with-rust ${{matrix.with_rust}} --with-hash ${{matrix.with_hash}} --verbose true

- name: Test
run: cargo xtask test --build-type ${{env.BUILD_TYPE}}
Expand All @@ -76,8 +66,9 @@ jobs:
strategy:
matrix:
with_rust: ['true', 'false']
with_hash: ['true', 'false']
runs-on: ubuntu-latest
name: Coverage with_rust=${{ matrix.with_rust }}
name: Coverage with_rust=${{ matrix.with_rust }} with_hash=${{ matrix.with_hash }}

steps:
- uses: actions/checkout@v3
Expand All @@ -101,7 +92,7 @@ jobs:
- name: Build
env:
CC: clang
run: cargo xtask build --build-type Debug --with-rust ${{matrix.with_rust}} --with-coverage true --verbose true
run: cargo xtask build --build-type Debug --with-rust ${{matrix.with_rust}} --with-hash ${{matrix.with_hash}} --with-coverage true --verbose true

- name: Test
run: |
Expand Down
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ option(USE_VALGRIND "Use valgrind when testing" true)
option(WITH_RUST "Use rust implemented internals (experimental)" false)
if(WITH_RUST)
add_subdirectory(cmake/corrosion)
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES chewing FEATURES capi test-tracing)
else()
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES chewing FEATURES capi)
endif()
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES chewing CRATE_TYPES staticlib FEATURES capi)
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES chewing-tools)
add_compile_definitions(WITH_RUST)
if(CMAKE_BUILD_TYPE MATCHES Debug)
corrosion_set_features(chewing FEATURES test-tracing)
endif()
if(WITH_SQLITE3)
corrosion_set_features(chewing FEATURES sqlite)
endif()
corrosion_add_target_local_rustflags(chewing -Ccodegen-units=1)
if(ENABLE_GCOV)
corrosion_set_env_vars(chewing CARGO_INCREMENTAL=0)
corrosion_add_target_local_rustflags(chewing -Cinstrument-coverage -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort)
Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bytemuck = { version = "1.14.0", features = ["derive"] }
cdb = "0.6.0"
directories = "5.0.0"
riff = "2.0.0"
rusqlite = "0.30.0"
rusqlite = { version = "0.30.0", optional = true }
thiserror = "1.0.0"
tracing = { version = "0.1.40", features = [
"max_level_trace",
Expand All @@ -25,21 +25,23 @@ tracing-subscriber = { version = "0.3.18", features = [
], optional = true }

[target.'cfg(windows)'.dependencies]
rusqlite = { version = "0.30.0", features = ["bundled"] }
rusqlite = { version = "0.30.0", features = ["bundled"], optional = true }

[lib]
crate-type = ["rlib", "staticlib"]

[features]
default = []
capi = []
sqlite = ["rusqlite"]
test-tracing = ["tracing-subscriber"]

[dev-dependencies]
tempfile = "3"

[workspace]
members = ["tools", "xtask"]
resolver = "2"

[profile.release]
lto = true
Expand Down
Loading

0 comments on commit b8140a6

Please sign in to comment.