@@ -29,6 +29,7 @@ import * as events from 'events';
2929import * as globmatch from 'micromatch'
3030import * as os from 'os' ;
3131import * as child_process from 'child_process' ;
32+ import * as mathjs from 'mathjs' ;
3233
3334import { AbstractProject , VirtualSource } from "./EIDEProject" ;
3435import { ResManager } from "./ResManager" ;
@@ -425,14 +426,46 @@ export abstract class CodeBuilder {
425426 if ( builderOptions . ram == undefined &&
426427 builderOptions . env &&
427428 builderOptions . env [ 'MCU_RAM_SIZE' ] ) {
428- builderOptions . ram = parseInt ( builderOptions . env [ 'MCU_RAM_SIZE' ] ) || undefined ;
429+
430+ const expr = ( < string > builderOptions . env [ 'MCU_RAM_SIZE' ] ) ;
431+ const expr_args = {
432+ B : 1 ,
433+ K : 1024 ,
434+ M : 1024 * 1024 ,
435+ G : 1024 * 1024 * 1024
436+ } ;
437+
438+ try {
439+ builderOptions . ram = mathjs . evaluate ( expr , expr_args ) as number || undefined ;
440+ } catch ( error ) {
441+ // nothing todo
442+ }
443+
444+ if ( builderOptions . ram && builderOptions . ram <= 0 )
445+ builderOptions . ram = undefined ;
429446 }
430447
431448 // set rom size from env
432449 if ( builderOptions . rom == undefined &&
433450 builderOptions . env &&
434451 builderOptions . env [ 'MCU_ROM_SIZE' ] ) {
435- builderOptions . rom = parseInt ( builderOptions . env [ 'MCU_ROM_SIZE' ] ) || undefined ;
452+
453+ const expr = ( < string > builderOptions . env [ 'MCU_ROM_SIZE' ] ) ;
454+ const expr_args = {
455+ B : 1 ,
456+ K : 1024 ,
457+ M : 1024 * 1024 ,
458+ G : 1024 * 1024 * 1024
459+ } ;
460+
461+ try {
462+ builderOptions . rom = mathjs . evaluate ( expr , expr_args ) as number || undefined ;
463+ } catch ( error ) {
464+ // nothing todo
465+ }
466+
467+ if ( builderOptions . rom && builderOptions . rom <= 0 )
468+ builderOptions . rom = undefined ;
436469 }
437470
438471 // handle options by toolchain
0 commit comments