Skip to content

Commit df937b1

Browse files
authored
Add option to send additional build args to ca65 (#133)
1 parent d28bd74 commit df937b1

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

build.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const mappers = { // https://www.nesdev.org/wiki/Mapper
1919
const args = process.argv.slice(2);
2020

2121
if (args.includes('-h')) {
22-
console.log(`usage: node build.js [-h] [-v] [-m<${Object.keys(mappers).join('|')}>] [-a] [-s] [-k] [-w]
22+
console.log(`usage: node build.js [-h] [-v] [-m<${Object.keys(mappers).join('|')}>] [-a] [-s] [-k] [-w] [-- (ca65 args)]
2323
2424
-m mapper
2525
-a faster aeppoz + press select to end game
@@ -88,6 +88,13 @@ if (args.includes('-o')) {
8888
console.log('cnrom override for autodetect');
8989
}
9090

91+
// pass additional arguments to ca65
92+
if (args.includes('--')) {
93+
const ca65Flags = args.slice(1+args.indexOf('--'));
94+
compileFlags.push(...ca65Flags);
95+
args.splice(args.indexOf('--'), 1+ca65Flags.length);
96+
}
97+
9198
console.log();
9299

93100
// build / compress nametables
@@ -128,12 +135,15 @@ console.timeEnd('CHR');
128135
const { spawnSync } = require('child_process');
129136

130137
function execArgs(exe, args) {
131-
const output = spawnSync(exe, args).output.flatMap(
132-
(d) => d?.toString() || [],
133-
);
134-
if (output.length) {
135-
console.log(output.join('\n'));
136-
process.exit(0);
138+
const result = spawnSync(exe, args);
139+
if (result.stderr.length) {
140+
console.error(result.stderr.toString());
141+
}
142+
if (result.stdout.length) {
143+
console.log(result.stdout.toString());
144+
}
145+
if (result.status) {
146+
process.exit(result.status);
137147
}
138148
}
139149

0 commit comments

Comments
 (0)