diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e4877f1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: CI + +on: [push, pull_request] + +jobs: + build_and_test: + name: Build and Test + strategy: + matrix: + os: + - "ubuntu-latest" + - "macos-latest" + - "windows-latest" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + - name: Build + run: cargo build -vv + - name: Test + run: cargo test -vv + env: + RUST_BACKTRACE: 1 + + build_result: + name: Result + runs-on: ubuntu-latest + needs: + - "build_and_test" + steps: + - name: Mark the job as successful + if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + run: exit 0 + - name: Mark the job as unsuccessful + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + run: exit 1 + diff --git a/build.rs b/build.rs index 5692f3b..15af353 100644 --- a/build.rs +++ b/build.rs @@ -7,11 +7,10 @@ use std::env; fn main() { let dst = cmake::Config::new("src").build(); - println!("cargo:rustc-link-search=native={}/lib\n\ - cargo:rustc-link-lib=static=brotli\n\ - cargo:rustc-link-lib=static=woff2\n\ - cargo:rustc-link-lib=static=ots", - dst.display()); + println!("cargo:rustc-link-search=native={}/lib", dst.display()); + println!("cargo:rustc-link-lib=static=ots"); + println!("cargo:rustc-link-lib=static=woff2"); + println!("cargo:rustc-link-lib=static=brotli"); let target = env::var("TARGET").unwrap(); if target.contains("apple") { println!("cargo:rustc-link-lib=c++"); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bfbe3fc..40308a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,5 @@ +cmake_minimum_required(VERSION 3.13) project(ots) -cmake_minimum_required(VERSION 2.6) - -# Needed to avoid error -set(DUMMY ${CMAKE_BUILD_TYPE}) set(OTS_SOURCES ots/src/cff.cc @@ -97,6 +94,23 @@ set(BROTLI_SOURCES ots/third_party/brotli/c/include/brotli/decode.h ots/third_party/brotli/c/include/brotli/port.h ots/third_party/brotli/c/include/brotli/types.h + ots/third_party/brotli/c/enc/backward_references.c + ots/third_party/brotli/c/enc/backward_references_hq.c + ots/third_party/brotli/c/enc/bit_cost.c + ots/third_party/brotli/c/enc/block_splitter.c + ots/third_party/brotli/c/enc/brotli_bit_stream.c + ots/third_party/brotli/c/enc/cluster.c + ots/third_party/brotli/c/enc/compress_fragment.c + ots/third_party/brotli/c/enc/compress_fragment_two_pass.c + ots/third_party/brotli/c/enc/dictionary_hash.c + ots/third_party/brotli/c/enc/encode.c + ots/third_party/brotli/c/enc/entropy_encode.c + ots/third_party/brotli/c/enc/histogram.c + ots/third_party/brotli/c/enc/literal_cost.c + ots/third_party/brotli/c/enc/memory.c + ots/third_party/brotli/c/enc/metablock.c + ots/third_party/brotli/c/enc/static_dict.c + ots/third_party/brotli/c/enc/utf8_util.c ) set(WOFF2_SOURCES @@ -131,6 +145,11 @@ set(OTS_GLUE_SOURCES ots_glue.cc ) +set(LZ4_SOURCES + ots/third_party/lz4/lib/lz4.c + ots/third_party/lz4/lib/lz4.h +) + include_directories( fake-zlib ots/include @@ -148,6 +167,11 @@ add_library(brotli STATIC ${BROTLI_SOURCES}) add_library(woff2 STATIC ${WOFF2_SOURCES}) add_library(ots_glue STATIC ${OTS_GLUE_SOURCES}) +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + target_sources(ots PRIVATE "${LZ4_SOURCES}") + target_include_directories(ots PRIVATE ots/third_party/lz4/lib/) +endif() + SET_TARGET_PROPERTIES(woff2 PROPERTIES COMPILE_FLAGS "-std=c++11" ) diff --git a/src/ffi.rs b/src/ffi.rs index a610c99..de35d1f 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -12,7 +12,7 @@ pub trait Wr: Write + Seek { } impl Wr for T where T: Write + Seek { } pub struct RustOTSStream<'a> { - pub wr: &'a mut (Wr + 'a), + pub wr: &'a mut (dyn Wr + 'a), pub error: Option, } diff --git a/src/lib.rs b/src/lib.rs index 2240547..2e9b509 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,7 +64,7 @@ pub fn process_and_write(output: &mut W, font_data: &[u8]) -> Result<(), Erro #[inline] pub fn process(font_data: &[u8]) -> Result, Error> { let mut out = io::Cursor::new(vec![]); - try!(process_and_write(&mut out, font_data)); + process_and_write(&mut out, font_data)?; Ok(out.into_inner()) }