Skip to content

Commit

Permalink
refactor: improve version extraction in build information
Browse files Browse the repository at this point in the history
Enhance version parsing for system libraries by extracting only the version number from command outputs. Specifically:
- Modify OpenSSL version extraction to capture just the version number
- Refine glibc version parsing to remove the "ldd (GNU libc)" prefix
  • Loading branch information
pedro-pelicioni-cw committed Feb 14, 2025
1 parent b73a245 commit 8114835
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ fn generate_build_info() {
.output()
.ok()
.and_then(|output| String::from_utf8(output.stdout).ok())
.map(|s| {
// take just the version number
s.split_whitespace().nth(1).unwrap_or("unknown").to_string()
})
.unwrap_or_else(|| "unknown".to_string());

// Capture glibc version (Linux only)
Expand All @@ -61,7 +65,8 @@ fn generate_build_info() {
.output()
.ok()
.and_then(|output| String::from_utf8(output.stdout).ok())
.and_then(|s| s.lines().next().map(|s| s.to_string()))
.and_then(|s| s.lines().next().map(|s| s.to_string())) // take just the first line
.map(|s| s.replace("ldd (GNU libc) ", "")) // take just the version number
.unwrap_or_else(|| "unknown".to_string())
} else {
"not applicable".to_string()
Expand Down

0 comments on commit 8114835

Please sign in to comment.