Skip to content

Commit

Permalink
ci: add build-rust job (plus build fixes)
Browse files Browse the repository at this point in the history
 * fix trivial rustfmt comment complaint
 * fix typo in c-API function name
  • Loading branch information
axxel committed Jan 21, 2024
1 parent 9e03476 commit 3b0f703
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,36 @@ jobs:
name: android-artifacts
path: "wrappers/android/zxingcpp/build/outputs/aar/zxingcpp-debug.aar"

build-rust:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v3

- name: Setup Rust
run: |
rustup update
rustup component add clippy
rustup component add rustfmt
- name: Lint
working-directory: wrappers/rust
run: |
cargo fmt --check
cargo clippy -- -Dwarnings
- name: Build
working-directory: wrappers/rust
run: cargo build --release --verbose --features bundled,image --examples

- name: Package
working-directory: wrappers/rust
# --allow-dirty is required on the windows build (but not the ubuntu build?!)
run: cargo package --verbose --allow-dirty --features bundled,image

build-wasm:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion core/src/zxing-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void zxing_ReaderOptions_setFormats(zxing_ReaderOptions* opts, zxing_BarcodeForm
opts->setFormats(static_cast<BarcodeFormat>(formats));
}

zxing_BarcodeFormats zxing_ReaderOptions_formats(const zxing_ReaderOptions* opts)
zxing_BarcodeFormats zxing_ReaderOptions_getFormats(const zxing_ReaderOptions* opts)
{
auto v = opts->formats();
return *reinterpret_cast<zxing_BarcodeFormats*>(&v);
Expand Down
2 changes: 1 addition & 1 deletion wrappers/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() -> miette::Result<()> {
println!("cargo:rustc-link-search=native={}", lib_dir);
println!("cargo:rustc-link-lib=dylib=ZXing");
} else {
// panic!("ZXing library not found. Use feature 'bundled' or set environment variabale ZXING_CPP_LIB_DIR.")
// panic!("ZXing library not found. Use feature 'bundled' or set environment variabale ZXING_CPP_LIB_DIR.")
}

// manual bindings.rs generation:
Expand Down

0 comments on commit 3b0f703

Please sign in to comment.