summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock63
-rw-r--r--Cargo.toml19
-rw-r--r--crates/atom/Cargo.toml11
-rw-r--r--crates/atom/meson.build9
-rw-r--r--crates/atom/src/lib.rs (renamed from src/atom/mod.rs)16
-rw-r--r--crates/atom/src/meson.build1
-rw-r--r--crates/atom/src/parsers.rs (renamed from src/atom/parsers.rs)18
-rw-r--r--crates/meson.build1
-rw-r--r--crates/parseable/Cargo.toml7
-rw-r--r--crates/parseable/src/lib.rs18
-rw-r--r--crates/repo/Cargo.toml11
-rw-r--r--crates/repo/src/ebuild/meson.build (renamed from src/atom/meson.build)0
-rw-r--r--crates/repo/src/ebuild/mod.rs (renamed from src/repo/ebuild/mod.rs)8
-rw-r--r--crates/repo/src/ebuild/parsers.rs (renamed from src/repo/ebuild/parsers.rs)16
-rw-r--r--crates/repo/src/lib.rs (renamed from src/repo/mod.rs)22
-rw-r--r--crates/repo/src/meson.build (renamed from src/repo/meson.build)0
-rw-r--r--crates/useflag/Cargo.toml9
-rw-r--r--crates/useflag/src/lib.rs (renamed from src/useflag/mod.rs)9
-rw-r--r--crates/useflag/src/meson.build (renamed from src/repo/ebuild/meson.build)0
-rw-r--r--crates/useflag/src/parsers.rs (renamed from src/useflag/parsers.rs)7
-rw-r--r--meson.build44
-rw-r--r--src/lib.rs81
-rw-r--r--src/meson.build4
-rw-r--r--src/useflag/meson.build1
24 files changed, 194 insertions, 181 deletions
diff --git a/Cargo.lock b/Cargo.lock
index dd0d9c6..7a7deb1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3,6 +3,17 @@
version = 4
[[package]]
+name = "atom"
+version = "0.1.0"
+dependencies = [
+ "get",
+ "itertools",
+ "mon",
+ "parseable",
+ "useflag",
+]
+
+[[package]]
name = "either"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -12,10 +23,9 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
name = "gentoo-utils"
version = "0.1.0"
dependencies = [
- "get",
- "itertools",
- "mon",
- "thiserror",
+ "atom",
+ "repo",
+ "useflag",
]
[[package]]
@@ -43,6 +53,13 @@ version = "0.1.0"
source = "git+https://jturnerusa.dev/cgit/mon/?rev=67861a4df8a5abdd70651d47cf265b20c41d2acc#67861a4df8a5abdd70651d47cf265b20c41d2acc"
[[package]]
+name = "parseable"
+version = "0.1.0"
+dependencies = [
+ "mon",
+]
+
+[[package]]
name = "proc-macro2"
version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -61,6 +78,17 @@ dependencies = [
]
[[package]]
+name = "repo"
+version = "0.1.0"
+dependencies = [
+ "atom",
+ "get",
+ "mon",
+ "parseable",
+ "useflag",
+]
+
+[[package]]
name = "syn"
version = "2.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -72,27 +100,16 @@ dependencies = [
]
[[package]]
-name = "thiserror"
-version = "2.0.17"
+name = "unicode-ident"
+version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
-dependencies = [
- "thiserror-impl",
-]
+checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06"
[[package]]
-name = "thiserror-impl"
-version = "2.0.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
+name = "useflag"
+version = "0.1.0"
dependencies = [
- "proc-macro2",
- "quote",
- "syn",
+ "get",
+ "mon",
+ "parseable",
]
-
-[[package]]
-name = "unicode-ident"
-version = "1.0.20"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06"
diff --git a/Cargo.toml b/Cargo.toml
index 3f99b99..c6c8296 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,10 +1,21 @@
+[workspace]
+members = [
+ "crates/parseable",
+ "crates/atom",
+ "crates/useflag",
+ "crates/repo"
+]
+
+[workspace.dependencies]
+mon = { git = "https://jturnerusa.dev/cgit/mon/", rev = "67861a4df8a5abdd70651d47cf265b20c41d2acc" }
+get = { git = "https://jturnerusa.dev/cgit/get/", rev = "cd5f75b65777a855ab010c3137304ac05f2e56b8" }
+
[package]
name = "gentoo-utils"
version = "0.1.0"
edition = "2024"
[dependencies]
-mon = { git = "https://jturnerusa.dev/cgit/mon/", rev = "67861a4df8a5abdd70651d47cf265b20c41d2acc" }
-get = { git = "https://jturnerusa.dev/cgit/get/", rev = "cd5f75b65777a855ab010c3137304ac05f2e56b8" }
-itertools = "0.14.0"
-thiserror = "2.0.17" \ No newline at end of file
+atom = { path = "crates/atom" }
+useflag = { path = "crates/useflag" }
+repo = { path = "crates/repo" } \ No newline at end of file
diff --git a/crates/atom/Cargo.toml b/crates/atom/Cargo.toml
new file mode 100644
index 0000000..092759f
--- /dev/null
+++ b/crates/atom/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "atom"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
+mon = { workspace = true }
+get = { workspace = true }
+useflag = { path = "../useflag" }
+parseable = { path = "../parseable" }
+itertools = "0.14.0" \ No newline at end of file
diff --git a/crates/atom/meson.build b/crates/atom/meson.build
new file mode 100644
index 0000000..ff4b6e6
--- /dev/null
+++ b/crates/atom/meson.build
@@ -0,0 +1,9 @@
+subdir('src')
+
+pkg = cargo.package('atom')
+lib = pkg.library()
+
+meson.override_dependency(
+ 'atom-' + pkg.api() + '-rs',
+ declare_dependency(link_with: lib),
+)
diff --git a/src/atom/mod.rs b/crates/atom/src/lib.rs
index 24cb555..39e32af 100644
--- a/src/atom/mod.rs
+++ b/crates/atom/src/lib.rs
@@ -1,10 +1,24 @@
+#![deny(clippy::pedantic, unused_imports)]
+#![allow(
+ dead_code,
+ unstable_name_collisions,
+ clippy::missing_errors_doc,
+ clippy::missing_panics_doc
+)]
+#![feature(impl_trait_in_assoc_type)]
+
use core::{
fmt::{self},
option::Option,
};
+
use std::cmp::Ordering;
-use crate::useflag::UseFlag;
+// TODO: wtf?
+#[allow(unused_imports)]
+use parseable::Parseable;
+
+use useflag::UseFlag;
use get::Get;
diff --git a/crates/atom/src/meson.build b/crates/atom/src/meson.build
new file mode 100644
index 0000000..0293be6
--- /dev/null
+++ b/crates/atom/src/meson.build
@@ -0,0 +1 @@
+sources += files('lib.rs', 'parsers.rs')
diff --git a/src/atom/parsers.rs b/crates/atom/src/parsers.rs
index c7ff586..2f8cb8c 100644
--- a/src/atom/parsers.rs
+++ b/crates/atom/src/parsers.rs
@@ -1,20 +1,20 @@
use core::option::Option::None;
-use mon::{
- Parser, ParserIter, ascii_alphanumeric, ascii_numeric, ascii_numeric1, eof, r#if,
- input::InputIter, one_of, tag,
-};
-
use crate::{
- Parseable,
- atom::{
Atom, Blocker, BuildId, Category, Cp, Cpv, Name, Repo, Slot, SlotName, SlotOperator,
UseDep, UseDepCondition, UseDepNegate, UseDepSign, Version, VersionNumber, VersionNumbers,
VersionOperator, VersionSuffix, VersionSuffixKind, VersionSuffixes, Wildcard,
- },
- useflag::UseFlag,
};
+use mon::{
+ Parser, ParserIter, ascii_alphanumeric, ascii_numeric, ascii_numeric1, eof, r#if,
+ input::InputIter, one_of, tag,
+};
+
+use parseable::Parseable;
+
+use useflag::UseFlag;
+
impl<'a> Parseable<'a, &'a str> for Blocker {
type Parser = impl Parser<&'a str, Output = Self>;
diff --git a/crates/meson.build b/crates/meson.build
new file mode 100644
index 0000000..e64f43d
--- /dev/null
+++ b/crates/meson.build
@@ -0,0 +1 @@
+subdir('atom')
diff --git a/crates/parseable/Cargo.toml b/crates/parseable/Cargo.toml
new file mode 100644
index 0000000..25b0c77
--- /dev/null
+++ b/crates/parseable/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "parseable"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
+mon = { workspace = true } \ No newline at end of file
diff --git a/crates/parseable/src/lib.rs b/crates/parseable/src/lib.rs
new file mode 100644
index 0000000..38ed418
--- /dev/null
+++ b/crates/parseable/src/lib.rs
@@ -0,0 +1,18 @@
+#![feature(impl_trait_in_assoc_type)]
+
+use mon::{Parser, input::{Input, InputIter}};
+
+pub trait Parseable<'a, I: Input + 'a> {
+ type Parser: Parser<I, Output = Self>;
+
+ fn parser() -> Self::Parser;
+
+ fn parse(input: I) -> Result<Self, I>
+ where
+ Self: Sized,
+ {
+ Self::parser()
+ .parse_finished(InputIter::new(input))
+ .map_err(|e| e.rest())
+ }
+}
diff --git a/crates/repo/Cargo.toml b/crates/repo/Cargo.toml
new file mode 100644
index 0000000..8b13ede
--- /dev/null
+++ b/crates/repo/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "repo"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
+atom = { path = "../atom" }
+useflag = { path = "../useflag" }
+parseable = { path = "../parseable" }
+mon = { workspace = true }
+get = { workspace = true } \ No newline at end of file
diff --git a/src/atom/meson.build b/crates/repo/src/ebuild/meson.build
index a7331a8..a7331a8 100644
--- a/src/atom/meson.build
+++ b/crates/repo/src/ebuild/meson.build
diff --git a/src/repo/ebuild/mod.rs b/crates/repo/src/ebuild/mod.rs
index 3f52db9..6c547c5 100644
--- a/src/repo/ebuild/mod.rs
+++ b/crates/repo/src/ebuild/mod.rs
@@ -1,10 +1,10 @@
use get::Get;
+
use std::path::PathBuf;
-use crate::{
- atom::{Atom, Name, Slot, Version},
- useflag::{IUseFlag, UseFlag},
-};
+use atom::{Atom, Name, Slot, Version};
+
+use useflag::{IUseFlag, UseFlag};
mod parsers;
diff --git a/src/repo/ebuild/parsers.rs b/crates/repo/src/ebuild/parsers.rs
index c80cdf2..6dc3525 100644
--- a/src/repo/ebuild/parsers.rs
+++ b/crates/repo/src/ebuild/parsers.rs
@@ -1,14 +1,14 @@
use std::path::PathBuf;
+use crate::ebuild::{Conditional, Depend, Eapi, Eclass, License, SrcUri, Uri, UriPrefix};
+
use mon::{
Parser, ParserIter, ascii_alpha1, ascii_alphanumeric, ascii_whitespace1, r#if, one_of, tag,
};
-use crate::{
- Parseable,
- repo::ebuild::{Conditional, Depend, Eapi, Eclass, License, SrcUri, Uri, UriPrefix},
- useflag::UseFlag,
-};
+use parseable::Parseable;
+
+use useflag::UseFlag;
impl<'a> Parseable<'a, &'a str> for UriPrefix {
type Parser = impl Parser<&'a str, Output = Self>;
@@ -172,11 +172,13 @@ impl<'a> Parseable<'a, &'a str> for Conditional {
#[cfg(test)]
mod test {
+ use super::*;
+
use mon::{ParserIter, input::InputIter};
- use crate::{atom::Atom, repo::ebuild::Depend};
+ use atom::Atom;
- use super::*;
+ use crate::ebuild::Depend;
#[test]
fn test_src_uri() {
diff --git a/src/repo/mod.rs b/crates/repo/src/lib.rs
index eb68839..df4412d 100644
--- a/src/repo/mod.rs
+++ b/crates/repo/src/lib.rs
@@ -1,19 +1,29 @@
+#![deny(clippy::pedantic, unused_imports)]
+#![allow(
+ dead_code,
+ unstable_name_collisions,
+ clippy::missing_errors_doc,
+ clippy::missing_panics_doc
+)]
+#![feature(impl_trait_in_assoc_type)]
+
use std::{
fs, io,
os::unix::ffi::OsStrExt,
path::{Path, PathBuf},
};
+use crate::ebuild::{Depend, Eapi, Ebuild, Eclass, License, SrcUri};
+
use get::Get;
use mon::{Parser, ParserIter, ascii_whitespace1, input::InputIter, tag};
-use crate::{
- Parseable,
- atom::{self, Atom},
- repo::ebuild::{Depend, Eapi, Ebuild, Eclass, License, SrcUri},
- useflag::IUseFlag,
-};
+use parseable::Parseable;
+
+use atom::{self, Atom};
+
+use useflag::IUseFlag;
pub mod ebuild;
diff --git a/src/repo/meson.build b/crates/repo/src/meson.build
index c1be7a7..c1be7a7 100644
--- a/src/repo/meson.build
+++ b/crates/repo/src/meson.build
diff --git a/crates/useflag/Cargo.toml b/crates/useflag/Cargo.toml
new file mode 100644
index 0000000..16c8c34
--- /dev/null
+++ b/crates/useflag/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "useflag"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
+mon = { workspace = true }
+get = { workspace = true }
+parseable = { path = "../parseable" } \ No newline at end of file
diff --git a/src/useflag/mod.rs b/crates/useflag/src/lib.rs
index c367b1a..75c40eb 100644
--- a/src/useflag/mod.rs
+++ b/crates/useflag/src/lib.rs
@@ -1,3 +1,12 @@
+#![deny(clippy::pedantic, unused_imports)]
+#![allow(
+ dead_code,
+ unstable_name_collisions,
+ clippy::missing_errors_doc,
+ clippy::missing_panics_doc
+)]
+#![feature(impl_trait_in_assoc_type)]
+
use core::fmt;
use get::Get;
diff --git a/src/repo/ebuild/meson.build b/crates/useflag/src/meson.build
index a7331a8..a7331a8 100644
--- a/src/repo/ebuild/meson.build
+++ b/crates/useflag/src/meson.build
diff --git a/src/useflag/parsers.rs b/crates/useflag/src/parsers.rs
index ca5929d..3007bde 100644
--- a/src/useflag/parsers.rs
+++ b/crates/useflag/src/parsers.rs
@@ -1,9 +1,8 @@
+use parseable::Parseable;
+
use mon::{Parser, ParserIter, ascii_alphanumeric, one_of, tag};
-use crate::{
- Parseable,
- useflag::{IUseFlag, UseFlag},
-};
+use crate::{IUseFlag, UseFlag};
impl<'a> Parseable<'a, &'a str> for UseFlag {
type Parser = impl Parser<&'a str, Output = Self>;
diff --git a/meson.build b/meson.build
index 389720b..291eeb7 100644
--- a/meson.build
+++ b/meson.build
@@ -7,48 +7,12 @@ project(
rustfmt = find_program('rustfmt')
-rust = import('rust')
fs = import('fs')
+rust = import('rust')
+cargo = rust.workspace()
+
sources = []
subdir('src')
-
-mon = dependency('mon-0.1-rs')
-get = dependency('get-0.1-rs')
-itertools = dependency('itertools-0.14-rs')
-thiserror = subproject('thiserror').get_variable('thiserror')
-
-gentoo_utils = static_library(
- 'gentoo_utils',
- 'src/lib.rs',
- dependencies: [mon, get, itertools],
- link_with: [thiserror],
-)
-
-custom_target(
- 'rustfmt',
- input: sources,
- output: 'rustfmt',
- command: [rustfmt, '--edition=2024', '--check', '@INPUT@'],
- build_always_stale: true,
-)
-
-if get_option('tests').enabled()
- rust.test('unittests', gentoo_utils)
- subdir('tests')
-endif
-
-if get_option('fuzz').enabled()
- subdir('fuzz')
-endif
-
-if get_option('docs').enabled()
- rust.doctest(
- 'doctests',
- gentoo_utils,
- dependencies: [mon, get, itertools],
- link_with: [thiserror],
- args: ['--nocapture'],
- )
-endif
+subdir('crates')
diff --git a/src/lib.rs b/src/lib.rs
index b7b01a7..78fe580 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,81 +11,6 @@
//! - vdb reader
//! - sourcing ebuilds with bash
//!
-
-#![deny(clippy::pedantic, unused_imports)]
-#![allow(
- dead_code,
- unstable_name_collisions,
- clippy::missing_errors_doc,
- clippy::missing_panics_doc
-)]
-#![feature(impl_trait_in_assoc_type)]
-
-use mon::{
- Parser,
- input::{Input, InputIter},
-};
-
-pub trait Parseable<'a, I: Input + 'a> {
- type Parser: Parser<I, Output = Self>;
-
- fn parser() -> Self::Parser;
-
- fn parse(input: I) -> Result<Self, I>
- where
- Self: Sized,
- {
- Self::parser()
- .parse_finished(InputIter::new(input))
- .map_err(|e| e.rest())
- }
-}
-
-/// Strongly typed atom and cpv representations.
-///
-/// Create atoms from parsers:
-/// ```
-/// use gentoo_utils::{Parseable, atom::Atom};
-///
-/// let emacs = Atom::parse("=app-editors/emacs-31.0-r1")
-/// .expect("failed to parse atom");
-///
-/// assert_eq!(emacs.to_string(), "=app-editors/emacs-31.0-r1");
-/// ````
-///
-/// Compare versions:
-/// ```
-/// use gentoo_utils::{Parseable, atom::Cpv};
-///
-/// let a = Cpv::parse("foo/bar-1.0").unwrap();
-/// let b = Cpv::parse("foo/bar-2.0").unwrap();
-///
-/// assert!(a < b);
-/// ```
-pub mod atom;
-
-/// Access to repos and ebuilds.
-///
-/// ```
-/// use gentoo_utils::repo::Repo;
-///
-/// let repo = Repo::new("/var/db/repos/gentoo");
-///
-/// for result in repo.categories().expect("failed to read categories") {
-/// let category = result.expect("failed to read category");
-///
-/// for result in category.ebuilds().expect("failed to read ebuilds") {
-/// let ebuild = result.expect("failed to read ebuild");
-///
-/// println!(
-/// "{}-{}: {}",
-/// ebuild.name(),
-/// ebuild.version(),
-/// ebuild.description().clone().unwrap_or("no description available".to_string())
-/// );
-/// }
-/// }
-///
-/// ```
-pub mod repo;
-pub mod useflag;
+pub use atom;
+pub use useflag;
+pub use repo;
diff --git a/src/meson.build b/src/meson.build
index 33a09de..8b7f4c9 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,5 +1 @@
sources += files('lib.rs')
-
-subdir('atom')
-subdir('repo')
-subdir('useflag')
diff --git a/src/useflag/meson.build b/src/useflag/meson.build
deleted file mode 100644
index a7331a8..0000000
--- a/src/useflag/meson.build
+++ /dev/null
@@ -1 +0,0 @@
-sources += files('mod.rs', 'parsers.rs')