2020-05-26 09:18:50 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2020-07-16 02:12:41 +02:00
|
|
|
use std::env;
|
2020-05-26 09:18:50 +02:00
|
|
|
|
2021-04-18 10:29:20 +02:00
|
|
|
use lazy_static::lazy_static;
|
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
fn buildinfo(key: &str) -> &'static str {
|
2020-12-21 06:59:16 +01:00
|
|
|
let buildinfo = include_str!(env!("BUILDINFO"));
|
2020-11-05 02:21:27 +01:00
|
|
|
for line in buildinfo.split('\n') {
|
2020-11-01 05:26:58 +01:00
|
|
|
let mut it = line.split(' ');
|
|
|
|
if it.next().unwrap() == key {
|
|
|
|
return it.next().unwrap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unreachable!("{} not found", key);
|
|
|
|
}
|
|
|
|
|
2020-05-26 09:18:50 +02:00
|
|
|
pub fn version() -> &'static str {
|
2020-11-01 05:26:58 +01:00
|
|
|
buildinfo("STABLE_VERSION")
|
2020-05-26 09:18:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn buildhash() -> &'static str {
|
2020-11-01 05:26:58 +01:00
|
|
|
buildinfo("STABLE_BUILDHASH")
|
2020-05-26 09:18:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn sync_client_version() -> &'static str {
|
|
|
|
lazy_static! {
|
|
|
|
static ref VER: String = format!(
|
2020-07-16 02:12:41 +02:00
|
|
|
"anki,{version} ({buildhash}),{platform}",
|
|
|
|
version = version(),
|
|
|
|
buildhash = buildhash(),
|
|
|
|
platform = env::var("PLATFORM").unwrap_or_else(|_| env::consts::OS.to_string())
|
2020-05-26 09:18:50 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
&VER
|
|
|
|
}
|