@@ -237,8 +237,7 @@ export function doCompileAsync(source: {
237
237
content ?: string ,
238
238
} , settings : CompilingSettings , callback ?: ( error : Error | null , result : {
239
239
path : string ,
240
- output : string ,
241
- md5 : string ,
240
+ output : string
242
241
} | null ) => void ) : ChildProcess {
243
242
const sourcePath = source . path ;
244
243
const srcDir = dirname ( sourcePath ) ;
@@ -258,7 +257,6 @@ export function doCompileAsync(source: {
258
257
callback ( null , {
259
258
path : sourcePath ,
260
259
output : stdout ,
261
- md5 : md5 ( sourceContent ) ,
262
260
} ) ;
263
261
} ) ;
264
262
@@ -292,7 +290,7 @@ export function compileAsync(source: {
292
290
293
291
try {
294
292
295
- const result = handleCompilerOutput ( source . path , settings , data . output , data . md5 ) ;
293
+ const result = handleCompilerOutput ( source . path , settings , data . output ) ;
296
294
resolve ( result ) ;
297
295
} catch ( error ) {
298
296
reject ( error ) ;
@@ -360,14 +358,18 @@ export function compile(
360
358
settings = Object . assign ( { } , defaultCompilingSettings , settings ) ;
361
359
const cmd = settings2cmd ( sourcePath , settings ) ;
362
360
const output = execSync ( cmd , { input : sourceContent , cwd : curWorkingDir , timeout : settings . timeout , maxBuffer : maxBuffer } ) . toString ( ) ;
363
- return handleCompilerOutput ( sourcePath , settings , output , md5 ( sourceContent ) ) ;
361
+ return handleCompilerOutput ( sourcePath , settings , output ) ;
362
+ }
363
+
364
+ function calcHexMd5 ( hex : string ) {
365
+ const chex = hex . replace ( / < ( [ ^ > ] + ) > / g, '<>' ) ;
366
+ return md5 ( chex ) ;
364
367
}
365
368
366
369
export function handleCompilerOutput (
367
370
sourcePath : string ,
368
371
settings : CompilingSettings ,
369
372
output : string ,
370
- md5 : string ,
371
373
) : CompileResult {
372
374
373
375
const srcDir = dirname ( sourcePath ) ;
@@ -380,7 +382,6 @@ export function handleCompilerOutput(
380
382
output = output . split ( / \r ? \n / g) . join ( '\n' ) ;
381
383
const result : CompileResult = new CompileResult ( [ ] , [ ] ) ;
382
384
result . compilerVersion = compilerVersion ( settings . cmdPrefix ? settings . cmdPrefix : findCompiler ( ) ) ;
383
- result . md5 = md5 ;
384
385
result . buildType = settings . buildType || BuildType . Debug ;
385
386
if ( output . startsWith ( 'Error:' ) || output . startsWith ( 'Warning:' ) ) {
386
387
Object . assign ( result , getErrorsAndWarnings ( output , srcDir , sourceFileName ) ) ;
@@ -422,6 +423,7 @@ export function handleCompilerOutput(
422
423
renameSync ( outputFilePath , hexFile ) ;
423
424
outputFiles [ 'hex' ] = hexFile ;
424
425
result . hex = readFileSync ( hexFile , 'utf8' ) ;
426
+ result . md5 = calcHexMd5 ( result . hex ) ;
425
427
}
426
428
427
429
if ( settings . sourceMap ) {
0 commit comments