Add patches for directories/directories-next/option-ext

The rational is detailed in the root Cargo.toml.

While I don't personally mind MPL dependencies, even if I don't prefer them
(they're allowed in the deny.toml for a reason), I do mind the pointless scope
creep and wish to highlight how little it actually used from the crate by
re-defining it as the single function.

We could also fork directories-next, or directories, and remove the usage of
option-ext per https://github.com/dirs-dev/dirs-sys-rs/issues/24, yet that'd be
a much larger task than what was done here.

In the future, it may be beneficial to submit a PR to wasmtime replacing
directories-next with home, a cargo-team maintained library to get the home
directory and associated folders. An example migration can be found at
https://github.com/harryfei/which-rs/pull/80.
This commit is contained in:
Luke Parker 2023-12-04 07:40:56 -05:00
parent a5065e52e9
commit 1820e916ca
No known key found for this signature in database
5 changed files with 53 additions and 0 deletions

View file

@ -36,6 +36,8 @@ members = [
"coordinator/tributary",
"coordinator",
"substrate/tree-cleanup/option-ext",
"substrate/tree-cleanup/directories-next",
"substrate/tree-cleanup/bandersnatch_vrfs",
"substrate/tree-cleanup/w3f-bls",
@ -100,6 +102,17 @@ lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev
sp-core-hashing = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sp-std = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
# directories-next was created because directories was unmaintained
# directories-next is now unmaintained while directories is maintained
# The directories author pulls in ridiculously pointless crates and prefers
# copyleft licenses
# Serai's polkadot-sdk consolidated to directories-next, as directories-next is
# acceptable and because we couldn't consolidate to directories without forking
# wasmtime
# The following two patches resolve everything
option-ext = { path = "substrate/tree-cleanup/option-ext" }
directories-next = { path = "substrate/tree-cleanup/directories-next" }
# cargo believes the following are in-tree despite no features activating them
# We provide empty crates to not only prove they're unused, yet also clean up
# our Cargo.lock

View file

@ -0,0 +1,17 @@
[package]
name = "directories-next"
version = "2.0.0"
description = "Patch from directories-next back to directories"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/substrate/tree-cleanup/directories-next"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = []
edition = "2021"
rust-version = "1.74"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
directories = "5"

View file

@ -0,0 +1 @@
pub use directories::*;

View file

@ -0,0 +1,14 @@
[package]
name = "option-ext"
version = "0.2.0"
description = "Non-MPL option-ext with the exactly needed API for directories"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/substrate/tree-cleanup/option-ext"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = []
edition = "2021"
rust-version = "1.74"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

View file

@ -0,0 +1,8 @@
pub trait OptionExt<T: PartialEq> {
fn contains(&self, x: &T) -> bool;
}
impl<T: PartialEq> OptionExt<T> for Option<T> {
fn contains(&self, x: &T) -> bool {
self.as_ref() == Some(x)
}
}