use serde::Serialize;
pub const NAME: &str = "Silicera";
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const PHASE: &str = "II";
pub const RELEASE_LINE: &str = "Single-Zen Research Release";
pub const TAGLINE: &str =
"experimental hardware-native execution research for AMD Zen";
pub const BRAND_LINE: &str =
"Silicera — experimental hardware-native execution research for AMD Zen";
pub const LICENSE: &str = "MIT OR Apache-2.0";
pub const HOMEPAGE: &str = env!("CARGO_PKG_HOMEPAGE");
pub const REPOSITORY: &str = env!("CARGO_PKG_REPOSITORY");
pub const THANKS_DEV: &str = "https://thanks.dev/u/gh/theworker02";
pub const FUNDING_URL: &str = THANKS_DEV;
pub const GITHUB_SPONSOR: &str = "theworker02";
pub const LOGO_RELATIVE: &str = "../../assets/logo.svg";
pub const AFFILIATION_DISCLAIMER: &str =
"Not affiliated with, endorsed by, or certified by Advanced Micro Devices, Inc.";
#[derive(Debug, Clone, Serialize)]
pub struct BrandInfo {
pub name: &'static str,
pub version: &'static str,
pub phase: &'static str,
pub release_line: &'static str,
pub tagline: &'static str,
pub brand_line: &'static str,
pub license: &'static str,
pub homepage: &'static str,
pub repository: &'static str,
pub funding_url: &'static str,
pub affiliation: &'static str,
pub logo_relative: &'static str,
}
impl BrandInfo {
pub fn current() -> Self {
Self {
name: NAME,
version: VERSION,
phase: PHASE,
release_line: RELEASE_LINE,
tagline: TAGLINE,
brand_line: BRAND_LINE,
license: LICENSE,
homepage: HOMEPAGE,
repository: REPOSITORY,
funding_url: FUNDING_URL,
affiliation: AFFILIATION_DISCLAIMER,
logo_relative: LOGO_RELATIVE,
}
}
pub fn to_json_pretty(&self) -> crate::Result<String> {
Ok(serde_json::to_string_pretty(self)?)
}
}
pub fn brand_json() -> crate::Result<String> {
BrandInfo::current().to_json_pretty()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn brand_json_roundtrip_fields() {
let j = brand_json().unwrap();
assert!(j.contains("Silicera"));
assert!(j.contains("II"));
assert!(j.contains("Single-Zen Research Release"));
assert!(j.contains("thanks.dev/u/gh/theworker02"));
assert!(j.contains("MIT OR Apache-2.0"));
assert!(j.contains("../../assets/logo.svg"));
}
#[test]
fn funding_aliases_match() {
assert_eq!(THANKS_DEV, FUNDING_URL);
assert!(THANKS_DEV.ends_with("/u/gh/theworker02"));
assert_eq!(GITHUB_SPONSOR, "theworker02");
assert_eq!(PHASE, "II");
assert_eq!(LOGO_RELATIVE, "../../assets/logo.svg");
}
}