Skip to content

Commit

Permalink
Moved "no-shared" so that also windows statically link to the librari…
Browse files Browse the repository at this point in the history
…es (#83)

* Moved "no-shared" so that windows statically link to the libraries

* try reapplying changes

* removed shared as it's always false.

Co-authored-by: molleafauss <[email protected]>
  • Loading branch information
molleafauss and molleafauss authored Jan 7, 2021
1 parent a85d18b commit 19f8b13
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub struct Artifacts {
bin_dir: PathBuf,
libs: Vec<String>,
target: String,
shared: bool,
}

impl Build {
Expand Down Expand Up @@ -98,6 +97,7 @@ impl Build {
configure
// No shared objects, we just want static libraries
.arg("no-dso")
.arg("no-shared")
// Should be off by default on OpenSSL 1.1.0, but let's be extra sure
.arg("no-ssl3")
// No need to build tests, we won't run them anyway
Expand Down Expand Up @@ -146,23 +146,11 @@ impl Build {
configure.arg("no-stdio");
}

let shared = if target.contains("msvc") {
if target.contains("msvc") {
// On MSVC we need nasm.exe to compile the assembly files, but let's
// just pessimistically assume for now that's not available.
configure.arg("no-asm");

let features = env::var("CARGO_CFG_TARGET_FEATURE").unwrap_or(String::new());
if features.contains("crt-static") {
configure.arg("no-shared");
false
} else {
true
}
} else {
// Never shared on non-MSVC
configure.arg("no-shared");
false
};
}

let os = match target {
"aarch64-apple-darwin" => "darwin64-arm64-cc",
Expand Down Expand Up @@ -417,7 +405,6 @@ impl Build {
include_dir: install_dir.join("include"),
libs: libs,
target: target.to_string(),
shared,
}
}

Expand Down Expand Up @@ -521,20 +508,12 @@ impl Artifacts {
pub fn print_cargo_metadata(&self) {
println!("cargo:rustc-link-search=native={}", self.lib_dir.display());
for lib in self.libs.iter() {
if self.shared {
println!("cargo:rustc-link-lib={}", lib);
} else {
println!("cargo:rustc-link-lib=static={}", lib);
}
println!("cargo:rustc-link-lib=static={}", lib);
}
println!("cargo:include={}", self.include_dir.display());
println!("cargo:lib={}", self.lib_dir.display());
if self.target.contains("msvc") {
if self.shared {
println!("cargo:rustc-link-search=native={}", self.bin_dir.display());
} else {
println!("cargo:rustc-link-lib=user32");
}
println!("cargo:rustc-link-lib=user32");
}
}
}

0 comments on commit 19f8b13

Please sign in to comment.