aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-08-18 17:03:29 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-08-18 17:03:29 +0200
commitfb0f163ba1f870158410a3851740101ecdc9d3ff (patch)
tree541b9bbb995d31430172bec43f9fff1655e84e92 /crates
parent2c837b9c1ee0761a0b6d2d4b65f43ff6a54f4a23 (diff)
downloadtools.nes-fb0f163ba1f870158410a3851740101ecdc9d3ff.tar.gz
tools.nes-fb0f163ba1f870158410a3851740101ecdc9d3ff.zip
xa65: Introduce the -s/--strict option
This further iterates on the previous -e/--error flag and it asks 'xa65' to error out in any case: when 'nasm' errors out, but also when the diff is not empty. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/xa65/src/main.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/crates/xa65/src/main.rs b/crates/xa65/src/main.rs
index 379dec9..6ac51c6 100644
--- a/crates/xa65/src/main.rs
+++ b/crates/xa65/src/main.rs
@@ -14,7 +14,7 @@ struct Args {
config: Option<String>,
target: Option<String>,
out: String,
- error: bool,
+ strict: bool,
}
// Print the help message and quit.
@@ -24,7 +24,7 @@ fn print_help() {
println!("Options:");
println!(" -b, --bin <PROGRAM>\tAlternative to the binary for 'nasm'.");
println!(" -C, --config <FILE>\tLinker configuration to be used, whether an identifier or a file path.");
- println!(" -e, --error\tDon't dismiss errors from 'nasm' and use the same exit code.");
+ println!(" -s, --strict\tError out if the output differ or 'nasm' has produced an error.");
println!(" -o, --out <FILE>\tFile path where the output should be located after execution.");
println!(" --target nes\t\tUsed for compatibility with 'ca65'.");
std::process::exit(0);
@@ -57,7 +57,6 @@ fn parse_arguments() -> Args {
}
},
},
- "-e" | "--error" => res.error = true,
"-h" | "--help" => print_help(),
"-o" | "--out" => {
if res.out.is_empty() {
@@ -71,6 +70,7 @@ fn parse_arguments() -> Args {
die("only specify the '-o/--out' flag once".to_string());
}
}
+ "-s" | "--strict" => res.strict = true,
"--target" => match res.target {
Some(_) => die("only specify the '--target' flag once".to_string()),
None => match args.next() {
@@ -209,6 +209,8 @@ fn attempt_hexdump(dir: &Path) {
}
fn main() {
+ let mut exit_code = 0;
+
// Parse arguments.
let args = parse_arguments();
@@ -242,7 +244,7 @@ fn main() {
.status()
{
Ok(cmd) => {
- if !cmd.success() && args.error {
+ if !cmd.success() && args.strict {
std::process::exit(cmd.code().unwrap_or(1));
}
}
@@ -296,6 +298,12 @@ fn main() {
"xa65 (error): 'nasm' and 'ca65' have a mismatch. Check the results at {}",
dir.display()
);
+
+ // If 'strict' was enabled, an error should be produced in the
+ // end.
+ if args.strict {
+ exit_code = 1;
+ }
}
}
Err(e) => {
@@ -310,4 +318,6 @@ fn main() {
if let Err(e) = std::fs::copy(dir.join("cl65.nes"), args.out) {
die(format!("could not copy the resulting binary: {e}"));
}
+
+ std::process::exit(exit_code);
}