@@ -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 ' : ' ' ) + '-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 ' : ' ' ) + '-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 ) ;
@@ -113,7 +113,7 @@ if (process.argv[2] && process.argv[2].indexOf('.py') !== -1) {
113
113
}
114
114
}
115
115
try {
116
- fs . appendFileSync ( path . join ( process . cwd ( ) , file + '.js' ) , '\n' + deserialize_rpython_json . toString ( ) + '\nModule.wasmMemory = wasmMemory;\nvar rpyGlobalArg = {"Module": Module, "deserialize_rpython_json": deserialize_rpython_json, "get_dirname": function () {return __dirname;}};\nrpyGlobalArg.global = rpyGlobalArg;\n if (typeof window !== "undefined") rpyGlobalArg.window = window;\n if (typeof require !== "undefined") rpyGlobalArg.require = require;\n if (typeof self !== "undefined") rpyGlobalArg.self = self;\n if (typeof global !== "undefined") rpyGlobalArg.node = global;' ) ;
116
+ fs . appendFileSync ( path . join ( process . cwd ( ) , file + '.js' ) , '\n' + deserialize_rpython_json . toString ( ) + '\nModule.wasmMemory = wasmMemory;\nvar rpyGlobalArg = {"Module": Module, "deserialize_rpython_json": deserialize_rpython_json, "get_dirname": function () {return __dirname;}};\nrpyGlobalArg.global = rpyGlobalArg;\n if (typeof window !== "undefined") rpyGlobalArg.window = window;\n if (typeof require !== "undefined") rpyGlobalArg.require = require;\n if (typeof self !== "undefined") rpyGlobalArg.self = self;\n if (typeof global !== "undefined") rpyGlobalArg.node = global;\nif (!WebAssembly.Module.customSections) WebAssembly.Module.customSections = () => []; ' ) ;
117
117
if ( source_flag ) {
118
118
var source_map = JSON . parse ( require ( 'fs' ) . readFileSync ( path . join ( directory , file + '.wasm.map' ) ) ) ;
119
119
source_map . sources . forEach ( function ( filename , index ) {
@@ -125,8 +125,10 @@ if (process.argv[2] && process.argv[2].indexOf('.py') !== -1) {
125
125
}
126
126
if ( process . argv . indexOf ( '--keep-temp' ) !== - 1 ) process . exit ( ) ;
127
127
try {
128
- if ( fs . rmSync ) fs . rmSync ( tempdir , { recursive : true } ) ;
129
- else fs . rmdirSync ( tempdir , { recursive : true } ) ;
128
+ if ( ! process . env . KEEP_TMP ) {
129
+ if ( fs . rmSync ) fs . rmSync ( tempdir , { recursive : true } ) ;
130
+ else fs . rmdirSync ( tempdir , { recursive : true } ) ;
131
+ }
130
132
}
131
133
catch ( error ) {
132
134
child_process . execSync ( 'rm -rf ' + tempdir ) ;
0 commit comments