Make cfzlib the default on platforms that support it

Raises the minimum Rust version to 1.27.0
This commit is contained in:
Josh Holmer 2018-07-20 19:03:17 -04:00
parent 2f619f214b
commit 2702145f3f
7 changed files with 6 additions and 15 deletions

View file

@ -11,7 +11,7 @@ matrix:
env: TARGET=x86_64-apple-darwin env: TARGET=x86_64-apple-darwin
cache: cargo cache: cargo
- os: linux - os: linux
rust: 1.24.0 rust: 1.27.0
env: TARGET=x86_64-unknown-linux-gnu env: TARGET=x86_64-unknown-linux-gnu
cache: cargo cache: cargo
- os: linux - os: linux

View file

@ -48,7 +48,6 @@ optional = true
version = "1.0.1" version = "1.0.1"
[dependencies.cloudflare-zlib-sys] [dependencies.cloudflare-zlib-sys]
optional = true
version = "^0.1.2" version = "^0.1.2"
[dependencies.image] [dependencies.image]
@ -63,11 +62,10 @@ binary = [
] ]
default = ["binary", "parallel"] default = ["binary", "parallel"]
parallel = ["rayon"] parallel = ["rayon"]
cfzlib = ["cloudflare-zlib-sys"]
dev = [ dev = [
"nightly-binary", "nightly-binary",
] ]
nightly = ["cfzlib"] nightly = []
nightly-binary = [ nightly-binary = [
"binary", "binary",
"nightly", "nightly",

View file

@ -26,7 +26,7 @@ cargo build --release
cp target/release/oxipng /usr/local/bin cp target/release/oxipng /usr/local/bin
``` ```
The current minimum supported Rust version is **1.24.0**. Oxipng may compile on earlier versions of Rust, The current minimum supported Rust version is **1.27.0**. Oxipng may compile on earlier versions of Rust,
but there is no guarantee. but there is no guarantee.
Oxipng follows Semantic Versioning. Oxipng follows Semantic Versioning.

View file

@ -26,7 +26,7 @@ cargo build --release
cp target/release/oxipng /usr/local/bin cp target/release/oxipng /usr/local/bin
``` ```
The current minimum supported Rust version is **1.24.0**. Oxipng may compile on earlier versions of Rust, The current minimum supported Rust version is **1.27.0**. Oxipng may compile on earlier versions of Rust,
but there is no guarantee. but there is no guarantee.
Oxipng follows Semantic Versioning. Oxipng follows Semantic Versioning.

View file

@ -15,17 +15,13 @@ pub fn inflate(data: &[u8]) -> Result<Vec<u8>, PngError> {
/// Compress a data stream using the DEFLATE algorithm /// Compress a data stream using the DEFLATE algorithm
pub fn deflate(data: &[u8], zc: u8, zs: u8, zw: u8, max_size: &AtomicMin) -> Result<Vec<u8>, PngError> { pub fn deflate(data: &[u8], zc: u8, zs: u8, zw: u8, max_size: &AtomicMin) -> Result<Vec<u8>, PngError> {
#[cfg(feature = "cfzlib")] if is_cfzlib_supported() {
{ return cfzlib_deflate(data, zc, zs, zw, max_size)
if is_cfzlib_supported() {
return cfzlib_deflate(data, zc, zs, zw, max_size)
}
} }
miniz_stream::compress_to_vec_oxipng(data, zc, zw.into(), zs.into(), max_size) miniz_stream::compress_to_vec_oxipng(data, zc, zw.into(), zs.into(), max_size)
} }
#[cfg(feature = "cfzlib")]
fn is_cfzlib_supported() -> bool { fn is_cfzlib_supported() -> bool {
#[cfg(target_arch = "x86_64")] { #[cfg(target_arch = "x86_64")] {
if is_x86_feature_detected!("sse4.2") && is_x86_feature_detected!("pclmulqdq") { if is_x86_feature_detected!("sse4.2") && is_x86_feature_detected!("pclmulqdq") {
@ -40,7 +36,6 @@ fn is_cfzlib_supported() -> bool {
false false
} }
#[cfg(feature = "cfzlib")]
pub fn cfzlib_deflate(data: &[u8], level: u8, strategy: u8, window_bits: u8, max_size: &AtomicMin) -> Result<Vec<u8>, PngError> { pub fn cfzlib_deflate(data: &[u8], level: u8, strategy: u8, window_bits: u8, max_size: &AtomicMin) -> Result<Vec<u8>, PngError> {
use std::mem; use std::mem;
use cloudflare_zlib_sys::*; use cloudflare_zlib_sys::*;

View file

@ -8,7 +8,6 @@ extern crate num_cpus;
#[cfg(feature = "parallel")] #[cfg(feature = "parallel")]
extern crate rayon; extern crate rayon;
extern crate zopfli; extern crate zopfli;
#[cfg(feature = "cfzlib")]
extern crate cloudflare_zlib_sys; extern crate cloudflare_zlib_sys;
use image::{DynamicImage, GenericImage, ImageFormat, Pixel}; use image::{DynamicImage, GenericImage, ImageFormat, Pixel};

View file

@ -275,7 +275,6 @@ fn collect_files(files: Vec<PathBuf>, out_dir: &Option<PathBuf>, out_file: &OutF
in_out_pairs in_out_pairs
} }
#[cfg_attr(feature = "clippy", allow(cyclomatic_complexity))]
fn parse_opts_into_struct(matches: &ArgMatches) -> Result<(OutFile, Option<PathBuf>, Options), String> { fn parse_opts_into_struct(matches: &ArgMatches) -> Result<(OutFile, Option<PathBuf>, Options), String> {
let mut opts = if let Some(x) = matches.value_of("optimization") { let mut opts = if let Some(x) = matches.value_of("optimization") {
if let Ok(opt) = x.parse::<u8>() { if let Ok(opt) = x.parse::<u8>() {