Skip to content

Commit 759734f

Browse files
committed
bug: try to fix windows linking again
1 parent ff3b60d commit 759734f

4 files changed

Lines changed: 28 additions & 66 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swls/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ glob = "0.3.3"
3939
default = ["tower-lsp/runtime-tokio"]
4040

4141
[build-dependencies]
42-
vergen = { version = "8.1", features = ["build", "git2", "git"] }
42+
vergen = { version = "8", default-features = false, features = ["build"] }

swls/build.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1+
use std::process::Command;
2+
13
fn main() {
2-
#[cfg(target_os = "windows")]
3-
{
4-
println!("cargo:rustc-link-lib=advapi32");
5-
println!("cargo:rustc-link-lib=userenv");
6-
println!("cargo:rustc-link-lib=crypt32");
4+
let output = Command::new("git")
5+
.args(["rev-parse", "HEAD"])
6+
.output()
7+
.ok();
8+
9+
if let Some(output) = output {
10+
if let Ok(hash) = String::from_utf8(output.stdout) {
11+
println!("cargo:rustc-env=GIT_HASH={}", hash.trim());
12+
}
713
}
14+
let branch = Command::new("git")
15+
.args(["branch", "--show-current"])
16+
.output()
17+
.ok()
18+
.and_then(|o| String::from_utf8(o.stdout).ok())
19+
.map(|s| s.trim().to_string())
20+
.filter(|s| !s.is_empty())
21+
.unwrap_or_else(|| {
22+
// fallback for detached HEAD
23+
std::env::var("GITHUB_REF_NAME").unwrap_or_else(|_| "unknown".into())
24+
});
25+
26+
println!("cargo:rustc-env=GIT_BRANCH={}", branch);
827

9-
vergen::EmitBuilder::builder()
10-
.git_sha(true)
11-
.git_describe(true, true, None) // includes tag if present
12-
.git_branch()
13-
.build_date()
14-
.emit()
15-
.unwrap();
28+
vergen::EmitBuilder::builder().build_date().emit().unwrap();
1629
}

swls/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use tracing::{debug, level_filters::LevelFilter};
1313

1414
fn version() -> String {
1515
let base = option_env!("APP_VERSION").unwrap_or(env!("CARGO_PKG_VERSION"));
16-
let git = option_env!("VERGEN_GIT_SHA").unwrap_or("unknown");
17-
let branch = option_env!("VERGEN_GIT_BRANCH").unwrap_or("unknown");
16+
let git = option_env!("GIT_HASH").unwrap_or("unknown");
17+
let branch = option_env!("GIT_BRANCH").unwrap_or("unknown");
1818
let date = option_env!("VERGEN_BUILD_DATE").unwrap_or("unknown");
1919

2020
format!("Semantic Web Language Server version={base} (git={git} branch={branch} date={date})")

0 commit comments

Comments
 (0)