|
8 | 8 | //!
|
9 | 9 | //! The root type of the schema is [`DistManifest`][].
|
10 | 10 |
|
| 11 | +pub mod macros; |
| 12 | + |
11 | 13 | use std::collections::BTreeMap;
|
12 | 14 |
|
13 | 15 | use schemars::JsonSchema;
|
14 | 16 | use semver::Version;
|
15 | 17 | use serde::{Deserialize, Serialize};
|
16 | 18 |
|
| 19 | +declare_strongly_typed_string! { |
| 20 | + /// A rust target-triple (e.g. "x86_64-pc-windows-msvc") |
| 21 | + pub struct TargetTriple => &TargetTripleRef; |
| 22 | +} |
| 23 | + |
| 24 | +impl TargetTripleRef { |
| 25 | + /// Returns true if this target triple contains the word "musl" |
| 26 | + pub fn is_musl(&self) -> bool { |
| 27 | + self.0.contains("musl") |
| 28 | + } |
| 29 | + |
| 30 | + /// Returns true if this target triple contains the word "linux" |
| 31 | + pub fn is_linux(&self) -> bool { |
| 32 | + self.0.contains("linux") |
| 33 | + } |
| 34 | + |
| 35 | + /// Returns true if this target triple contains the word "apple" |
| 36 | + pub fn is_apple(&self) -> bool { |
| 37 | + self.0.contains("apple") |
| 38 | + } |
| 39 | + |
| 40 | + /// Returns true if this target triple contains the word "darwin" |
| 41 | + pub fn is_darwin(&self) -> bool { |
| 42 | + self.0.contains("darwin") |
| 43 | + } |
| 44 | + |
| 45 | + /// Returns true if this target triple contains the word "windows" |
| 46 | + pub fn is_windows(&self) -> bool { |
| 47 | + self.0.contains("windows") |
| 48 | + } |
| 49 | + |
| 50 | + /// Returns true if this target triple contains the word "x86_64" |
| 51 | + pub fn is_x86_64(&self) -> bool { |
| 52 | + self.0.contains("x86_64") |
| 53 | + } |
| 54 | + |
| 55 | + /// Returns true if this target triple contains the word "aarch64" |
| 56 | + pub fn is_aarch64(&self) -> bool { |
| 57 | + self.0.contains("aarch64") |
| 58 | + } |
| 59 | + |
| 60 | + //--------------------------- |
| 61 | + // common combinations |
| 62 | + |
| 63 | + /// Returns true if this target triple contains the string "linux-musl" |
| 64 | + pub fn is_linux_musl(&self) -> bool { |
| 65 | + self.0.contains("linux-musl") |
| 66 | + } |
| 67 | + |
| 68 | + /// Returns true if this target triple contains the string "windows-msvc" |
| 69 | + pub fn is_windows_msvc(&self) -> bool { |
| 70 | + self.0.contains("windows-msvc") |
| 71 | + } |
| 72 | +} |
| 73 | + |
17 | 74 | /// A local system path on the machine cargo-dist was run.
|
18 | 75 | ///
|
19 | 76 | /// This is a String because when deserializing this may be a path format from a different OS!
|
@@ -176,7 +233,7 @@ pub struct AssetInfo {
|
176 | 233 | /// * length 0: not a meaningful question, maybe some static file
|
177 | 234 | /// * length 1: typical of binaries
|
178 | 235 | /// * length 2+: some kind of universal binary
|
179 |
| - pub target_triples: Vec<String>, |
| 236 | + pub target_triples: Vec<TargetTriple>, |
180 | 237 | /// the linkage of this Asset
|
181 | 238 | pub linkage: Option<Linkage>,
|
182 | 239 | }
|
@@ -346,7 +403,7 @@ pub struct Artifact {
|
346 | 403 | /// The target triple of the bundle
|
347 | 404 | #[serde(skip_serializing_if = "Vec::is_empty")]
|
348 | 405 | #[serde(default)]
|
349 |
| - pub target_triples: Vec<String>, |
| 406 | + pub target_triples: Vec<TargetTriple>, |
350 | 407 | /// The location of the artifact on the local system
|
351 | 408 | #[serde(skip_serializing_if = "Option::is_none")]
|
352 | 409 | #[serde(default)]
|
|
0 commit comments