Build Scripts ignore target cfg
RinLovesYou opened this issue · comments
Sarah commented
Hi there! Want to just preface this by saying thank you for making this tool, it's been a great help!
It seems that build scripts will ignore target os, when building for windows, on linux
fn main() {
#[cfg(target_os = "windows")]
{
println!("cargo:warning=Linking Exports File..");
use std::path::Path;
let lib_path = Path::new("deps").join("Exports.def");
let absolute_path = std::fs::canonicalize(&lib_path).unwrap();
println!(
"cargo:rustc-cdylib-link-arg=/DEF:{}",
absolute_path.display()
);
}
}
building this with cargo xwin build --target x86_64-pc-windows-msvc
on linux, will result in no output, and no linking of the definition file. if i remove the target_os
attribute, linking succeeds. Obviously this is not good if we're not compiling for windows, as it would require a manual change to the build.rs each time.
messense commented
You are doing it wrong, see Byron/trash-rs#39 (comment)