Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serde_with without android dependencies #741

Closed
avahahn opened this issue May 3, 2024 · 1 comment
Closed

serde_with without android dependencies #741

avahahn opened this issue May 3, 2024 · 1 comment

Comments

@avahahn
Copy link

avahahn commented May 3, 2024

The serde_with crate uses chrono, which pulls in a number of android specific dependencies (which you can see in your top level Cargo.lock). Chrono does not need to pull these in if you arent using the Clock feature. It did not look like you were using offset::local so I think you can turn it off and ship without those dependencies. Doing so would lead to a smaller and faster to build library, which I would really appreciate. It was entertaining to find android centric dependencies in a CLI application I am developing.

For more information: chronotope/chrono#1220

@jonasbb
Copy link
Owner

jonasbb commented May 3, 2024

The local timezone is used, for example here. As such, disabling the clock feature would be a breaking change.

use ::chrono_0_4::Local;

I would love to have a way to not use the clock feature and instead just "detect" that it is enabled somewhere else in the dependency tree. Something like #[cfg(accessible(...))], but that isn't anywhere near stabilization rust-lang/rust#64797.

The timezone dependency is gated by [target.'cfg(target_os = "android")'.dependencies] so it will only be built if you target Android. Otherwise, it is just an entry in the lock file. Further, there is a cargo bug where it includes dependencies in the lockfile, even though they are disabled rust-lang/cargo#10801. However, they are never compiled.

@jonasbb jonasbb closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants