Skip to content

Commit 5b034a5

Browse files
committed
support install CMSIS Common Driver Interface
1 parent 8cc4dcb commit 5b034a5

File tree

5 files changed

+58
-18
lines changed

5 files changed

+58
-18
lines changed

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,11 @@
763763
"command": "_cl.eide.project.installCmsisLibs",
764764
"title": "Install CMSIS Core Libs"
765765
},
766+
{
767+
"command": "_cl.eide.project.installCmsisDriverInterface",
768+
"category": "eide",
769+
"title": "Install CMSIS Common Driver Interface"
770+
},
766771
{
767772
"command": "_cl.eide.project.addSrcDir",
768773
"title": "%eide.explorer.root.add.folder%",
@@ -1250,6 +1255,10 @@
12501255
"command": "_cl.eide.project.installCmsisLibs",
12511256
"when": "viewItem == PACK && view == cl.eide.view.projects"
12521257
},
1258+
{
1259+
"command": "_cl.eide.project.installCmsisDriverInterface",
1260+
"when": "viewItem == PACK && view == cl.eide.view.projects"
1261+
},
12531262
{
12541263
"command": "_cl.eide.project.setActive",
12551264
"when": "viewItem == SOLUTION && view == cl.eide.view.projects && cl.eide.enable.active"
45.1 KB
Binary file not shown.

src/EIDEProject.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,32 +1627,37 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
16271627
return dupList;
16281628
}
16291629

1630-
installCMSISHeaders() {
1630+
installCmsisSourceCodePack(pList: { name: string; zippath: string; exportIncs?: string[] } []) {
16311631

1632-
const packList = ResManager.GetInstance().getCMSISHeaderPacks();
1633-
if (packList.length === 0) {
1634-
GlobalEvent.emit('msg', newMessage('Info', 'Not found available libraries !'));
1632+
if (pList.length == 0) {
16351633
return;
16361634
}
16371635

16381636
const doneList: string[] = [];
16391637

1640-
for (const packZipFile of packList) {
1638+
for (const packInfo of pList) {
16411639

1642-
const outDir = File.fromArray([this.GetRootDir().path, '.cmsis', packZipFile.noSuffixName]);
1640+
const outDir = File.fromArray([this.GetRootDir().path, '.cmsis', packInfo.name]);
16431641
const rePath = this.ToRelativePath(outDir.path) || outDir.path;
16441642

16451643
if (outDir.IsDir()) {
1646-
GlobalEvent.emit('msg', newMessage('Warning', `'${rePath}' directory is already exists !, Aborted !`));
1647-
return;
1644+
GlobalEvent.emit('globalLog', newMessage('Warning', `'${rePath}' directory is already exists !, Aborted !`));
1645+
continue;
16481646
}
16491647

16501648
outDir.CreateDir(true);
16511649
const compresser = new SevenZipper(ResManager.GetInstance().Get7zDir());
1652-
compresser.UnzipSync(packZipFile, outDir);
1650+
compresser.UnzipSync(new File(packInfo.zippath), outDir);
16531651

16541652
// add to include folder
1655-
this.addIncludePaths([outDir.path]);
1653+
if (packInfo.exportIncs) {
1654+
const incLi = packInfo.exportIncs.map(p => {
1655+
let path = p.trim();
1656+
if (path == '.') path = '';
1657+
return path ? (outDir.path + File.sep + path) : outDir.path;
1658+
});
1659+
this.addIncludePaths(incLi);
1660+
}
16561661

16571662
doneList.push(rePath);
16581663
}

src/EIDEProjectExplorer.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5668,10 +5668,10 @@ export class ProjectExplorer implements CustomConfigurationProvider {
56685668
}
56695669

56705670
private install_lock: boolean = false;
5671-
async installCmsisSourcePack(item: ProjTreeItem, type: 'header' | 'lib') {
5671+
async installCmsisSourcePack(item: ProjTreeItem, type: 'header' | 'lib' | 'idrv') {
56725672

56735673
if (this.install_lock) {
5674-
GlobalEvent.emit('msg', newMessage('Warning', 'Operation is busy !'));
5674+
GlobalEvent.emit('msg', newMessage('Warning', 'Operation is in pending !'));
56755675
return;
56765676
}
56775677

@@ -5681,10 +5681,34 @@ export class ProjectExplorer implements CustomConfigurationProvider {
56815681

56825682
const prj = this.dataProvider.GetProjectByIndex(item.val.projectIndex);
56835683
if (prj) {
5684-
if (type == 'header') {
5685-
prj.installCMSISHeaders();
5686-
} else if (type == 'lib') {
5687-
prj.installCmsisLibs();
5684+
switch (type) {
5685+
case 'header':
5686+
prj.installCmsisSourceCodePack(
5687+
ResManager.GetInstance().getCMSISHeaderPacks().map(f => {
5688+
return {
5689+
name: f.noSuffixName,
5690+
zippath: f.path,
5691+
exportIncs: ['.']
5692+
}
5693+
}));
5694+
break;
5695+
case 'lib':
5696+
prj.installCmsisLibs();
5697+
break;
5698+
case 'idrv':
5699+
prj.installCmsisSourceCodePack([
5700+
{
5701+
name: 'driver',
5702+
zippath: [ResManager.instance().GetAppDataDir().path, 'cmsis_driver_interface_v5_9_0.7z'].join(File.sep),
5703+
exportIncs: [
5704+
'Include',
5705+
'VIO/Include'
5706+
]
5707+
}
5708+
]);
5709+
break;
5710+
default:
5711+
break;
56885712
}
56895713
}
56905714

src/extension.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,14 @@ export async function activate(context: vscode.ExtensionContext) {
209209
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.modify.path', (item) => projectExplorer.openYamlConfig(item, 'src-path-cfg')));
210210

211211
// package
212-
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.installCMSISHeaders', (item) => projectExplorer.installCmsisSourcePack(item, 'header')));
213-
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.installCmsisLibs', (item) => projectExplorer.installCmsisSourcePack(item, 'lib')));
214212
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.removePackage', (item) => projectExplorer.UninstallKeilPackage(item)));
215213
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.addPackage', (item) => projectExplorer.InstallKeilPackage(item.val.projectIndex)));
216214
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.exportXml', (item) => projectExplorer.ExportKeilXml(item.val.projectIndex)));
217215
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.setDevice', (item) => projectExplorer.SetDevice(item.val.projectIndex)));
216+
// - cmsis core packages
217+
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.installCMSISHeaders', (item) => projectExplorer.installCmsisSourcePack(item, 'header')));
218+
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.installCmsisLibs', (item) => projectExplorer.installCmsisSourcePack(item, 'lib')));
219+
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.installCmsisDriverInterface', (item) => projectExplorer.installCmsisSourcePack(item, 'idrv')));
218220

219221
// builder
220222
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.modifyCompileConfig', (item) => projectExplorer.ModifyCompileConfig(item)));

0 commit comments

Comments
 (0)