Skip to content

Commit b992b8a

Browse files
committed
chore: fixing build error 6 annotations
1 parent fc99c46 commit b992b8a

File tree

4 files changed

+49
-25
lines changed

4 files changed

+49
-25
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ jobs:
284284
throw "Expected embedded build id '$build' in binary"
285285
}
286286
} else {
287-
$out = & $bin -i
287+
$outLines = & $bin -i
288+
$out = $outLines -join "`n"
288289
$out
289290
if ($out -notmatch [regex]::Escape("build: $build")) {
290291
throw "Expected build id 'build: $build' in cosmostrix -i output"

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ rust-version = "1.81"
66
authors = ["rezk_nightky"]
77
description = "A cosmic take on the classic Matrix rain for the terminal"
88
license = "MIT"
9+
build = "build.rs"
910

1011
[dependencies]
1112
clap = { version = "4.5.23", features = ["derive"] }

build.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
fn main() {
2+
println!("cargo:rerun-if-env-changed=COSMOSTRIX_BUILD");
3+
println!("cargo:rerun-if-env-changed=RUSTFLAGS");
4+
println!("cargo:rerun-if-env-changed=CARGO_ENCODED_RUSTFLAGS");
5+
6+
let build_id = if let Ok(v) = std::env::var("COSMOSTRIX_BUILD") {
7+
if !v.is_empty() {
8+
v
9+
} else {
10+
infer_build_id()
11+
}
12+
} else {
13+
infer_build_id()
14+
};
15+
16+
println!("cargo:rustc-env=COSMOSTRIX_BUILD={}", build_id);
17+
}
18+
19+
fn infer_build_id() -> String {
20+
let os_raw = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_else(|_| "unknown".to_string());
21+
let os = match os_raw.as_str() {
22+
"macos" => "darwin",
23+
other => other,
24+
};
25+
26+
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| "unknown".to_string());
27+
let features = std::env::var("CARGO_CFG_TARGET_FEATURE").unwrap_or_default();
28+
29+
let variant = if arch == "x86_64" {
30+
if features.contains("avx512f") {
31+
"v4"
32+
} else if features.contains("avx2") {
33+
"v3"
34+
} else if features.contains("sse4.2") || features.contains("sse4_2") {
35+
"v2"
36+
} else {
37+
"v1"
38+
}
39+
} else {
40+
"native"
41+
};
42+
43+
format!("{os}-{arch}-{variant}")
44+
}

src/main.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,8 @@ const HELP_TEMPLATE_COLOR: &str = "\
5151
5252
{all-args}{after-help}";
5353

54-
fn build_info() -> String {
55-
if let Some(v) = option_env!("COSMOSTRIX_BUILD") {
56-
return v.to_string();
57-
}
58-
59-
let os = match std::env::consts::OS {
60-
"macos" => "darwin",
61-
other => other,
62-
};
63-
let arch = std::env::consts::ARCH;
64-
65-
let variant = if cfg!(all(target_arch = "x86_64", target_feature = "avx512f")) {
66-
"v4"
67-
} else if cfg!(all(target_arch = "x86_64", target_feature = "avx2")) {
68-
"v3"
69-
} else if cfg!(all(target_arch = "x86_64", target_feature = "sse4.2")) {
70-
"v2"
71-
} else if cfg!(target_arch = "x86_64") {
72-
"v1"
73-
} else {
74-
"native"
75-
};
76-
77-
format!("{os}-{arch}-{variant}")
54+
fn build_info() -> &'static str {
55+
env!("COSMOSTRIX_BUILD")
7856
}
7957

8058
fn clap_styles() -> ClapStyles {

0 commit comments

Comments
 (0)