Skip to content

Commit 15a48d2

Browse files
authored
Haiku: rework build.rs logic for curl-sys (#375)
Due to several issues, the Haiku build of rustc and cargo is cross-compiled from a Linux host. In this official build, it is prefered to link to the libcurl build that is being distributed as an official Haiku port. This change adds the logic to link to the official libcurl build when cross-compiling. The previous logic was flawed, in the sense that it would rely on the hosts curl-config to determine whether http2 support was available. When doing a native build, pkg_config can be used to determine whether libcurl is available on the platform, thus removing the need for separate logic when building curl-sys on Haiku itself.
1 parent d48298d commit 15a48d2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

curl-sys/build.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::path::{Path, PathBuf};
99
use std::process::Command;
1010

1111
fn main() {
12+
let host = env::var("HOST").unwrap();
1213
let target = env::var("TARGET").unwrap();
1314
let windows = target.contains("windows");
1415

@@ -19,13 +20,18 @@ fn main() {
1920
return println!("cargo:rustc-flags=-l curl");
2021
}
2122

23+
// When cross-compiling for Haiku, use the system's default supplied
24+
// libcurl (it supports http2). This is in the case where rustc and
25+
// cargo are built for Haiku, which is done from a Linux host.
26+
if host != target && target.contains("haiku") {
27+
return println!("cargo:rustc-flags=-l curl");
28+
}
29+
2230
// If the static-curl feature is disabled, probe for a system-wide libcurl.
2331
if !cfg!(feature = "static-curl") {
24-
// OSX and Haiku ships libcurl by default, so we just use that version
32+
// OSX ships libcurl by default, so we just use that version
2533
// so long as it has the right features enabled.
26-
if (target.contains("apple") || target.contains("haiku"))
27-
&& (!cfg!(feature = "http2") || curl_config_reports_http2())
28-
{
34+
if target.contains("apple") && (!cfg!(feature = "http2") || curl_config_reports_http2()) {
2935
return println!("cargo:rustc-flags=-l curl");
3036
}
3137

0 commit comments

Comments
 (0)