From 60ba26aae341d1e106384d47696b77bef2fdbc0a Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Wed, 16 Dec 2020 22:48:45 +0100 Subject: [PATCH 1/5] Feature for external libs instead of default windows ones --- Cargo.toml | 1 + build.rs | 40 +++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 524487083..5ad9b152e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ winapi-i686-pc-windows-gnu = { version = "0.4", path = "i686" } winapi-x86_64-pc-windows-gnu = { version = "0.4", path = "x86_64" } [features] +external_lib = [] debug = ["impl-debug"] everything = [] impl-debug = [] diff --git a/build.rs b/build.rs index 622050495..2e3884726 100644 --- a/build.rs +++ b/build.rs @@ -469,25 +469,27 @@ impl Graph { } } fn emit_libraries(&self) { - let mut libs = self.0.iter().filter(|&(_, header)| { - header.included.get() - }).flat_map(|(_, header)| { - header.libraries.iter() - }).collect::>(); - libs.sort(); - libs.dedup(); - // FIXME Temporary hacks until build script is redesigned. - libs.retain(|&&lib| match &*var("TARGET").unwrap() { - "aarch64-pc-windows-msvc" | "aarch64-uwp-windows-msvc" | "thumbv7a-pc-windows-msvc" => { - if lib == "opengl32" { false } - else { true } - }, - _ => true, - }); - let prefix = library_prefix(); - let kind = library_kind(); - for lib in libs { - println!("cargo:rustc-link-lib={}={}{}", kind, prefix, lib); + if var("CARGO_FEATURE_EXTERNAL_LIB").is_err() { + let mut libs = self.0.iter().filter(|&(_, header)| { + header.included.get() + }).flat_map(|(_, header)| { + header.libraries.iter() + }).collect::>(); + libs.sort(); + libs.dedup(); + // FIXME Temporary hacks until build script is redesigned. + libs.retain(|&&lib| match &*var("TARGET").unwrap() { + "aarch64-pc-windows-msvc" | "aarch64-uwp-windows-msvc" | "thumbv7a-pc-windows-msvc" => { + if lib == "opengl32" { false } + else { true } + }, + _ => true, + }); + let prefix = library_prefix(); + let kind = library_kind(); + for lib in libs { + println!("cargo:rustc-link-lib={}={}{}", kind, prefix, lib); + } } } } From 0e3225989c3f68da783055b60dd660fd2e1424f2 Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Wed, 16 Dec 2020 22:54:54 +0100 Subject: [PATCH 2/5] Fix feature naming --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5ad9b152e..d123d9427 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ winapi-i686-pc-windows-gnu = { version = "0.4", path = "i686" } winapi-x86_64-pc-windows-gnu = { version = "0.4", path = "x86_64" } [features] -external_lib = [] +external-lib = [] debug = ["impl-debug"] everything = [] impl-debug = [] From 0f913dfd1a1c983451c327e8a2c8a1028404aa54 Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Thu, 17 Dec 2020 14:39:33 +0100 Subject: [PATCH 3/5] Disable lib linking for test --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 2e3884726..e074023af 100644 --- a/build.rs +++ b/build.rs @@ -515,7 +515,7 @@ fn try_everything() { graph.check_everything(); graph.resolve_dependencies(); graph.emit_features(); - graph.emit_libraries(); + //graph.emit_libraries(); } fn main() { println!("cargo:rerun-if-changed=build.rs"); From f2397c69a8eccd9836ee816c53fe52458a0cb552 Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Mon, 28 Dec 2020 22:22:34 +0100 Subject: [PATCH 4/5] re-enable emit library --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index e074023af..2e3884726 100644 --- a/build.rs +++ b/build.rs @@ -515,7 +515,7 @@ fn try_everything() { graph.check_everything(); graph.resolve_dependencies(); graph.emit_features(); - //graph.emit_libraries(); + graph.emit_libraries(); } fn main() { println!("cargo:rerun-if-changed=build.rs"); From ddc5022f9ed0647a433e93daacdec0e07b850f17 Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Mon, 28 Dec 2020 22:49:13 +0100 Subject: [PATCH 5/5] Add external-lib to ignore list --- Cargo.toml | 2 +- tests/code_checkers/check_features.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d123d9427..3b0387ba4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,9 +23,9 @@ winapi-i686-pc-windows-gnu = { version = "0.4", path = "i686" } winapi-x86_64-pc-windows-gnu = { version = "0.4", path = "x86_64" } [features] -external-lib = [] debug = ["impl-debug"] everything = [] +external-lib = [] impl-debug = [] impl-default = [] std = [] diff --git a/tests/code_checkers/check_features.rs b/tests/code_checkers/check_features.rs index 6831fc2d3..a8cf25d7e 100644 --- a/tests/code_checkers/check_features.rs +++ b/tests/code_checkers/check_features.rs @@ -111,7 +111,7 @@ fn check_missing_features_in_cargo_file(build_features: &[String], cargo_features: &[String], errors: &mut u32) { const FEATURES_TO_IGNORE: &'static [&'static str] = &[ - "debug", "everything", "impl-debug", "impl-default", "std", + "debug", "everything", "external-lib", "impl-debug", "impl-default", "std", ]; let mut it1 = 0; let mut it2 = 0;