Skip to content

Commit a134bea

Browse files
committed
sys: don't probe system for library if it's static
1 parent 51117ec commit a134bea

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/codegen/sys/build.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ fn generate_build_script(w: &mut dyn Write, env: &Env, split_build_rs: bool) ->
4242
writeln!(w, "mod build_version;")?;
4343
}
4444

45-
write!(
46-
w,
47-
"{}",
48-
r#"
45+
if !env.config.static_lib {
46+
write!(
47+
w,
48+
"{}",
49+
r#"
4950
fn main() {
5051
if std::env::var("DOCS_RS").is_ok() {
5152
// prevent linking libraries to avoid documentation failure
@@ -58,7 +59,18 @@ fn main() {
5859
}
5960
}
6061
"#
61-
)
62+
)
63+
} else {
64+
write!(
65+
w,
66+
"{}",
67+
r#"
68+
fn main() {
69+
70+
}
71+
"#
72+
)
73+
}
6274
}
6375

6476
fn generate_build_version(w: &mut dyn Write, env: &Env) -> Result<()> {

src/config/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ pub struct Config {
123123
/// to another doc source, for example when builds on docs.rs
124124
/// are limited due to license issues.
125125
pub external_docs_url: Option<String>,
126+
pub static_lib: bool,
126127
}
127128

128129
impl Config {
@@ -333,6 +334,11 @@ impl Config {
333334
let feature_dependencies = read_feature_dependencies(&toml)?;
334335
let external_docs_url = read_external_docs_url(&toml)?;
335336

337+
let static_lib = match toml.lookup("options.static_lib") {
338+
Some(v) => v.as_result_bool("options.static_lib")?,
339+
None => false,
340+
};
341+
336342
Ok(Self {
337343
work_mode,
338344
girs_dirs,
@@ -359,6 +365,7 @@ impl Config {
359365
lib_version_overrides,
360366
feature_dependencies,
361367
external_docs_url,
368+
static_lib,
362369
})
363370
}
364371

0 commit comments

Comments
 (0)