Skip to main content

easy_install/
manfiest.rs

1// https://github.com/axodotdev/cargo-dist/blob/main/cargo-dist-schema/src/lib.rs
2
3use serde::{Deserialize, Serialize};
4use std::collections::BTreeMap;
5pub(crate) type RelPath = String;
6pub(crate) type ArtifactId = String;
7pub(crate) type TripleName = String;
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub(crate) struct DistManifest {
11    #[serde(default)]
12    #[serde(skip_serializing_if = "BTreeMap::is_empty")]
13    pub(crate) artifacts: BTreeMap<ArtifactId, Artifact>,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub(crate) struct Artifact {
18    #[serde(skip_serializing_if = "Option::is_none")]
19    #[serde(default)]
20    pub(crate) kind: Option<ArtifactId>,
21
22    #[serde(skip_serializing_if = "Option::is_none")]
23    #[serde(default)]
24    pub(crate) name: Option<ArtifactId>,
25    #[serde(skip_serializing_if = "Vec::is_empty")]
26    #[serde(default)]
27    pub(crate) target_triples: Vec<TripleName>,
28    /// Assets included in the bundle (like executables and READMEs)
29    #[serde(skip_serializing_if = "Vec::is_empty")]
30    #[serde(default)]
31    pub(crate) assets: Vec<Asset>,
32}
33/// An asset contained in an artifact (executable, license, etc.)
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub(crate) struct Asset {
36    /// The executable_name name of the asset
37    #[serde(default)]
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub(crate) executable_name: Option<String>,
40
41    /// The high-level name of the asset
42    #[serde(default)]
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub(crate) name: Option<String>,
45    /// The path of the asset relative to the root of the artifact
46    #[serde(default)]
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub(crate) path: Option<RelPath>,
49    /// The kind of asset this is
50    #[serde(flatten)]
51    pub(crate) kind: AssetKind,
52}
53
54/// An artifact included in a Distributable
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(tag = "kind")]
57#[non_exhaustive]
58pub(crate) enum AssetKind {
59    /// An executable artifact
60    #[serde(rename = "executable")]
61    Executable(ExecutableAsset),
62    /// A C dynamic library
63    #[serde(rename = "c_dynamic_library")]
64    CDynamicLibrary(DynamicLibraryAsset),
65    /// A C static library
66    #[serde(rename = "c_static_library")]
67    CStaticLibrary(StaticLibraryAsset),
68    /// A README file
69    #[serde(rename = "readme")]
70    Readme,
71    /// A LICENSE file
72    #[serde(rename = "license")]
73    License,
74    /// A CHANGELOG or RELEASES file
75    #[serde(rename = "changelog")]
76    Changelog,
77    /// Unknown to this version of cargo-dist-schema
78    ///
79    /// This is a fallback for forward/backward-compat
80    #[serde(other)]
81    #[serde(rename = "unknown")]
82    Unknown,
83}
84
85/// An executable artifact (exe/binary)
86#[derive(Debug, Clone, Serialize, Deserialize)]
87pub(crate) struct ExecutableAsset {
88    /// The name of the Artifact containing symbols for this executable
89    #[serde(skip_serializing_if = "Option::is_none")]
90    #[serde(default)]
91    pub(crate) symbols_artifact: Option<ArtifactId>,
92}
93
94/// A C dynamic library artifact (so/dylib/dll)
95#[derive(Debug, Clone, Serialize, Deserialize)]
96pub(crate) struct DynamicLibraryAsset {
97    /// The name of the Artifact containing symbols for this library
98    #[serde(skip_serializing_if = "Option::is_none")]
99    #[serde(default)]
100    pub(crate) symbols_artifact: Option<ArtifactId>,
101}
102
103/// A C static library artifact (a/lib)
104#[derive(Debug, Clone, Serialize, Deserialize)]
105pub(crate) struct StaticLibraryAsset {
106    /// The name of the Artifact containing symbols for this library
107    #[serde(skip_serializing_if = "Option::is_none")]
108    #[serde(default)]
109    pub(crate) symbols_artifact: Option<ArtifactId>,
110}
111
112// #[derive(Debug, Clone, Serialize, Deserialize)]
113// #[serde(tag = "kind")]
114// #[non_exhaustive]
115// pub(crate) enum ArtifactKind {
116//     /// A zip or a tarball
117//     #[serde(rename = "executable-zip")]
118//     ExecutableZip,
119//     /// Standalone Symbols/Debuginfo for a build
120//     #[serde(rename = "symbols")]
121//     Symbols,
122//     /// Installer
123//     #[serde(rename = "installer")]
124//     Installer,
125//     /// A checksum of another artifact
126//     #[serde(rename = "checksum")]
127//     Checksum,
128//     /// The checksums of many artifacts
129//     #[serde(rename = "unified-checksum")]
130//     UnifiedChecksum,
131//     /// A tarball containing the source code
132//     #[serde(rename = "source-tarball")]
133//     SourceTarball,
134//     /// Some form of extra artifact produced by a sidecar build
135//     #[serde(rename = "extra-artifact")]
136//     ExtraArtifact,
137//     /// An updater executable
138//     #[serde(rename = "updater")]
139//     Updater,
140//     /// A file that already exists
141//     // #[serde(rename = "sbom")]
142//     // SBOM,
143//     /// Unknown to this version of cargo-dist-schema
144//     ///
145//     /// This is a fallback for forward/backward-compat
146//     #[serde(other)]
147//     #[serde(rename = "unknown")]
148//     Unknown,
149// }