From a0537d7a2986dc0dc6a09c175841a1f928c3f63a Mon Sep 17 00:00:00 2001 From: Allen Li Date: Wed, 27 Nov 2024 22:18:51 -0800 Subject: [PATCH] feat: Support for `exelinkflags` --- src/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 89d803f..9491200 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -504,6 +504,11 @@ impl CargoInstructions { writeln!(self.out, "cargo:rerun-if-env-changed={val}").unwrap(); } + /// Adds `cargo:rustc-link-args-bins={val}` instruction. + fn rustc_link_arg_bins(&mut self, val: &str) { + writeln!(self.out, "cargo:rustc-link-arg-bins={val}").unwrap(); + } + /// Adds `cargo:rustc-link-lib={lib}` instruction. fn rustc_link_lib(&mut self, lib: &str) { writeln!(self.out, "cargo:rustc-link-lib={lib}").unwrap(); @@ -608,7 +613,16 @@ impl ConanDependencyGraph { } }; - // 5. Recursively visit dependency component requirements. + // 5. Emit "cargo:rustc-link-arg-bins=FLAGS" metadata for `rustc`. + if let Some(Value::Array(flags)) = component.get("exelinkflags") { + for flag in flags { + if let Value::String(flag) = flag { + cargo.rustc_link_arg_bins(flag); + } + } + } + + // 6. Recursively visit dependency component requirements. if let Some(Value::Array(requires)) = component.get("requires") { for requirement in requires { if let Value::String(req_comp_name) = requirement {