Detect the target at the runtime.
It runs $CARGO -vV if environment variable CARGO is present
for cargo subcommands, otherwise it would try running rustc -vV.
If both rustc isn't present on the system, it will fallback
to using syscalls plus ldd on Linux to detect targets.
Example use cases:
- The binary is built with musl libc to run on anywhere, but the runtime supports glibc.
- The binary is built for x86_64-apple-darwin, but run on aarch64-apple-darwin.
This crate provides two API:
- [
detect_targets] provides the API to get the target at runtime, but the code is run on the current thread. - [
get_desired_targets] provides the API to either use override provided by the users, or run [detect_targets] in the background using [tokio::spawn].
Example
detect_targets:
use detect_targets;
#
# async
get_desired_targets with user override:
use get_desired_targets;
#
# async
get_desired_targets without user override:
use get_desired_targets;
#
# async