summaryrefslogtreecommitdiff
path: root/src/ebuild/mod.rs
blob: 50d9f3f43b9b71e4d291089c9aaff55cd61be8a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use get::Get;
use std::path::PathBuf;

use crate::{
    atom::{Atom, Name, Slot, Version},
    useflag::{IUseFlag, UseFlag},
};

pub mod parsers;
pub mod repo;

#[derive(Clone, Debug)]
pub enum Conditional {
    Negative(UseFlag),
    Positive(UseFlag),
}

#[derive(Clone, Debug)]
pub enum Depend<T> {
    Element(T),
    AllOf(Vec<Self>),
    AnyOf(Vec<Self>),
    OneOf(Vec<Self>),
    ConditionalGroup(Conditional, Vec<Self>),
}

#[derive(Debug, Clone)]
pub enum UriPrefix {
    Mirror,
    Fetch,
}

#[derive(Debug, Clone, Get)]
pub struct Uri {
    #[get(kind = "deref")]
    protocol: String,
    #[get(kind = "deref")]
    path: String,
}

#[derive(Debug, Clone)]
pub enum SrcUri {
    Filename(PathBuf),
    Uri {
        prefix: Option<UriPrefix>,
        uri: Uri,
        filename: Option<PathBuf>,
    },
}

#[derive(Debug, Clone, Get)]
pub struct License(#[get(method = "get", kind = "deref")] String);

#[derive(Debug, Clone, Get)]
pub struct Eapi(#[get(method = "get", kind = "deref")] String);

#[derive(Debug, Clone, Get)]
pub struct Eclass(#[get(method = "get", kind = "deref")] String);

#[derive(Debug, Clone, Get)]
pub struct Ebuild {
    name: Name,
    version: Version,
    slot: Option<Slot>,
    homepage: Option<String>,
    #[get(kind = "deref")]
    src_uri: Vec<Depend<SrcUri>>,
    eapi: Option<Eapi>,
    #[get(kind = "deref")]
    inherit: Vec<Eclass>,
    #[get(kind = "deref")]
    iuse: Vec<IUseFlag>,
    #[get(kind = "deref")]
    license: Vec<Depend<License>>,
    description: Option<String>,
    #[get(kind = "deref")]
    depend: Vec<Depend<Atom>>,
    #[get(kind = "deref")]
    bdepend: Vec<Depend<Atom>>,
    #[get(kind = "deref")]
    rdepend: Vec<Depend<Atom>>,
    #[get(kind = "deref")]
    idepend: Vec<Depend<Atom>>,
}