Skip to content

Commit 7e91a2c

Browse files
committed
allow get cmsis libs from index.json
1 parent 147275e commit 7e91a2c

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

src/ResManager.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import * as utility from './utility'
4242
import { CmdLineHandler } from "./CmdLineHandler";
4343
import * as yaml from 'yaml';
4444
import { CodeConverter } from "./CodeConverter";
45+
import { jsonc } from "jsonc";
4546

4647
let resManager: ResManager | undefined;
4748

@@ -339,9 +340,29 @@ export class ResManager extends events.EventEmitter {
339340
}
340341

341342
getCmsisLibPacks(): { [name: string]: File } {
342-
return {
343-
'libdsp': File.fromArray([(<File>this.GetDir('include')).path, 'cmsis', 'dsp_lib.7z'])
343+
344+
const cmsisDir = File.fromArray([(<File>this.GetDir('include')).path, 'cmsis']);
345+
const packages: { [name: string]: File } = {
346+
'libdsp': File.fromArray([cmsisDir.path, 'dsp_lib.7z'])
347+
};
348+
349+
const libsDir = File.fromArray([cmsisDir.path, 'libs']);
350+
const indexFile = File.fromArray([libsDir.path, 'index.json']);
351+
if (indexFile.IsFile()) {
352+
try {
353+
const libs = jsonc.parse(indexFile.Read());
354+
for (const key in libs) {
355+
const libpath = libs[key];
356+
if (typeof libpath == 'string') {
357+
packages[key] = File.fromArray([libsDir.path, libpath]);
358+
}
359+
}
360+
} catch (error) {
361+
// nothing todo
362+
}
344363
}
364+
365+
return packages;
345366
}
346367

347368
getStvpToolsDir(): File {

0 commit comments

Comments
 (0)