From 18ea688438888a2ca1d068cb6c9151960852601b Mon Sep 17 00:00:00 2001 From: zohassadar Date: Sun, 26 Jan 2025 16:43:26 +0000 Subject: [PATCH 1/6] Add option to send additional build args to ca65 --- build.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.js b/build.js index f170a9d1..49e6fd52 100644 --- a/build.js +++ b/build.js @@ -30,6 +30,7 @@ if (args.includes('-h')) { -o override autodetect mmc1 header with cnrom -t run tests (requires cargo) -T run single test +-D ca65 build arg -h you are here `); process.exit(0); @@ -88,6 +89,12 @@ if (args.includes('-o')) { console.log('cnrom override for autodetect'); } +args.forEach((arg, i) => { + if (arg === '-D') { + compileFlags.push(...args.slice(i, i+2)); + } + }) + console.log(); // build / compress nametables From 69fe1400d0a48a22ff800447458fca542760bbab Mon Sep 17 00:00:00 2001 From: zohassadar Date: Sun, 26 Jan 2025 17:40:35 +0000 Subject: [PATCH 2/6] pass status, stdout and stderr from spawned process --- build.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/build.js b/build.js index 49e6fd52..3ccecb2c 100644 --- a/build.js +++ b/build.js @@ -135,12 +135,15 @@ console.timeEnd('CHR'); const { spawnSync } = require('child_process'); function execArgs(exe, args) { - const output = spawnSync(exe, args).output.flatMap( - (d) => d?.toString() || [], - ); - if (output.length) { - console.log(output.join('\n')); - process.exit(0); + const result = spawnSync(exe, args); + if (result.stderr.length) { + console.error(result.stderr.toString()); + } + if (result.stdout.length) { + console.log(result.stdout.toString()); + } + if (result.status !== 0){ + process.exit(1); } } From d5b5b13919be4c37fb14a4478f970b8dd63f6b0e Mon Sep 17 00:00:00 2001 From: zohassadar Date: Sun, 26 Jan 2025 17:44:06 +0000 Subject: [PATCH 3/6] use -- to pass arguments directly to ca65 --- build.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.js b/build.js index 3ccecb2c..e1dcd057 100644 --- a/build.js +++ b/build.js @@ -30,7 +30,6 @@ if (args.includes('-h')) { -o override autodetect mmc1 header with cnrom -t run tests (requires cargo) -T run single test --D ca65 build arg -h you are here `); process.exit(0); @@ -89,11 +88,12 @@ if (args.includes('-o')) { console.log('cnrom override for autodetect'); } -args.forEach((arg, i) => { - if (arg === '-D') { - compileFlags.push(...args.slice(i, i+2)); - } - }) +// pass additional arguments to ca65 +if (args.includes('--')){ + const addlFlags = args.slice(1+args.indexOf('--')); + compileFlags.push(...addlFlags); + args.splice(args.indexOf('--'), 1+compileFlags.length); + } console.log(); From 6d16c80b7ea4dbbb6472e56f6240c76fcc82cceb Mon Sep 17 00:00:00 2001 From: zohassadar Date: Sun, 26 Jan 2025 17:46:50 +0000 Subject: [PATCH 4/6] exit on error with same status code --- build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.js b/build.js index e1dcd057..ebfb14e1 100644 --- a/build.js +++ b/build.js @@ -143,7 +143,7 @@ function execArgs(exe, args) { console.log(result.stdout.toString()); } if (result.status !== 0){ - process.exit(1); + process.exit(result.status); } } From ebd2c54b53b68ce5a3efa34a78363657cd43937b Mon Sep 17 00:00:00 2001 From: zohassadar Date: Sun, 26 Jan 2025 18:07:00 +0000 Subject: [PATCH 5/6] fix: reference correct array --- build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.js b/build.js index ebfb14e1..61664209 100644 --- a/build.js +++ b/build.js @@ -92,7 +92,7 @@ if (args.includes('-o')) { if (args.includes('--')){ const addlFlags = args.slice(1+args.indexOf('--')); compileFlags.push(...addlFlags); - args.splice(args.indexOf('--'), 1+compileFlags.length); + args.splice(args.indexOf('--'), 1+addlFlags.length); } console.log(); @@ -142,7 +142,7 @@ function execArgs(exe, args) { if (result.stdout.length) { console.log(result.stdout.toString()); } - if (result.status !== 0){ + if (result.status){ process.exit(result.status); } } From b3aaf77689647aac68379cc41a600f5ba99c4dd5 Mon Sep 17 00:00:00 2001 From: kirjavascript Date: Sat, 1 Feb 2025 19:48:54 +0000 Subject: [PATCH 6/6] tidy up --- build.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build.js b/build.js index 61664209..aaa24637 100644 --- a/build.js +++ b/build.js @@ -19,7 +19,7 @@ const mappers = { // https://www.nesdev.org/wiki/Mapper const args = process.argv.slice(2); if (args.includes('-h')) { - console.log(`usage: node build.js [-h] [-v] [-m<${Object.keys(mappers).join('|')}>] [-a] [-s] [-k] [-w] + console.log(`usage: node build.js [-h] [-v] [-m<${Object.keys(mappers).join('|')}>] [-a] [-s] [-k] [-w] [-- (ca65 args)] -m mapper -a faster aeppoz + press select to end game @@ -89,11 +89,11 @@ if (args.includes('-o')) { } // pass additional arguments to ca65 -if (args.includes('--')){ - const addlFlags = args.slice(1+args.indexOf('--')); - compileFlags.push(...addlFlags); - args.splice(args.indexOf('--'), 1+addlFlags.length); - } +if (args.includes('--')) { + const ca65Flags = args.slice(1+args.indexOf('--')); + compileFlags.push(...ca65Flags); + args.splice(args.indexOf('--'), 1+ca65Flags.length); +} console.log(); @@ -142,7 +142,7 @@ function execArgs(exe, args) { if (result.stdout.length) { console.log(result.stdout.toString()); } - if (result.status){ + if (result.status) { process.exit(result.status); } }