@@ -84,7 +84,7 @@ process.env.RPYTHON_TARGET_FILE = process.argv[2];
84
84
process . env . PYPY_USESSION_DIR = platform === 'win32' ? cygpath ( tempdir ) : tempdir ;
85
85
process . env . USER = 'current' ;
86
86
child_process . execSync ( [ python , rpython , '--gc=none' , '--no-translation-jit' , '-s' ] . concat ( process . argv . slice ( 2 ) ) . join ( ' ' ) , { stdio : 'inherit' , env : process . env } ) ;
87
- if ( process . argv [ 2 ] && process . argv [ 2 ] . indexOf ( '.py' ) !== - 1 ) {
87
+ async function handle ( ) {
88
88
var file = process . argv [ 2 ] . split ( '.py' ) [ 0 ] ;
89
89
var directory = path . join ( tempdir , 'usession-unknown-0' , 'testing_1' ) ;
90
90
var makefile = path . join ( directory , 'Makefile' ) ;
@@ -95,7 +95,7 @@ if (process.argv[2] && process.argv[2].indexOf('.py') !== -1) {
95
95
if ( platform === 'win32' ) make = make . replace ( 'RPYDIR = ' , 'RPYDIR = "' + rpydir + '"#' )
96
96
make = make . replace ( / - l u t i l / g, '' ) ;
97
97
make = make . replace ( / - - e x p o r t - a l l - s y m b o l s / g, '--export-dynamic' ) ;
98
- make = make . replace ( 'CC = ' , 'CC = ' + emcc + ( ! use_wasm ? ' -s WASM=0 ' : ' ' ) + '-fsanitize=undefined -s ALLOW_MEMORY_GROWTH=1 -s \'EXPORTED_FUNCTIONS=["_main", "_malloc", "_onresolve", "_onfunctioncall"]\' -s \'EXPORTED_RUNTIME_METHODS=["ccall", "wasmMemory"]\'' + ( debug_flag ? ' -g3' : ( source_flag ? ' -g4' : '' ) ) + ' #' ) ;
98
+ make = make . replace ( 'CC = ' , 'CC = ' + emcc + ( ! use_wasm ? ' -s WASM=0 ' : ' ' ) + '-fdiagnostics-color=always - fsanitize=undefined -s ALLOW_MEMORY_GROWTH=1 -s \'EXPORTED_FUNCTIONS=["_main", "_malloc", "_onresolve", "_onfunctioncall"]\' -s \'EXPORTED_RUNTIME_METHODS=["ccall", "wasmMemory"]\'' + ( debug_flag ? ' -g3' : ( source_flag ? ' -g4' : '' ) ) + ' #' ) ;
99
99
make = make . replace ( 'TARGET = ' , 'TARGET = ' + file + '.js #' ) ;
100
100
make = make . replace ( 'DEFAULT_TARGET = ' , 'DEFAULT_TARGET = ' + file + '.js #' ) ;
101
101
fs . writeFileSync ( makefile , make ) ;
@@ -105,7 +105,12 @@ if (process.argv[2] && process.argv[2].indexOf('.py') !== -1) {
105
105
if ( platform === 'darwin' ) {
106
106
process . env . C_INCLUDE_PATH = path . join ( __dirname , '../dmidecode' ) ;
107
107
}
108
- child_process . execSync ( [ 'make' , '-j' , cores ] . join ( ' ' ) , { env : process . env , stdio : 'inherit' , cwd : directory } ) ;
108
+ var error = '' ;
109
+ var code = await new Promise ( ( resolve ) => child_process . spawn ( 'make' , [ '-j' , cores ] , { env : process . env , stdio : [ 'inherit' , 'inherit' , 'pipe' ] , cwd : directory } ) . on ( 'close' , resolve ) . stderr . on ( 'data' , ( data ) => process . stderr . write ( error += data . toString ( ) ) ) ) ;
110
+ if ( code !== 0 ) {
111
+ if ( error . includes ( 'wasm2js is not compatible with USE_OFFSET_CONVERTER' ) ) throw new Error ( '\x1b[31mYour emcc wasm2js support is not patched yet, add --wasm to rpython command or comment out "wasm2js is not compatible with USE_OFFSET_CONVERTER" in emcc.py\x1b[0m' ) . toString ( ) ;
112
+ process . exit ( ) ;
113
+ }
109
114
for ( var filename of fs . readdirSync ( directory ) ) {
110
115
if ( filename . startsWith ( file + '.' ) ) {
111
116
if ( use_wasm || filename !== ( file + '.js' ) ) fs . copyFileSync ( path . join ( directory , filename ) , path . join ( process . cwd ( ) , filename ) ) ;
@@ -138,3 +143,4 @@ if (process.argv[2] && process.argv[2].indexOf('.py') !== -1) {
138
143
console . warn ( error ) ;
139
144
}
140
145
}
146
+ if ( process . argv [ 2 ] && process . argv [ 2 ] . indexOf ( '.py' ) !== - 1 ) handle ( ) . catch ( console . error ) ;
0 commit comments