diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0b0e8c0d..07de14ec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,7 +38,7 @@ jobs: id: msrv with: file: 'Cargo.toml' - field: 'package.rust-version' + field: 'workspace.package.rust-version' - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ steps.msrv.outputs.value }} diff --git a/Cargo.lock b/Cargo.lock index 90ee8236..6f51a38f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -241,6 +241,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +[[package]] +name = "common" +version = "0.9.5-masterV2" +dependencies = [ + "criterion", + "fastrand", + "pkg-config", + "rustix", +] + [[package]] name = "crc32fast" version = "1.4.2" @@ -831,22 +841,22 @@ dependencies = [ "assert_cmd", "clap", "clap_complete", + "common", "fast_image_resize", "fastrand", "image", - "utils", ] [[package]] name = "swww-daemon" version = "0.9.5-masterV2" dependencies = [ + "common", "keyframe", "libc", "log", "rustix", "sd-notify", - "utils", ] [[package]] @@ -929,16 +939,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "utils" -version = "0.9.5-masterV2" -dependencies = [ - "criterion", - "fastrand", - "pkg-config", - "rustix", -] - [[package]] name = "wait-timeout" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 2bbe76a7..a547d77c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,29 @@ [workspace] -members = [".", "daemon", "utils"] -default-members = [".", "daemon"] +members = ["client", "daemon", "common"] +default-members = ["client", "daemon"] -[package] -name = "swww" +[workspace.package] version = "0.9.5-masterV2" authors = ["Leonardo Gibrowski Faé "] edition = "2021" +license-file = "LICENSE" rust-version = "1.75" +[workspace.dependencies] +common = { path = "common" } + +[workspace.lints.clippy] +correctness = { level = "deny", priority = -1 } +suspicious = { level = "deny", priority = -1 } +perf = { level = "deny", priority = -1 } +style = { level = "deny", priority = -1 } +complexity = { level = "warn", priority = -1 } +#pedantic = { level = "warn", priority = -1 } + +module-name-repetitions = "allow" +missing-errors-doc = "allow" +missing-panics-doc = "allow" + # Enable some optimizations in debug mode. Otherwise, it is a pain to test it [profile.dev] opt-level = 1 @@ -28,34 +43,3 @@ strip = true lto = "thin" debug = 1 strip = false - -[dependencies] -image = { version = "0.25", default-features = false, features = [ - # all formats, except avif, since avif compiles just rav1d, which is just an - # encoder, which we do not care about - "bmp", - "dds", - "exr", - "ff", - "gif", - "hdr", - "ico", - "jpeg", - "png", - "pnm", - "qoi", - "tga", - "tiff", - "webp", -]} -fast_image_resize = "4.0" -clap = { version = "4.5", features = ["derive", "wrap_help", "env"] } -fastrand = { version = "2.1", default-features = false, features = [ "std" ] } -utils = { version = "0.9.5-masterV2", path = "utils" } - -[dev-dependencies] -assert_cmd = "2.0" - -[build-dependencies] -clap = { version = "4.5", features = ["derive", "env"] } -clap_complete = "4.5" diff --git a/build.nix b/build.nix index 5b7ab2de..03e320e3 100644 --- a/build.nix +++ b/build.nix @@ -8,7 +8,7 @@ scdoc, nix-gitignore, }: let - version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version; + version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version; src = nix-gitignore.gitignoreSource [] ./.; in rustPlatform.buildRustPackage { diff --git a/client/Cargo.toml b/client/Cargo.toml new file mode 100644 index 00000000..b715e90e --- /dev/null +++ b/client/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "swww" +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +license-file.workspace = true + +[lints] +workspace = true + +[dependencies] +image = { version = "0.25", default-features = false, features = [ + # all formats, except avif, since avif compiles just rav1d, which is just an + # encoder, which we do not care about + "bmp", + "dds", + "exr", + "ff", + "gif", + "hdr", + "ico", + "jpeg", + "png", + "pnm", + "qoi", + "tga", + "tiff", + "webp", +] } +fast_image_resize = "4.0" +clap = { version = "4.5", features = ["derive", "wrap_help", "env"] } +fastrand = { version = "2.1", default-features = false, features = ["std"] } +common = { workspace = true } + +[dev-dependencies] +assert_cmd = "2.0" + +[build-dependencies] +clap = { version = "4.5", features = ["derive", "env"] } +clap_complete = "4.5" diff --git a/build.rs b/client/build.rs similarity index 93% rename from build.rs rename to client/build.rs index e278c575..7c97d51d 100644 --- a/build.rs +++ b/client/build.rs @@ -5,7 +5,7 @@ use clap_complete::{generate_to, Shell}; include!("src/cli.rs"); -const COMPLETION_DIR: &str = "completions"; +const COMPLETION_DIR: &str = "../completions"; const APP_NAME: &str = "swww"; fn main() -> Result<(), Error> { diff --git a/src/cli.rs b/client/src/cli.rs similarity index 100% rename from src/cli.rs rename to client/src/cli.rs diff --git a/src/imgproc.rs b/client/src/imgproc.rs similarity index 99% rename from src/imgproc.rs rename to client/src/imgproc.rs index 3e757b69..8ba7b463 100644 --- a/src/imgproc.rs +++ b/client/src/imgproc.rs @@ -9,7 +9,7 @@ use std::{ time::Duration, }; -use utils::{ +use common::{ compression::{BitPack, Compressor}, ipc::{self, Coord, PixelFormat, Position}, }; diff --git a/src/main.rs b/client/src/main.rs similarity index 99% rename from src/main.rs rename to client/src/main.rs index 49d7ded6..f49f86a2 100644 --- a/src/main.rs +++ b/client/src/main.rs @@ -1,7 +1,7 @@ use clap::Parser; use std::time::Duration; -use utils::{ +use common::{ cache, ipc::{self, connect_to_socket, get_socket_path, read_socket, Answer, RequestSend}, }; @@ -266,7 +266,7 @@ fn restore_from_cache(requested_outputs: &[String]) -> Result<(), String> { let (_, _, outputs) = get_format_dims_and_outputs(requested_outputs)?; for output in outputs.iter().flatten() { - let img_path = utils::cache::get_previous_image_path(output) + let img_path = common::cache::get_previous_image_path(output) .map_err(|e| format!("failed to get previous image path: {e}"))?; #[allow(deprecated)] if let Err(e) = process_swww_args(&Swww::Img(cli::Img { diff --git a/utils/Cargo.toml b/common/Cargo.toml similarity index 56% rename from utils/Cargo.toml rename to common/Cargo.toml index 444df3b6..76df47b0 100644 --- a/utils/Cargo.toml +++ b/common/Cargo.toml @@ -1,18 +1,28 @@ [package] -name = "utils" -version = "0.9.5-masterV2" -authors = ["Leonardo Gibrowski Faé "] -edition = "2021" -license-file = "../LICENSE" +name = "common" +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +license-file.workspace = true + +[lints] +workspace = true [dependencies] -rustix = { version = "0.38", default-features = false, features = [ "std", "net", "shm", "mm", "param" ] } +rustix = { version = "0.38", default-features = false, features = [ + "std", + "net", + "shm", + "mm", + "param", +] } [build-dependencies] pkg-config = "0.3" [dev-dependencies] -fastrand = { version = "2.1", default-features = false, features = [ "std" ] } +fastrand = { version = "2.1", default-features = false, features = ["std"] } criterion = { version = "0.5", default-features = false } [[bench]] diff --git a/utils/benches/compression.rs b/common/benches/compression.rs similarity index 82% rename from utils/benches/compression.rs rename to common/benches/compression.rs index bffd6645..b28ecf9d 100644 --- a/utils/benches/compression.rs +++ b/common/benches/compression.rs @@ -1,5 +1,5 @@ +use common::compression::{Compressor, Decompressor}; use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use utils::compression::{Compressor, Decompressor}; fn generate_data() -> (Box<[u8]>, Box<[u8]>) { let v1 = vec![120; 1920 * 1080 * 3]; @@ -45,7 +45,7 @@ pub fn compression_and_decompression(c: &mut Criterion) { b.iter(|| { black_box( compressor - .compress(&prev, &cur, utils::ipc::PixelFormat::Xrgb) + .compress(&prev, &cur, common::ipc::PixelFormat::Xrgb) .is_some(), ) }) @@ -54,14 +54,18 @@ pub fn compression_and_decompression(c: &mut Criterion) { let mut decomp = c.benchmark_group("decompression 4 channels"); let bitpack = compressor - .compress(&prev, &cur, utils::ipc::PixelFormat::Xrgb) + .compress(&prev, &cur, common::ipc::PixelFormat::Xrgb) .unwrap(); let mut canvas = buf_from(&prev); let mut decompressor = Decompressor::new(); decomp.bench_function("Full", |b| { b.iter(|| { - black_box(decompressor.decompress(&bitpack, &mut canvas, utils::ipc::PixelFormat::Xrgb)) + black_box(decompressor.decompress( + &bitpack, + &mut canvas, + common::ipc::PixelFormat::Xrgb, + )) }) }); diff --git a/utils/build.rs b/common/build.rs similarity index 100% rename from utils/build.rs rename to common/build.rs diff --git a/utils/src/cache.rs b/common/src/cache.rs similarity index 100% rename from utils/src/cache.rs rename to common/src/cache.rs diff --git a/utils/src/compression/comp/mod.rs b/common/src/compression/comp/mod.rs similarity index 100% rename from utils/src/compression/comp/mod.rs rename to common/src/compression/comp/mod.rs diff --git a/utils/src/compression/comp/sse2.rs b/common/src/compression/comp/sse2.rs similarity index 100% rename from utils/src/compression/comp/sse2.rs rename to common/src/compression/comp/sse2.rs diff --git a/utils/src/compression/cpu.rs b/common/src/compression/cpu.rs similarity index 100% rename from utils/src/compression/cpu.rs rename to common/src/compression/cpu.rs diff --git a/utils/src/compression/decomp/mod.rs b/common/src/compression/decomp/mod.rs similarity index 100% rename from utils/src/compression/decomp/mod.rs rename to common/src/compression/decomp/mod.rs diff --git a/utils/src/compression/decomp/ssse3.rs b/common/src/compression/decomp/ssse3.rs similarity index 100% rename from utils/src/compression/decomp/ssse3.rs rename to common/src/compression/decomp/ssse3.rs diff --git a/utils/src/compression/mod.rs b/common/src/compression/mod.rs similarity index 100% rename from utils/src/compression/mod.rs rename to common/src/compression/mod.rs diff --git a/utils/src/ipc/mmap.rs b/common/src/ipc/mmap.rs similarity index 100% rename from utils/src/ipc/mmap.rs rename to common/src/ipc/mmap.rs diff --git a/utils/src/ipc/mod.rs b/common/src/ipc/mod.rs similarity index 100% rename from utils/src/ipc/mod.rs rename to common/src/ipc/mod.rs diff --git a/utils/src/ipc/socket.rs b/common/src/ipc/socket.rs similarity index 100% rename from utils/src/ipc/socket.rs rename to common/src/ipc/socket.rs diff --git a/utils/src/ipc/types.rs b/common/src/ipc/types.rs similarity index 100% rename from utils/src/ipc/types.rs rename to common/src/ipc/types.rs diff --git a/utils/src/lib.rs b/common/src/lib.rs similarity index 100% rename from utils/src/lib.rs rename to common/src/lib.rs diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index f7b49091..929b1b70 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -1,19 +1,26 @@ [package] name = "swww-daemon" -version = "0.9.5-masterV2" -authors = ["Leonardo Gibrowski Faé "] -edition = "2021" +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +license-file.workspace = true -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lints] +workspace = true [dependencies] -log = { version = "0.4", default_features = false, features = [ "max_level_debug", "release_max_level_info", "std" ] } +log = { version = "0.4", default-features = false, features = [ + "max_level_debug", + "release_max_level_info", + "std", +] } -rustix = { version = "0.38", default-features = false, features = [ "event" ] } +rustix = { version = "0.38", default-features = false, features = ["event"] } libc = "0.2" keyframe = "1.1" sd-notify = { version = "0.4.1" } -utils = { version = "0.9.5-masterV2", path = "../utils" } +common = { workspace = true } diff --git a/daemon/src/animations/mod.rs b/daemon/src/animations/mod.rs index 5d356199..d0e7c4dc 100644 --- a/daemon/src/animations/mod.rs +++ b/daemon/src/animations/mod.rs @@ -5,7 +5,7 @@ use std::{ thread::{self, Scope}, }; -use utils::{ +use common::{ compression::Decompressor, ipc::{self, Animation, Answer, BgImg, ImgReq}, }; diff --git a/daemon/src/animations/transitions.rs b/daemon/src/animations/transitions.rs index abc83309..045b2215 100644 --- a/daemon/src/animations/transitions.rs +++ b/daemon/src/animations/transitions.rs @@ -3,8 +3,8 @@ use std::{ time::{Duration, Instant}, }; +use common::ipc::{Position, TransitionType}; use log::debug; -use utils::ipc::{Position, TransitionType}; use crate::{ wallpaper::{AnimationToken, Wallpaper}, @@ -35,7 +35,7 @@ impl<'a> Transition<'a> { pub(super) fn new( wallpapers: &'a mut Vec>, dimensions: (u32, u32), - transition: &utils::ipc::Transition, + transition: &common::ipc::Transition, ) -> Self { Transition { animation_tokens: wallpapers diff --git a/daemon/src/cli.rs b/daemon/src/cli.rs index 6f72ef23..79d0227d 100644 --- a/daemon/src/cli.rs +++ b/daemon/src/cli.rs @@ -1,4 +1,4 @@ -use utils::ipc::PixelFormat; +use common::ipc::PixelFormat; pub struct Cli { pub format: Option, diff --git a/daemon/src/main.rs b/daemon/src/main.rs index 7231e510..47f1a253 100644 --- a/daemon/src/main.rs +++ b/daemon/src/main.rs @@ -30,7 +30,7 @@ use std::{ }, }; -use utils::ipc::{ +use common::ipc::{ connect_to_socket, get_socket_path, read_socket, Answer, BgInfo, ImageReq, MmappedStr, RequestRecv, RequestSend, Scale, }; @@ -125,7 +125,7 @@ impl Daemon { } fn recv_socket_msg(&mut self, stream: OwnedFd) { - let bytes = match utils::ipc::read_socket(&stream) { + let bytes = match common::ipc::read_socket(&stream) { Ok(bytes) => bytes, Err(e) => { error!("FATAL: cannot read socket: {e}. Exiting..."); @@ -143,7 +143,7 @@ impl Daemon { .spawn(move || { crate::wallpaper::stop_animations(&wallpapers); for wallpaper in &wallpapers { - wallpaper.set_img_info(utils::ipc::BgImg::Color(clear.color)); + wallpaper.set_img_info(common::ipc::BgImg::Color(clear.color)); wallpaper.clear(clear.color); } crate::wallpaper::attach_buffers_and_damange_surfaces(&wallpapers); diff --git a/daemon/src/wallpaper.rs b/daemon/src/wallpaper.rs index 17160c00..fb80946f 100644 --- a/daemon/src/wallpaper.rs +++ b/daemon/src/wallpaper.rs @@ -1,5 +1,5 @@ +use common::ipc::{BgImg, BgInfo, Scale}; use log::{debug, error, warn}; -use utils::ipc::{BgImg, BgInfo, Scale}; use std::{ num::NonZeroI32, @@ -238,7 +238,7 @@ impl Wallpaper { .name("cache loader".to_string()) .stack_size(1 << 14) .spawn(move || { - if let Err(e) = utils::cache::load(&name) { + if let Err(e) = common::cache::load(&name) { warn!("failed to load cache: {e}"); } }) @@ -487,7 +487,7 @@ pub(crate) fn commit_wallpapers(wallpapers: &[Arc]) { impl Drop for Wallpaper { fn drop(&mut self) { // note we shouldn't panic in a drop implementation - + if let Err(e) = wp_viewport::req::destroy(self.wp_viewport) { error!("error destroying wp_viewport: {e:?}"); } diff --git a/daemon/src/wayland/bump_pool.rs b/daemon/src/wayland/bump_pool.rs index 63630a9a..14a29563 100644 --- a/daemon/src/wayland/bump_pool.rs +++ b/daemon/src/wayland/bump_pool.rs @@ -1,6 +1,6 @@ use std::sync::atomic::{AtomicBool, Ordering}; -use utils::ipc::Mmap; +use common::ipc::Mmap; use super::{globals, ObjectId}; diff --git a/daemon/src/wayland/globals.rs b/daemon/src/wayland/globals.rs index 2316c06b..8eeb1911 100644 --- a/daemon/src/wayland/globals.rs +++ b/daemon/src/wayland/globals.rs @@ -17,8 +17,8 @@ use rustix::{ net::SocketAddrAny, }; +use common::ipc::PixelFormat; use log::{debug, error, info}; -use utils::ipc::PixelFormat; use super::{ObjectId, ObjectManager, WlDynObj}; use std::{ diff --git a/tests/spell_check.rs b/tests/spell_check.rs index 75ec3ee1..bf13da86 100644 --- a/tests/spell_check.rs +++ b/tests/spell_check.rs @@ -16,7 +16,7 @@ fn spell_check_code_and_man_pages() { "doc/generated", // skip the generated documentation "src", // client "daemon/src", // daemon - "utils/src", // common code + "common/src", // common code "doc", // man pages "example_scripts", // scripts "CHANGELOG.md", diff --git a/version.sh b/version.sh index 19d3fddb..709a2f3c 100755 --- a/version.sh +++ b/version.sh @@ -19,21 +19,9 @@ cargo test --workspace -- --include-ignored ./doc/gen.sh # make sure the docs "compile" # Cargo.toml: -sed \ - -e "s/^version = .*/version = \"$1\"/" \ - -e "s/^utils.*/utils = { version = \"$1\", path = \"utils\" }/" \ - Cargo.toml > TMP +sed -e "s/^version = .*/version = \"$1\"/" Cargo.toml > TMP mv -v TMP Cargo.toml -sed "s/^version = .*/version = \"$1\"/" utils/Cargo.toml > TMP -mv -v TMP utils/Cargo.toml - -sed \ - -e "s/^version = .*/version = \"$1\"/" \ - -e "s/^utils.*/utils = { version = \"$1\", path = \"..\/utils\" }/" \ - daemon/Cargo.toml > TMP -mv -v TMP daemon/Cargo.toml - # CHANGELOG: sed -e "s/^### Unreleased/### $1/" \ -e '1s/^/### Unreleased\n\n\n/' CHANGELOG.md > TMP