aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-20 12:47:14 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-20 12:47:14 +0100
commitdaa0095507bf847675c529a78d96f7ac4b561eee (patch)
tree6fd9450d82c359f3ba80dd9f4a4d9ea2ed851b1e
parent0356d5871afe7669f17bdb9853cc878248bfe7b9 (diff)
downloadtools.nes-daa0095507bf847675c529a78d96f7ac4b561eee.tar.gz
tools.nes-daa0095507bf847675c529a78d96f7ac4b561eee.zip
Do not spit out bytes if -Werror was passed
Even if there are no errors, if warnings are to be treated as errors then the output should behave the same as if they were errors. That is, in case there are warnings and they are to be treated as errors, then do not spit out any assembled bundle. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
-rw-r--r--crates/nasm/src/main.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/crates/nasm/src/main.rs b/crates/nasm/src/main.rs
index 646e249..c5c72ae 100644
--- a/crates/nasm/src/main.rs
+++ b/crates/nasm/src/main.rs
@@ -94,9 +94,19 @@ fn main() -> Result<()> {
let mut assembler = Assembler::new(mapping);
match assembler.assemble(working_directory.to_path_buf(), input) {
Ok(bundles) => {
- for b in bundles {
- for i in 0..b.size {
- output.write_all(&[b.bytes[i as usize]])?;
+ for warning in assembler.warnings() {
+ if warn_as_errors {
+ println!("{}", warning);
+ error_count += 1;
+ } else {
+ println!("Warning: {}", warning);
+ }
+ }
+ if error_count == 0 {
+ for b in bundles {
+ for i in 0..b.size {
+ output.write_all(&[b.bytes[i as usize]])?;
+ }
}
}
}
@@ -107,12 +117,6 @@ fn main() -> Result<()> {
}
}
}
- for warning in assembler.warnings() {
- println!("Warning: {}", warning);
- if warn_as_errors {
- error_count += 1;
- }
- }
std::process::exit(error_count);
}