Closed berkus closed 5 years ago
Seems like the cargo documentation is not specific enough or out of date. A target triple in rust can be either a triple string or a path to a JSON file: https://github.com/rust-lang/rust/blob/653da4fd006c97625247acd7e076d0782cdc149b/src/librustc_target/spec/mod.rs#L1275-L1278
Hmm, ok, still very inconvenient because my build.rs only need to look at the TRIPLE regardless of actual json file path.
Can this be added? Maybe even to cargo? (As TARGET_TRIPLE for example)
Basically this means I just need result of calling triple()
on the triple, so I can probably construct it from the envvar and then call the triple()
function, let me try that.
Probably it makes more sense to match on (CARGO_CFG_TARGET_ARCH, CARGO_CFG_TARGET_OS, CARGO_CFG_TARGET_FAMILY)
triple instead.
You could use https://doc.rust-lang.org/std/path/struct.Path.html#method.file_stem to get the triple from a path.
I used direct match on the env vars and it worked excellently!
Cool!
When using a full path to json file as cargo-xbuild
--target
argument, the resulting TARGET is not a triple but instead a full file path. I believe it should be a triple.According to cargo book:
What I'm getting:
The line
Target /path/to/vesper/targets/aarch64-vesper-metta.json
is output by build.rs from the TARGET env var.