Skip to content

Commit b957d89

Browse files
committed
optimize cppcheck generator
1 parent 3e91ccd commit b957d89

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

src/EIDEProjectExplorer.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5530,6 +5530,13 @@ export class ProjectExplorer implements CustomConfigurationProvider {
55305530
return;
55315531
}
55325532

5533+
const cppcheck_has_platform = (plat: string): boolean => {
5534+
return File.IsFile(`${exeFile.dir}/platforms/${plat}.xml`);
5535+
};
5536+
const cppcheck_has_cfg = (cfgname: string): boolean => {
5537+
return File.IsFile(`${exeFile.dir}/cfg/${cfgname}.cfg`);
5538+
};
5539+
55335540
const prj = this.getProjectByTreeItem(item);
55345541
if (!prj) {
55355542
GlobalEvent.emit('msg', newMessage('Warning', 'Not found project by this item !'));
@@ -5597,18 +5604,13 @@ export class ProjectExplorer implements CustomConfigurationProvider {
55975604
}
55985605

55995606
if (os.platform() == 'win32') {
5600-
switch (toolchain.name) {
5601-
case 'GCC':
5602-
cfgList.push('armgcc');
5603-
break;
5604-
case 'RISCV_GCC':
5605-
cfgList.push('riscv');
5606-
break;
5607-
default:
5608-
defList = defList.concat(
5609-
toolchain.getInternalDefines(<any>prjConfig.config.compileConfig, builderOpts));
5610-
break;
5611-
}
5607+
if (toolchain.name == 'GCC' && cppcheck_has_cfg('armgcc'))
5608+
cfgList.push('armgcc');
5609+
else if (toolchain.name == 'RISCV_GCC' && cppcheck_has_cfg('riscv'))
5610+
cfgList.push('riscv');
5611+
else
5612+
defList = defList.concat(
5613+
toolchain.getInternalDefines(<any>prjConfig.config.compileConfig, builderOpts));
56125614
} else {
56135615
defList = defList.concat(
56145616
toolchain.getInternalDefines(<any>prjConfig.config.compileConfig, builderOpts));
@@ -5625,9 +5627,12 @@ export class ProjectExplorer implements CustomConfigurationProvider {
56255627

56265628
const fixedDefList = defList.map((str) => str.replace(/"/g, '&quot;'));
56275629

5628-
let cppcheck_plat: string = 'arm32-wchar_t2';
5630+
let cppcheck_plat: string = 'unix32';
56295631
if (is8bit) {
5630-
cppcheck_plat = os.platform() == 'win32' ? 'mcs51' : 'avr8';
5632+
if (os.platform() == 'win32' && cppcheck_has_platform('mcs51'))
5633+
cppcheck_plat = 'mcs51';
5634+
else
5635+
cppcheck_plat = 'avr8';
56315636
}
56325637

56335638
cppcheckConf = cppcheckConf

0 commit comments

Comments
 (0)