@@ -19,7 +19,7 @@ const mappers = { // https://www.nesdev.org/wiki/Mapper
1919const args = process . argv . slice ( 2 ) ;
2020
2121if ( 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+
9198console . log ( ) ;
9299
93100// build / compress nametables
@@ -128,12 +135,15 @@ console.timeEnd('CHR');
128135const { spawnSync } = require ( 'child_process' ) ;
129136
130137function 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