rust3ds / cargo-3ds

Cargo command to work with Nintendo 3DS project binaries.
Apache License 2.0
59 stars 10 forks source link

Add verbose flag to print cargo commands #42

Closed ian-h-chamberlain closed 1 year ago

ian-h-chamberlain commented 1 year ago

I often find myself wanting to reproduce the same command that cargo-3ds was running, so I thought it would be handy to print these commands out when a flag is passed in.

The output looks like this, with the intention that it can be copy-pasted back into the shell easily to run the same command:

$ cargo 3ds -v test
No pre-build std found, using build-std
Running command:
   RUSTDOCFLAGS=" --no-run --persist-doctests target/doctests" \
   RUSTFLAGS=" -L/opt/devkitpro/libctru/lib -lctru" \
   /Users/ianchamberlain/.rustup/toolchains/nightly-x86_64-apple-darwin/bin/cargo test --target armv6k-nintendo-3ds --message-format json-render-diagnostics -Z build-std --no-run

    Finished test [unoptimized + debuginfo] target(s) in 0.26s
Getting metadata
Building smdh:/Users/ianchamberlain/Documents/Development/3ds/test-runner-3ds/target/armv6k-nintendo-3ds/debug/deps/integration-86fc0175e918598b.smdh
Running command:
   smdhtool --create integration "Homebrew Application" "Unspecified Author" /opt/devkitpro/libctru/default_icon.png /Users/ianchamberlain/Documents/Development/3ds/test-runner-3ds/target/armv6k-nintendo-3ds/debug/deps/integration-86fc0175e918598b.smdh

Building 3dsx: /Users/ianchamberlain/Documents/Development/3ds/test-runner-3ds/target/armv6k-nintendo-3ds/debug/deps/integration-86fc0175e918598b.3dsx
Running command:
   3dsxtool /Users/ianchamberlain/Documents/Development/3ds/test-runner-3ds/target/armv6k-nintendo-3ds/debug/deps/integration-86fc0175e918598b.elf /Users/ianchamberlain/Documents/Development/3ds/test-runner-3ds/target/armv6k-nintendo-3ds/debug/deps/integration-86fc0175e918598b.3dsx "--smdh=/Users/ianchamberlain/Documents/Development/3ds/test-runner-3ds/target/armv6k-nintendo-3ds/debug/deps/integration-86fc0175e918598b.smdh"

Running 3dslink
Running command:
   3dslink /Users/ianchamberlain/Documents/Development/3ds/test-runner-3ds/target/armv6k-nintendo-3ds/debug/deps/integration-86fc0175e918598b.3dsx

No response from 3DS!

Also fix minor issue with building test crate for doctests.

Meziu commented 1 year ago

This is a very welcome addition, especially since cargo-3ds presents a film of obscurity between the user and the commands actually run (maybe we should do something about documenting how cargo-3ds interacts with the environment).

Just a thing: even though I think that it'd be almost impossible to move away from 3dslink (especially for how it interacts with the Homebrew Menu), I would still like to work on #2. What do you think about moving away from console commands and actually re-implement some features?

ian-h-chamberlain commented 1 year ago

Just a thing: even though I think that it'd be almost impossible to move away from 3dslink (especially for how it interacts with the Homebrew Menu), I would still like to work on #2. What do you think about moving away from console commands and actually re-implement some features?

Sure, I don't think it's a bad idea, if you want to. I personally wouldn't consider it a priority, since users will always have to have the toolchain installed anyway, so we should always be able to rely on the existence of those tools. Having more stuff in Rust (and library-usable) is always nice though!

One thing we could do is find the tools' full path using $DEVKITARM/tools/bin/$tool, instead of just relying on $PATH to be set correctly. That would be a much easier change and probably more reliable, in case people don't add that directory to their PATH.

ian-h-chamberlain commented 1 year ago

Going to go ahead and merge this, it fixes some issues with building doctests and doesn't seem too controversial.