Skip to content

Commit ffa466f

Browse files
Rust wrapper: minor build.rs improvements for cross-compiling
1 parent fa25a38 commit ffa466f

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

wrapper/rust/wolfssl-wolfcrypt/build.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@ fn wolfssl_repo_lib_dir() -> Result<String> {
4444
fn wolfssl_include_dir() -> Result<Option<String>> {
4545
if let Ok(prefix) = env::var("WOLFSSL_PREFIX") {
4646
Ok(Some(format!("{}/include", prefix)))
47-
} else if Path::new(&wolfssl_repo_base_dir()?).exists() {
48-
Ok(Some(wolfssl_repo_base_dir()?))
4947
} else {
50-
Ok(None)
48+
let base = wolfssl_repo_base_dir()?;
49+
let base_path = Path::new(&base);
50+
// Treat this as an in-tree wolfSSL repo only if the expected layout exists.
51+
let wolfssl_dir = base_path.join("wolfssl");
52+
let wolfssl_options = wolfssl_dir.join("options.h");
53+
if wolfssl_options.is_file() {
54+
Ok(Some(base))
55+
} else {
56+
Ok(None)
57+
}
5158
}
5259
}
5360

@@ -97,6 +104,8 @@ fn rust_target_to_clang_target(rust_target: &str) -> String {
97104
// Bare-metal: (os=none, abi=elf) → <arch>-<vendor>-elf
98105
if os == "none" && abi == "elf" {
99106
format!("{}-{}-elf", arch, vendor)
107+
} else if abi.is_empty() {
108+
format!("{}-{}-{}", arch, vendor, os)
100109
} else {
101110
format!("{}-{}-{}-{}", arch, vendor, os, abi)
102111
}

0 commit comments

Comments
 (0)