Browse Source

Allow other Cargo commands (like check and clippy)

This makes it easier to switch between check/clippy and build.
Otherwise, unless you use the same exact RUSTFLAGS and parameters,
Cargo will rebuild everything (throwing away the build cache).
pull/8/head
AzureMarker 3 years ago
parent
commit
6e78e5c27e
No known key found for this signature in database
GPG Key ID: 47A133F3BF9D03D3
  1. 23
      src/main.rs

23
src/main.rs

@ -69,17 +69,22 @@ fn main() {
let args: Vec<String> = args.collect(); let args: Vec<String> = args.collect();
let args: Vec<&str> = args.iter().map(String::as_str).collect(); let args: Vec<&str> = args.iter().map(String::as_str).collect();
let must_link = match command.as_deref() { let (command, must_link) = match command.as_deref() {
Some("build") => false, Some("link") => ("link", true),
Some("link") => true, Some(command) => (command, false),
_ => { None => {
print_usage(&mut io::stderr()); print_usage(&mut io::stderr());
process::exit(2) process::exit(2)
} }
}; };
eprintln!("Building ELF"); eprintln!("Running Cargo");
build_elf(&args); build_elf(command, &args);
if !["build", "link"].contains(&command) {
// We only do more work if it's a build or build + 3dslink operation
return;
}
eprintln!("Getting metadata"); eprintln!("Getting metadata");
let app_conf = get_metadata(&args, &optimization_level); let app_conf = get_metadata(&args, &optimization_level);
@ -116,11 +121,13 @@ fn print_usage(f: &mut impl std::io::Write) {
Usage: Usage:
{invocation} build [--release] [CARGO_OPTS...] {invocation} build [--release] [CARGO_OPTS...]
{invocation} link [--release] [CARGO_OPTS...] {invocation} link [--release] [CARGO_OPTS...]
{invocation} <cargo-command> [CARGO_OPTS...]
{invocation} -h | --help {invocation} -h | --help
Commands: Commands:
build build a 3dsx executable. build build a 3dsx executable.
link build a 3dsx executable and send it to a device with 3dslink. link build a 3dsx executable and send it to a device with 3dslink.
<cargo-command> execute some other Cargo command with 3ds options configured (ex. check or clippy).
Options: Options:
-h --help Show this screen. -h --help Show this screen.
@ -168,12 +175,12 @@ fn check_rust_version() {
} }
} }
fn build_elf(args: &[&str]) { fn build_elf(command: &str, args: &[&str]) {
let rustflags = env::var("RUSTFLAGS").unwrap_or_default() let rustflags = env::var("RUSTFLAGS").unwrap_or_default()
+ &format!(" -L{}/libctru/lib -lctru", env::var("DEVKITPRO").unwrap()); + &format!(" -L{}/libctru/lib -lctru", env::var("DEVKITPRO").unwrap());
let mut process = Command::new("cargo") let mut process = Command::new("cargo")
.arg("build") .arg(command)
.arg("-Z") .arg("-Z")
.arg("build-std") .arg("build-std")
.arg("--target") .arg("--target")

Loading…
Cancel
Save