Skip to content

Commit

Permalink
Merge pull request #330 from rkuklik/main
Browse files Browse the repository at this point in the history
Improve cargo workspace
  • Loading branch information
LGFae committed Jun 18, 2024
2 parents 57f5337 + 18cee57 commit 1bb137b
Show file tree
Hide file tree
Showing 34 changed files with 131 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 19 additions & 35 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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é <leonardo.fae44@gmail.com>"]
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
Expand All @@ -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"
2 changes: 1 addition & 1 deletion build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
41 changes: 41 additions & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion build.rs → client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/imgproc.rs → client/src/imgproc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
time::Duration,
};

use utils::{
use common::{
compression::{BitPack, Compressor},
ipc::{self, Coord, PixelFormat, Position},
};
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs → client/src/main.rs
Original file line number Diff line number Diff line change
@@ -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},
};
Expand Down Expand Up @@ -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 {
Expand Down
24 changes: 17 additions & 7 deletions utils/Cargo.toml → common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
[package]
name = "utils"
version = "0.9.5-masterV2"
authors = ["Leonardo Gibrowski Faé <leonardo.fae44@gmail.com>"]
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]]
Expand Down
12 changes: 8 additions & 4 deletions utils/benches/compression.rs → common/benches/compression.rs
Original file line number Diff line number Diff line change
@@ -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];
Expand Down Expand Up @@ -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(),
)
})
Expand All @@ -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,
))
})
});

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 14 additions & 7 deletions daemon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
[package]
name = "swww-daemon"
version = "0.9.5-masterV2"
authors = ["Leonardo Gibrowski Faé <leonardo.fae44@gmail.com>"]
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 }
2 changes: 1 addition & 1 deletion daemon/src/animations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
thread::{self, Scope},
};

use utils::{
use common::{
compression::Decompressor,
ipc::{self, Animation, Answer, BgImg, ImgReq},
};
Expand Down
4 changes: 2 additions & 2 deletions daemon/src/animations/transitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -35,7 +35,7 @@ impl<'a> Transition<'a> {
pub(super) fn new(
wallpapers: &'a mut Vec<Arc<Wallpaper>>,
dimensions: (u32, u32),
transition: &utils::ipc::Transition,
transition: &common::ipc::Transition,
) -> Self {
Transition {
animation_tokens: wallpapers
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use utils::ipc::PixelFormat;
use common::ipc::PixelFormat;

pub struct Cli {
pub format: Option<PixelFormat>,
Expand Down
6 changes: 3 additions & 3 deletions daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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...");
Expand All @@ -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);
Expand Down

0 comments on commit 1bb137b

Please sign in to comment.