Skip to content

Commit

Permalink
🔀 Add windows CI (#46)
Browse files Browse the repository at this point in the history
Thanks @Szpadel for CMAKE_INSTALL_LIBDIR tip (#39).
  • Loading branch information
inflation authored Apr 30, 2024
2 parents c7d9086 + 99f8387 commit 1fe2fa0
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 21 deletions.
68 changes: 50 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,42 @@ on:
pull_request:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: Unit Tests
timeout-minutes: 20
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Dependency
run: cargo fetch
- uses: actions/cache@v4
id: cache
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- name: Tests
run: cargo nextest run --all-features --workspace

coverage:
name: Code Coverage
runs-on: ubuntu-latest
Expand All @@ -23,28 +50,31 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
run: rustup update nightly
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Dependency
run: cargo fetch
- uses: actions/cache@v4
id: cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-cov-${{ hashFiles('**/Cargo.lock') }}
- name: Generate code coverage
run: cargo +nightly llvm-cov nextest
--all-features --workspace --branch
--ignore-filename-regex jpegxl-sys/
--lcov --output-path lcov.info
run:
cargo +nightly llvm-cov nextest
--all-features --workspace
--ignore-filename-regex jpegxl-sys/
--lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand All @@ -60,25 +90,27 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
run: rustup update nightly
- name: Add rust-src
run: rustup +nightly component add rust-src
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Dependency
run: cargo fetch
- uses: actions/cache@v4
id: cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-sanitizer-${{ hashFiles('**/Cargo.lock') }}
- name: Address Sanitizer
run: cargo +nightly nextest run -Z build-std --target=x86_64-unknown-linux-gnu --all-features
run:
cargo +nightly nextest run
-Z build-std --target=x86_64-unknown-linux-gnu --all-features
env:
RUSTFLAGS: "-Z sanitizer=address"
RUSTDOCFLAGS: "-Z sanitizer=address"
Expand All @@ -95,10 +127,10 @@ jobs:
run: rustup update stable
- name: Dependency
run: cargo fetch
- uses: actions/cache@v4
- uses: actions/cache@v3
id: cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
Expand Down
9 changes: 7 additions & 2 deletions jpegxl-rs/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ use crate::{
common::PixelType, errors::EncodeError, memory::MemoryManager, parallel::JxlParallelRunner,
};

// MARK: Utility types

/// Encoding speed
#[derive(Debug, Clone, Copy)]
pub enum EncoderSpeed {
Expand Down Expand Up @@ -162,6 +164,8 @@ impl<U: PixelType> Deref for EncoderResult<U> {
}
}

// MARK: Encoder

/// JPEG XL Encoder
#[derive(Builder)]
#[builder(build_fn(skip, error = "None"))]
Expand Down Expand Up @@ -278,7 +282,7 @@ impl<'prl, 'mm> JxlEncoderBuilder<'prl, 'mm> {
}
}

// Private helper functions
// MARK: Private helper functions
impl JxlEncoder<'_, '_> {
/// Error mapping from underlying C const to [`EncodeError`] enum
#[cfg_attr(coverage_nightly, coverage(off))]
Expand Down Expand Up @@ -453,7 +457,7 @@ impl JxlEncoder<'_, '_> {
}
}

// Public interface
// MARK: Public interface
impl<'prl, 'mm> JxlEncoder<'prl, 'mm> {
/// Set a specific encoder frame setting
///
Expand Down Expand Up @@ -584,6 +588,7 @@ pub fn encoder_builder<'prl, 'mm>() -> JxlEncoderBuilder<'prl, 'mm> {
JxlEncoderBuilder::default()
}

// MARK: Tests
#[cfg(test)]
mod tests {
use super::*;
Expand Down
3 changes: 3 additions & 0 deletions jpegxl-src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ exclude = [

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lints.clippy]
pedantic = "warn"

[dependencies]
cmake = "0.1.50"

Expand Down
9 changes: 8 additions & 1 deletion jpegxl-src/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ pub fn build() {
let source = source_dir();

if let Ok(p) = std::thread::available_parallelism() {
env::set_var("CMAKE_BUILD_PARALLEL_LEVEL", format!("{}", p))
env::set_var("CMAKE_BUILD_PARALLEL_LEVEL", format!("{p}"));
}

let mut config = cmake::Config::new(source);
config
.define("CMAKE_INSTALL_LIBDIR", "lib")
.define("BUILD_SHARED_LIBS", "OFF")
.define("BUILD_TESTING", "OFF")
.define("JPEGXL_ENABLE_TOOLS", "OFF")
Expand All @@ -34,6 +35,12 @@ pub fn build() {
.define("JPEGXL_ENABLE_OPENEXR", "OFF")
.define("JPEGXL_ENABLE_JPEGLI", "OFF");

#[cfg(target_os = "windows")]
config
.generator("Visual Studio 17 2022")
.generator_toolset("ClangCL")
.define("CMAKE_MSVC_RUNTIME_LIBRARY", "MultiThreadedDLL");

let mut prefix = config.build();
prefix.push("lib");
println!("cargo:rustc-link-search=native={}", prefix.display());
Expand Down

0 comments on commit 1fe2fa0

Please sign in to comment.