diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-09-02 17:16:05 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-09-02 17:16:05 +0200 |
| commit | 488fafc44203cbce2d641966c2f122025dcd043b (patch) | |
| tree | 3519c4fd9608204dd425f4716e83488149e18992 | |
| parent | 54a585e751e77c2406005b04ababbd93f23eba7e (diff) | |
| download | tools.nes-488fafc44203cbce2d641966c2f122025dcd043b.tar.gz tools.nes-488fafc44203cbce2d641966c2f122025dcd043b.zip | |
Split the --stats and the --strict flags
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
| -rw-r--r-- | crates/nasm/src/main.rs | 13 | ||||
| -rw-r--r-- | crates/xa65/src/main.rs | 35 | ||||
| -rwxr-xr-x | scripts/test-e2e.sh | 36 |
3 files changed, 48 insertions, 36 deletions
diff --git a/crates/nasm/src/main.rs b/crates/nasm/src/main.rs index cc516b6..2aab743 100644 --- a/crates/nasm/src/main.rs +++ b/crates/nasm/src/main.rs @@ -32,7 +32,7 @@ fn print_help() { println!(" -D <NAME>(=VALUE)\tDefine an 8-bit variable on the global scope (default: 1)"); println!(" -h, --help\t\tPrint this message."); println!(" -o, --out <FILE>\tFile path where the output should be located after execution."); - println!(" -s, --stats\t\tPrint the statistics on how segments have been filled."); + println!(" -s, --stats\t\tPrint the statistics on the final layout of segments and memory."); println!(" --stdout\t\tPrint the output binary to the standard output."); println!(" -v, --version\t\tPrint the version of this program."); println!( @@ -383,15 +383,10 @@ fn main() { if args.info { save_memory_stats(&source, &mut memory, has_working_ram); } - - if !args.stats { - println!("== Statistics ==\n"); - } else { - println!(); + if args.stats { + println!("\n=> Amount of memory used (in bytes):\n"); + print_memory_summary(Box::new(io::stdout()), &memory, has_working_ram); } - println!("=> Amount of memory used (in bytes):\n"); - - print_memory_summary(Box::new(io::stdout()), &memory, has_working_ram); } } diff --git a/crates/xa65/src/main.rs b/crates/xa65/src/main.rs index 4fe034b..96c5582 100644 --- a/crates/xa65/src/main.rs +++ b/crates/xa65/src/main.rs @@ -14,7 +14,9 @@ struct Args { config: Option<String>, target: Option<String>, out: String, + no_errors: bool, strict: bool, + stats: bool, } // Print the help message and quit. @@ -25,7 +27,11 @@ fn print_help() { 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!(" -h, --help\t\tPrint this message."); - println!(" -s, --strict\t\tError out if the output differ or 'nasm' has produced an error."); + println!( + " -n, --no-errors\t\tError out if the output differ or 'nasm' has produced an error." + ); + println!(" -s, --strict\t\tBe more strict on 'nasm' by adding the address-sanitizer and writing debug/analysis information."); + println!(" --stats\t\tPrint statistics to the standard output."); println!(" -o, --out <FILE>\tFile path where the output should be located after execution."); println!(" --target nes\t\tUsed for compatibility with 'ca65'."); println!(" -v, --version\t\tPrint the version of this program."); @@ -72,6 +78,8 @@ fn parse_arguments() -> Args { die("only specify the '-o/--out' flag once".to_string()); } } + "-n" | "--no-errors" => res.no_errors = true, + "--stats" => res.stats = true, "-s" | "--strict" => res.strict = true, "--target" => match res.target { Some(_) => die("only specify the '--target' flag once".to_string()), @@ -237,16 +245,25 @@ fn main() { // 'nasm' if the '-e/--error' flag was provided, otherwise we just go on as // if nothing had happened (i.e. the user just wants a binary, even if it // comes from cl65). - match Command::new(nasm) - .arg(&args.file) + let mut cmd = Command::new(nasm); + cmd.arg(&args.file) .arg("-o") .arg(dir.join("nasm.nes")) .arg("-c") - .arg(args.config.clone().unwrap_or("nrom65".to_string())) - .status() - { + .arg(args.config.clone().unwrap_or("nrom65".to_string())); + + // Add stricter flags for 'nasm' if requested. + if args.strict { + cmd.arg("--asan").arg("--write-info"); + } + if args.stats { + cmd.arg("--stats"); + } + + // Actually run the command. + match cmd.status() { Ok(cmd) => { - if !cmd.success() && args.strict { + if !cmd.success() && args.no_errors { std::process::exit(cmd.code().unwrap_or(1)); } } @@ -301,9 +318,9 @@ fn main() { dir.display() ); - // If 'strict' was enabled, an error should be produced in the + // If 'no_errors' was enabled, an error should be produced in the // end. - if args.strict { + if args.no_errors { exit_code = 1; } } diff --git a/scripts/test-e2e.sh b/scripts/test-e2e.sh index 3eb5754..844aee0 100755 --- a/scripts/test-e2e.sh +++ b/scripts/test-e2e.sh @@ -53,78 +53,78 @@ exit_code=$((exit_code + $?)) # code.nes echo "test: code.nes => basics/sprite.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/basics/sprite.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/basics/sprite.s exit_code=$((exit_code + $?)) echo "test: code.nes => basics/input.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/basics/input.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/basics/input.s exit_code=$((exit_code + $?)) echo "test: code.nes => basics/persist.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc1.cfg -o /dev/null tests/code.nes/basics/persist.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc1.cfg -o /dev/null tests/code.nes/basics/persist.s exit_code=$((exit_code + $?)) echo "test: code.nes => basics/flicker.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/basics/flicker.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/basics/flicker.s exit_code=$((exit_code + $?)) echo "test: code.nes => basics/unrom.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/unrom.cfg -o /dev/null tests/code.nes/basics/unrom.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/unrom.cfg -o /dev/null tests/code.nes/basics/unrom.s exit_code=$((exit_code + $?)) echo "test: code.nes => basics/chr-ram.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/unrom.cfg -o /dev/null tests/code.nes/basics/chr-ram.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/unrom.cfg -o /dev/null tests/code.nes/basics/chr-ram.s exit_code=$((exit_code + $?)) echo "test: code.nes => fx/blink.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc3.cfg -o /dev/null tests/code.nes/fx/blink.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc3.cfg -o /dev/null tests/code.nes/fx/blink.s exit_code=$((exit_code + $?)) echo "test: code.nes => scroll/toggle.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/scroll/toggle.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/scroll/toggle.s exit_code=$((exit_code + $?)) echo "test: code.nes => scroll/level.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/scroll/level.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/scroll/level.s exit_code=$((exit_code + $?)) echo "test: code.nes => scroll/sprite0.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/scroll/sprite0.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/scroll/sprite0.s exit_code=$((exit_code + $?)) echo "test: code.nes => scroll/mmc3.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc3.cfg -o /dev/null tests/code.nes/scroll/mmc3.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc3.cfg -o /dev/null tests/code.nes/scroll/mmc3.s exit_code=$((exit_code + $?)) echo "test: code.nes => rand/rand.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/rand/rand.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/rand/rand.s exit_code=$((exit_code + $?)) echo "test: code.nes => scroll/roulette.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc3.cfg -o /dev/null tests/code.nes/scroll/roulette.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc3.cfg -o /dev/null tests/code.nes/scroll/roulette.s exit_code=$((exit_code + $?)) echo "test: code.nes => space/space.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/space/src/space.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/space/src/space.s exit_code=$((exit_code + $?)) ## # aoc2023.nes echo "test: aoc2023.nes => 1.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/1.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/1.s exit_code=$((exit_code + $?)) echo "test: aoc2023.nes => 2.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/2.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/2.s exit_code=$((exit_code + $?)) echo "test: aoc2023.nes => 3.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/3.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/3.s exit_code=$((exit_code + $?)) echo "test: aoc2023.nes => 4.nes" -$AS65 --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/4.s +$AS65 --no-errors --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/4.s exit_code=$((exit_code + $?)) ## |
