2025-05-02 23:09:50 +02:00
|
|
|
use once_cell::sync::Lazy;
|
2025-05-03 14:26:13 +02:00
|
|
|
use std::sync::Mutex;
|
2025-05-02 23:09:50 +02:00
|
|
|
|
|
|
|
|
pub static META_DATA: Lazy<Mutex<Option<MetaData>>> = Lazy::new(|| Mutex::new(None));
|
|
|
|
|
|
2026-11-04 15:19:16 +01:00
|
|
|
/// The Rust compiler which built the runtime, e.g., "1.99.1 (commit 58cf8f9c3)".
|
|
|
|
|
///
|
|
|
|
|
/// The build script asks the compiler itself. Line 6 of metadata.txt names
|
|
|
|
|
/// only the one our pipeline is supposed to use, while other builds, such
|
|
|
|
|
/// as the Flatpak, bring their own compiler.
|
|
|
|
|
pub const RUST_VERSION: &str = env!("AI_STUDIO_RUST_VERSION");
|
|
|
|
|
|
2025-05-02 23:09:50 +02:00
|
|
|
#[derive(Clone)]
|
|
|
|
|
pub struct MetaData {
|
|
|
|
|
pub app_version: String,
|
|
|
|
|
pub build_time: String,
|
|
|
|
|
pub build_number: String,
|
|
|
|
|
pub dotnet_sdk_version: String,
|
|
|
|
|
pub dotnet_version: String,
|
|
|
|
|
pub rust_version: String,
|
|
|
|
|
pub mud_blazor_version: String,
|
|
|
|
|
pub tauri_version: String,
|
|
|
|
|
pub app_commit_hash: String,
|
|
|
|
|
pub architecture: String,
|
2025-05-03 14:26:13 +02:00
|
|
|
pub pdfium_version: String,
|
2026-06-02 17:22:59 +02:00
|
|
|
pub vector_store_version: String,
|
2025-05-03 14:26:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl MetaData {
|
|
|
|
|
/// Creates a new instance of `MetaData` from the given metadata string.
|
|
|
|
|
pub fn init_from_string(metadata: &str) -> Self {
|
|
|
|
|
|
|
|
|
|
// When the metadata is already initialized, return the existing instance:
|
|
|
|
|
if let Some(metadata) = META_DATA.lock().unwrap().as_ref() {
|
|
|
|
|
return metadata.clone();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let mut metadata_lines = metadata.lines();
|
|
|
|
|
let app_version = metadata_lines.next().unwrap();
|
|
|
|
|
let build_time = metadata_lines.next().unwrap();
|
|
|
|
|
let build_number = metadata_lines.next().unwrap();
|
|
|
|
|
let dotnet_sdk_version = metadata_lines.next().unwrap();
|
|
|
|
|
let dotnet_version = metadata_lines.next().unwrap();
|
2026-11-04 15:19:16 +01:00
|
|
|
|
|
|
|
|
// Skip the Rust compiler of the pipeline, see RUST_VERSION:
|
|
|
|
|
metadata_lines.next().unwrap();
|
2025-05-03 14:26:13 +02:00
|
|
|
let mud_blazor_version = metadata_lines.next().unwrap();
|
|
|
|
|
let tauri_version = metadata_lines.next().unwrap();
|
|
|
|
|
let app_commit_hash = metadata_lines.next().unwrap();
|
|
|
|
|
let pdfium_version = metadata_lines.next().unwrap();
|
2026-06-02 17:22:59 +02:00
|
|
|
let vector_store_version = metadata_lines.next().unwrap();
|
2025-05-03 14:26:13 +02:00
|
|
|
|
|
|
|
|
let metadata = MetaData {
|
2026-10-16 08:13:18 +02:00
|
|
|
// The build script names the platform the runtime is built for:
|
|
|
|
|
architecture: env!("AI_STUDIO_ARCHITECTURE").to_string(),
|
2025-05-03 14:26:13 +02:00
|
|
|
app_commit_hash: app_commit_hash.to_string(),
|
|
|
|
|
app_version: app_version.to_string(),
|
|
|
|
|
build_number: build_number.to_string(),
|
|
|
|
|
build_time: build_time.to_string(),
|
|
|
|
|
dotnet_sdk_version: dotnet_sdk_version.to_string(),
|
|
|
|
|
dotnet_version: dotnet_version.to_string(),
|
|
|
|
|
mud_blazor_version: mud_blazor_version.to_string(),
|
2026-11-04 15:19:16 +01:00
|
|
|
rust_version: RUST_VERSION.to_string(),
|
2025-05-03 14:26:13 +02:00
|
|
|
tauri_version: tauri_version.to_string(),
|
|
|
|
|
pdfium_version: pdfium_version.to_string(),
|
2026-06-02 17:22:59 +02:00
|
|
|
vector_store_version: vector_store_version.to_string(),
|
2025-05-03 14:26:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
*META_DATA.lock().unwrap() = Some(metadata.clone());
|
|
|
|
|
metadata
|
|
|
|
|
}
|
2025-05-02 23:09:50 +02:00
|
|
|
}
|