Skip to content

Moved "no-shared" so that also windows statically link to the libraries #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}
}