This is similar to hello-static-rustup-target-windows
but this time, we
experiment with a non trivial project that has dependencies (in this case
the clap
cli parser lib).
Build and run:
$ cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `/nix/store/5nz0dnmfn70gjl15srmn8wyqqmhsynpw-wine-wow-6.0/bin/wine64 target/x86_64-pc-windows-gnu/debug/simple-static-rustup-target-windows.exe`
error: The following required arguments were not provided:
<INPUT>
USAGE:
simple-static-rustup-target-windows.exe [FLAGS] [OPTIONS] <INPUT> [SUBCOMMAND]
For more information try --help
Note how we weren't force to invoke rustup target add $TARGET_TRIPLE
as our
nix env shell hook did that for us.
Note how cargo run
has configured by our nix env to use wine to run our program.
Validate that we're still free of dynamic dependencies:
$ winedump -j export ./target/x86_64-pc-windows-gnu/debug/simple-static-rustup-target-windows.exe
Contents of ./target/x86_64-pc-windows-gnu/debug/simple-static-rustup-target-windows.exe: 14574056 bytes
Done dumping ./target/x86_64-pc-windows-gnu/debug/simple-static-rustup-target-windows.exe
-
rust - How can I set default build target for Cargo? - Stack Overflow
you can create a .cargo/config and specify the target
-
Add option to configure a test/binary runner · Issue #1411 · rust-lang/cargo
target.x86_64-pc-windows-gnu.run = "wine64"
-
Environment Variables - The Cargo Book
CARGO_TARGET__RUNNER — The executable runner, see target..runner.
Which means:
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine64
CARGO_BUILD_TARGET — The default target platform, see build.target.
- Avoiding having to mess with
.cargo/config.toml
.