diff --git a/gcc-test/build.rs b/gcc-test/build.rs index 276da26..4ce6628 100644 --- a/gcc-test/build.rs +++ b/gcc-test/build.rs @@ -70,7 +70,9 @@ fn main() { println!("cargo:rustc-link-search={}", out.display()); } - // This tests whether we can build a library but not link it to the main crate. - // The test module will do its own linking. - gcc::Config::new().cargo_metadata(false).file("src/opt_linkage.c").compile("libOptLinkage.a"); + // This tests whether we can build a library but not link it to the main + // crate. The test module will do its own linking. + gcc::Config::new().cargo_metadata(false) + .file("src/opt_linkage.c") + .compile("libOptLinkage.a"); } diff --git a/gcc-test/src/opt_linkage.c b/gcc-test/src/opt_linkage.c index 95eb443..a74af8c 100644 --- a/gcc-test/src/opt_linkage.c +++ b/gcc-test/src/opt_linkage.c @@ -1,5 +1,5 @@ -#include +#include int32_t answer() { - return 42; + return 42; } diff --git a/gcc-test/tests/all.rs b/gcc-test/tests/all.rs index 2537960..0f02668 100644 --- a/gcc-test/tests/all.rs +++ b/gcc-test/tests/all.rs @@ -2,12 +2,9 @@ extern crate gcc_test; use gcc_test::*; - -// This will cause a link failure if the archive is already -// linked against the gcc_test crate. #[link(name = "OptLinkage", kind = "static")] extern { - fn answer() -> i32; + fn answer() -> i32; } #[test] @@ -57,5 +54,7 @@ fn msvc_here() { #[test] fn opt_linkage() { - unsafe { assert_eq!(answer(),42); } + unsafe { + assert_eq!(answer(), 42); + } } diff --git a/src/lib.rs b/src/lib.rs index e093a15..8f892f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -323,16 +323,15 @@ impl Config { self.assemble(lib_name, &dst.join(output), &objects); if self.cargo_metadata { - println!("cargo:rustc-link-lib=static={}", - &output[3..output.len() - 2]); - println!("cargo:rustc-link-search=native={}", dst.display()); - - // Add specific C++ libraries, if enabled. - if self.cpp { - if let Some(stdlib) = self.get_cpp_link_stdlib() { - println!("cargo:rustc-link-lib={}", stdlib); - } - + println!("cargo:rustc-link-lib=static={}", + &output[3..output.len() - 2]); + println!("cargo:rustc-link-search=native={}", dst.display()); + + // Add specific C++ libraries, if enabled. + if self.cpp { + if let Some(stdlib) = self.get_cpp_link_stdlib() { + println!("cargo:rustc-link-lib={}", stdlib); + } } } }