Skip to content

Commit d335dd9

Browse files
authored
fix error: 'Not found required sub component'
1 parent 92665b9 commit d335dd9

3 files changed

Lines changed: 43 additions & 18 deletions

File tree

src/DependenceManager.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export class DependenceManager implements ManagerInterface {
6565
}
6666

6767
InstallComponent(packName: string, component: Component) {
68+
GlobalEvent.emit('globalLog.append', `[Info] Install CMSIS Component: ${component.groupName}\n`);
6869
this._installComponent(packName, component, [component.groupName]);
70+
GlobalEvent.emit('globalLog.append', `[Info] Done.\n`);
6971
}
7072

7173
private _installComponent(packName: string, component: Component, pendingList: string[]) {
@@ -77,25 +79,30 @@ export class DependenceManager implements ManagerInterface {
7779

7880
/* 安装此组件的依赖项 */
7981
if (component.condition) {
80-
const r = packageManager.CheckConditionRequire(component.condition, toolchain);
81-
if (r == false)
82-
throw new Error(`This condition '${component.condition}' is not met for component: '${component.groupName}'`);
83-
if (Array.isArray(r)) {
84-
for (const comp of r) {
85-
const compName = comp.replace('Device.', '');
86-
if (!comp.startsWith('Device.'))
82+
const result = packageManager.CheckConditionRequire(component.condition, toolchain);
83+
if (result == false)
84+
throw new Error(`Condition '${component.condition}' is not fit for this component: '${component.groupName}'`);
85+
if (Array.isArray(result)) {
86+
for (const fullname of result) {
87+
if (!fullname.startsWith('Device.'))
8788
continue; /* 排除非 Device 类型的组件 */
88-
if (this.isInstalled(packName, compName))
89+
const requiredName = fullname.replace('Device.', '');
90+
if (this.isInstalled(packName, requiredName))
8991
continue; /* 排除已安装的 */
90-
if (pendingList.includes(compName))
92+
if (pendingList.includes(requiredName))
9193
continue; /* 排除队列中已存在的 */
92-
const t = packageManager.FindComponent(compName);
93-
if (t) {
94-
pendingList.push(compName);
95-
this._installComponent(packName, t, pendingList);
96-
pendingList.pop();
94+
const compList = packageManager.FindAllComponents(requiredName);
95+
if (compList) {
96+
for (const item of compList) {
97+
pendingList.push(item.groupName);
98+
GlobalEvent.emit('globalLog.append', `[Info] ${' '.repeat(pendingList.length)}-> install dependence component: ${item.groupName}\n`);
99+
this._installComponent(packName, item, pendingList);
100+
pendingList.pop();
101+
}
97102
} else {
98-
throw new Error(`Not found required sub component: '${comp}'`);
103+
//throw new Error(`Not found required sub component: '${comp}'`);
104+
GlobalEvent.emit('globalLog.append',
105+
`[Warn] ${' '.repeat(pendingList.length)}Not found required sub component: '${comp}'\n`);
99106
}
100107
}
101108
}

src/EIDEProjectModules.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,18 @@ export interface ComponentFileItem {
6262
path: string;
6363
}
6464

65+
// XML define example:
66+
// ---
67+
// <component Cgroup="Drivers" Csub="Touch Screen" condition="STM32F746G-Discovery BSP TS">
68+
// <description>Touch Screen for STMicroelectronics STM32F746G-Discovery Kit</description>
69+
// <files>
70+
// <file category="header" name="Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_ts.h"/>
71+
// <file category="source" name="Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_ts.c"/>
72+
// <file category="source" name="Drivers/BSP/Components/ft5336/ft5336.c"/>
73+
// </files>
74+
// </component>
6575
export interface Component {
66-
groupName: string;
76+
groupName: string; // value is: ${Cgroup} + '.' + ${Csub}, and remove whitespace
6777
description?: string;
6878
enable: boolean;
6979
RTE_define?: string;

src/PackageManager.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,10 +1145,18 @@ export class PackageManager {
11451145
return undefined;
11461146
}
11471147

1148-
findComponents(groupName: string): Component[] | undefined {
1148+
FindAllComponents(matchName: string): Component[] | undefined {
11491149
if (this.packList.length > 0) {
11501150
return this.packList[0].components.filter((comp) => {
1151-
return comp.enable && comp.groupName === groupName;
1151+
if (!comp.enable)
1152+
return false
1153+
// case 1: matchName == 'A' and comp.groupName == 'A'
1154+
if (comp.groupName === matchName)
1155+
return true
1156+
// case 2: matchName == 'A' and comp.groupName == 'A.B.C'
1157+
if (comp.groupName.startsWith(matchName + '.'))
1158+
return true;
1159+
return false
11521160
});
11531161
}
11541162
return undefined;

0 commit comments

Comments
 (0)