From 102ffa298836644d9ba682ea8a3f811adf1c0fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Sat, 30 Jul 2022 17:26:36 +1200 Subject: [PATCH] Reflink behind feature --- .github/workflows/build.yml | 8 ++++++-- Cargo.toml | 14 +++++++++++++- src/bins.rs | 16 ++-------------- src/main.rs | 6 +----- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 67dda4b4a..b111946be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,15 +28,18 @@ jobs: include: - target: x86_64-unknown-linux-gnu os: ubuntu-latest - debug_features: [ rustls, pkg-config ] + debug_features: [ rustls, pkg-config, reflink ] + release_features: [ reflink ] - target: x86_64-apple-darwin os: macos-latest + release_features: [ reflink ] - target: aarch64-apple-darwin os: macos-latest + release_features: [ reflink ] - target: x86_64-pc-windows-msvc os: windows-latest debug_features: [ native-tls ] - release_features: [ static, zlib-ng, native-tls, fancy-no-backtrace ] + release_features: [ static, zlib-ng, native-tls, fancy-no-backtrace, reflink ] - target: x86_64-unknown-linux-musl os: ubuntu-latest - target: armv7-unknown-linux-musleabihf @@ -51,6 +54,7 @@ jobs: - target: aarch64-unknown-linux-gnu os: ubuntu-latest use-cross: true + release_features: [ reflink ] runs-on: ${{ matrix.os }} name: ${{ matrix.target }} diff --git a/Cargo.toml b/Cargo.toml index f80785406..853712f01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ log = "0.4.17" miette = "5.1.1" mimalloc = { version = "0.1.29", default-features = false, optional = true } once_cell = "1.13.0" -reflink = "0.1.3" +reflink = { version = "0.1.3", optional = true } reqwest = { version = "0.11.11", features = ["stream"], default-features = false } scopeguard = "1.1.0" semver = { version = "1.0.12", features = ["serde"] } @@ -78,19 +78,31 @@ guess_host_triple = "0.1.3" [features] default = ["static", "zlib-ng", "rustls", "fancy-no-backtrace"] +# Use mimalloc as global allocator mimalloc = ["dep:mimalloc"] +# Use reflink copies when the filesystem supports it +reflink = ["dep:reflink"] + +# Build and link libraries statically static = ["bzip2/static", "xz2/static"] + +# Use pkg-config to lookup libraries pkg-config = ["zstd/pkg-config"] +# Use zlib-ng over zlib zlib-ng = ["flate2/zlib-ng"] +# Use rustls for TLS rustls = ["crates_io_api/rustls", "reqwest/rustls-tls"] + +# Use native/OS APIs for TLS native-tls = ["reqwest/native-tls"] fancy-no-backtrace = ["miette/fancy-no-backtrace"] fancy-with-backtrace = ["fancy-no-backtrace", "miette/fancy"] +# Make a smaller release build by opting out of logging below info level log_release_max_level_info = ["log/release_max_level_info"] [dev-dependencies] diff --git a/src/bins.rs b/src/bins.rs index bd8a2dae4..722dad6d1 100644 --- a/src/bins.rs +++ b/src/bins.rs @@ -153,24 +153,12 @@ fn install_copy(src: &Path, dst: &Path) -> Result<(), BinstallError> { dst.display() ); - #[cfg(any( - target = "x86_64-unknown-linux-gnu", - target = "x86_64-apple-darwin", - target = "aarch64-apple-darwin", - target = "aarch64-unknown-linux-gnu", - target = "x86_64-pc-windows-msvc", - ))] + #[cfg(feature = "reflink")] { debug!("Reflink copy or fallback"); reflink::reflink_or_copy(src, dst)?; } - #[cfg(not(any( - target = "x86_64-unknown-linux-gnu", - target = "x86_64-apple-darwin", - target = "aarch64-apple-darwin", - target = "aarch64-unknown-linux-gnu", - target = "x86_64-pc-windows-msvc", - )))] + #[cfg(not(feature = "reflink"))] { debug!("Copy file"); fs::copy(src, dst)?; diff --git a/src/main.rs b/src/main.rs index c333f9086..84e932dbf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -146,11 +146,7 @@ struct Options { /// Show logs at this level /// /// Set to `debug` when submitting a bug report. - #[clap( - help_heading = "Meta", - long, - value_name = "LEVEL" - )] + #[clap(help_heading = "Meta", long, value_name = "LEVEL")] log_level: Option, }