@@ -15,6 +15,12 @@ const config = {
15
15
] ,
16
16
"type" : "b"
17
17
} ,
18
+ "createBinary" : {
19
+ "description" : [
20
+ "Also creates the respective .wasm binaries."
21
+ ] ,
22
+ "type" : "b"
23
+ } ,
18
24
"help" : {
19
25
"description" : "Prints this message and exits." ,
20
26
"type" : "b" ,
@@ -81,14 +87,17 @@ tests.forEach(filename => {
81
87
// TODO: also save stdout/stderr and diff it (-> expected failures)
82
88
83
89
// Build unoptimized
84
- asc . main ( [
90
+ var cmd = [
85
91
filename ,
86
92
"--baseDir" , basedir ,
87
93
"--validate" ,
88
94
"--measure" ,
89
95
"--debug" ,
90
96
"--textFile" // -> stdout
91
- ] , {
97
+ ] ;
98
+ if ( args . createBinary )
99
+ cmd . push ( "--binaryFile" , basename + ".untouched.wasm" ) ;
100
+ asc . main ( cmd , {
92
101
stdout : stdout ,
93
102
stderr : stderr
94
103
} , err => {
@@ -141,9 +150,8 @@ tests.forEach(filename => {
141
150
"--binaryFile" , // -> stdout
142
151
"-O3"
143
152
] ;
144
- if ( args . create ) cmd . push (
145
- "--textFile" , basename + ".optimized.wat"
146
- ) ;
153
+ if ( args . create )
154
+ cmd . push ( "--textFile" , basename + ".optimized.wat" ) ;
147
155
asc . main ( cmd , {
148
156
stdout : stdout ,
149
157
stderr : stderr
@@ -176,8 +184,11 @@ tests.forEach(filename => {
176
184
return parts . join ( "" ) + String . fromCharCode . apply ( String , U16 . subarray ( dataOffset , dataOffset + dataRemain ) ) ;
177
185
}
178
186
187
+ var binaryBuffer = stdout . toBuffer ( ) ;
188
+ if ( args . createBinary )
189
+ fs . writeFileSync ( path . join ( basedir , basename + ".optimized.wasm" ) , binaryBuffer ) ;
179
190
let runTime = asc . measure ( ( ) => {
180
- exports = new WebAssembly . Instance ( new WebAssembly . Module ( stdout . toBuffer ( ) ) , {
191
+ exports = new WebAssembly . Instance ( new WebAssembly . Module ( binaryBuffer ) , {
181
192
env : {
182
193
memory,
183
194
abort : function ( msg , file , line , column ) {
0 commit comments