Cargo pass target to shell script

So I have seen cargo-cc and cargo-make

Both are nice and helpful in their own way

But I am looking for an environment variable that tells me the arch of the current target

From that env I can determine which compiler to use ie arm cortex or x86 Linux host or riscv

I cannot seem to find a list of env vars exports by cargo for this purpose that contains for example the target triple or host triple

Can somebody point me to this?

I've not had to use that, but is this not what you are aiming for?

Environment Variables - The Cargo Book.

  • HOST — the host triple of the Rust compiler.

You can build the crate with a special target with (replace the x86_64-pc-windows-gnu for your target)

cargo build --target x86_64-pc-windows-gnu --release

I think this is not close to "environment variable", but you can write a .sh script to claim the env variable

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.