Browse Source

Revert to original cargo usage

Re-add TeeReader comment
Remove debugging line
pull/21/head
Steve Cook 2 years ago
parent
commit
239556abf8
  1. 11
      src/commands/mod.rs
  2. 5
      src/lib.rs
  3. 14
      src/main.rs

11
src/commands/mod.rs

@ -1,7 +1,16 @@
use clap::{ValueEnum, Parser, AppSettings}; use clap::{AppSettings, Parser, ValueEnum};
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
#[derive(Parser)] #[derive(Parser)]
#[clap(name = "cargo")]
#[clap(bin_name = "cargo")]
pub enum Cargo {
#[clap(name = "3ds")]
Input(Input),
}
#[derive(clap::Args)]
#[clap(about)]
#[clap(global_setting(AppSettings::AllowLeadingHyphen))] #[clap(global_setting(AppSettings::AllowLeadingHyphen))]
pub struct Input { pub struct Input {
#[clap(value_enum)] #[clap(value_enum)]

5
src/lib.rs

@ -29,6 +29,9 @@ pub fn build_elf(
stdout_reader = BufReader::new(command_stdout); stdout_reader = BufReader::new(command_stdout);
&mut stdout_reader &mut stdout_reader
} else { } else {
// The user presumably cares about the message format, so we should
// copy stuff to stdout like they expect. We can still extract the executable
// information out of it that we need for 3dsxtool etc.
tee_reader = BufReader::new(TeeReader::new(command_stdout, io::stdout())); tee_reader = BufReader::new(TeeReader::new(command_stdout, io::stdout()));
&mut tee_reader &mut tee_reader
}; };
@ -59,8 +62,6 @@ fn make_cargo_build_command(
command.arg("-Z").arg("build-std"); command.arg("-Z").arg("build-std");
} }
println!("{:?}", args);
command command
.env("RUSTFLAGS", rust_flags) .env("RUSTFLAGS", rust_flags)
.arg(&cmd.to_string()) .arg(&cmd.to_string())

14
src/main.rs

@ -1,12 +1,12 @@
use cargo_3ds::commands::{CargoCommand, Input}; use cargo_3ds::commands::{Cargo, CargoCommand};
use cargo_3ds::{build_3dsx, build_elf, build_smdh, check_rust_version, get_metadata, link}; use cargo_3ds::{build_3dsx, build_elf, build_smdh, check_rust_version, get_metadata, link};
use clap::{Parser}; use clap::Parser;
use std::process; use std::process;
fn main() { fn main() {
check_rust_version(); check_rust_version();
let mut input: Input = Input::parse(); let Cargo::Input(mut input) = Cargo::parse();
let should_link = input.cmd == CargoCommand::Build let should_link = input.cmd == CargoCommand::Build
|| (input.cmd == CargoCommand::Test || (input.cmd == CargoCommand::Test
@ -17,16 +17,16 @@ fn main() {
true true
}); });
let message_format = if let Some(pos) = input.cargo_opts let message_format = if let Some(pos) = input
.cargo_opts
.iter() .iter()
.position(|s| s.starts_with("--message-format")) .position(|s| s.starts_with("--message-format"))
{ {
let arg = input.cargo_opts.remove(pos); let arg = input.cargo_opts.remove(pos);
let format = if let Some((_, format)) = arg.split_once('=') let format = if let Some((_, format)) = arg.split_once('=') {
{
format.to_string() format.to_string()
} else { } else {
input.cargo_opts.remove(pos).to_string() input.cargo_opts.remove(pos)
}; };
if !format.starts_with("json") { if !format.starts_with("json") {
eprintln!("error: non-JSON `message-format` is not supported"); eprintln!("error: non-JSON `message-format` is not supported");

Loading…
Cancel
Save