Concat in path and link attributes


#1

Hi!

I have a set of platform-dependent libs, which all are located in a separate folder. All of them are named after <target_arch>-<target_env>. And there should be a set of Rust files for each of libs - these companion files will contain some platform-specific constants. I tried to use something like

#[link(name = concat!(cfg!(target_arch), "-", cfg!(target_env)), kind = "static")]
extern {
}

But compiler complains about unexpected token concat!. For link, I can circumvent this by putting all the libs into separate subfolders. Is there some workaround for companion modules?

UPD: string literal constants don’t work here unfortunately. Seems that link(name) must be a string literal and nothing more, which is unfortunate.

UPD2: it seems that cfg!() cannot tell you the value of specific parameter. It can only check whether that parameter has value X. Or not. That’s really unfortunate.

Thanks