From 554897eb0bfc8d44c14d65c3af50d5cc25efddd6 Mon Sep 17 00:00:00 2001 From: Kirigaya <1193466151@qq.com> Date: Sat, 8 Jul 2023 03:50:42 +0800 Subject: [PATCH] #fix bug of libPick --- src/extension.ts | 3 ++ src/global/opeParam.ts | 1 + src/global/prjInfo.ts | 110 +++++++++++++++++++++++++---------------- src/manager/libPick.ts | 7 ++- src/manager/prj.ts | 3 +- src/monitor/event.ts | 18 ++++--- 6 files changed, 90 insertions(+), 52 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 3fbea3e..7a1b731 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -60,7 +60,10 @@ async function launch(context: vscode.ExtensionContext) { // await vlogFast("e:/Project/Digial-IDE/TestWs/simulate/user/sim/tb_file/scc018ug_hd_rvt.v"); console.log(hdlParam); + console.log(opeParam.prjInfo.library.hardware.common); + console.log(opeParam.prjInfo.library.hardware.custom); + MainOutput.report('Digital-IDE has launched, Version: 0.3.0'); MainOutput.report('OS: ' + opeParam.os); } diff --git a/src/global/opeParam.ts b/src/global/opeParam.ts index 7273e11..aa5ab9d 100644 --- a/src/global/opeParam.ts +++ b/src/global/opeParam.ts @@ -166,6 +166,7 @@ class OpeParam { */ public getUserPrjInfo(): PrjInfo { const userPrjInfo = new PrjInfo(); + userPrjInfo.initContextPath(this.extensionPath, this.workspacePath); const rawPrjInfo = this.getRawUserPrjInfo(); userPrjInfo.merge(rawPrjInfo); return userPrjInfo; diff --git a/src/global/prjInfo.ts b/src/global/prjInfo.ts index 2b41900..4d04ee0 100644 --- a/src/global/prjInfo.ts +++ b/src/global/prjInfo.ts @@ -24,44 +24,61 @@ type PrjInfoMeta = Record; type RawPrjInfoMeta = OptionalPickType; const PrjInfoDefaults: PrjInfoMeta = { - toolChain: ToolChainType.Xilinx, - - prjName: { - PL: 'template', - PS: 'template' + get toolChain() { + return ToolChainType.Xilinx; }, - IP_REPO: [], + get prjName() { + return { + PL: 'template', + PS: 'template' + }; + }, + + get IP_REPO() { + return []; + }, + + get soc() { + return { + core: '', + bd: '', + os: '', + app: '' + }; + }, + + get enableShowLog() { + return false; + } + + get device() { + return 'none'; + }, - soc: { - core: '', - bd: '', - os: '', - app: '' + get arch() { + return { + prjPath: '', + hardware: { + src: '', + sim: '', + data: '' + }, + software: { + src: '', + data: '' + } + }; }, - enableShowLog: false, - device: 'none', - - arch: { - prjPath: '', - hardware: { - src: '', - sim: '', - data: '' - }, - software: { - src: '', - data: '' - } - }, - - library: { - state: LibraryState.Unknown, - hardware: { - common: [], - custom: [] - } + get library() { + return { + state: LibraryState.Unknown, + hardware: { + common: [], + custom: [] + } + }; } }; @@ -250,7 +267,8 @@ class PrjInfo implements PrjInfoMeta { public updatePathWisely(obj: Record, attr: T, path?: Path | Path[], - root?: AbsPath) { + root?: AbsPath, + defaultPath: Path | Path[] = '') { if (path) { if (path instanceof Array) { const actualPaths = []; @@ -268,7 +286,7 @@ class PrjInfo implements PrjInfoMeta { } } } else { - obj[attr] = ''; + obj[attr] = defaultPath; } } @@ -400,7 +418,7 @@ class PrjInfo implements PrjInfoMeta { this.checkDirExist(this.arch.prjPath); } - public updateLibrary(library?: Library) { + public updateLibrary(library?: Library) { if (library) { if (library.state) { if (!validLibraryState(library.state)) { @@ -409,14 +427,22 @@ class PrjInfo implements PrjInfoMeta { } else { this._library.state = library.state; } + } else { + this._library.state = library.state; } if (library.hardware) { - // TODO : finish this when you can acquire root of common and custom const commonPath = this.libCommonPath; const customPath = this.libCustomPath; - this.updatePathWisely(this.library.hardware, 'common', library.hardware.common, commonPath); - this.updatePathWisely(this.library.hardware, 'custom', library.hardware.custom, customPath); + this.library.hardware.common = library.hardware.common ? library.hardware.common : []; + // this.updatePathWisely(this.library.hardware, 'common', library.hardware.common, commonPath, []); + this.updatePathWisely(this.library.hardware, 'custom', library.hardware.custom, customPath, []); + + } else { + this._library.hardware = library.hardware; } + } else { + this._library.hardware = PrjInfoDefaults.library.hardware; + this._library.state = PrjInfoDefaults.library.state; } } @@ -429,8 +455,8 @@ class PrjInfo implements PrjInfoMeta { } public getLibraryCommonPaths(absolute: boolean = true): Path[] { - if (absolute) { - const commonFolder = hdlPath.join(this.libCommonPath, 'Empty'); + if (absolute) { + const commonFolder = hdlPath.join(this.libCommonPath, 'Empty'); return this._library.hardware.common.map(relPath => hdlPath.rel2abs(commonFolder, relPath)); } return this._library.hardware.common; @@ -479,7 +505,7 @@ class PrjInfo implements PrjInfoMeta { public get libCommonPath(): AbsPath { const libPath = join(this._extensionPath, 'lib', 'common'); if (!fs.existsSync(libPath)) { - vscode.window.showErrorMessage('common lib path in extension is invalid, maybe extension has been corrupted, reinstall the extension'); + vscode.window.showErrorMessage('common lib path: "' + libPath + '" in extension is invalid, maybe extension has been corrupted, reinstall the extension'); } return libPath; } diff --git a/src/manager/libPick.ts b/src/manager/libPick.ts index a5c13fa..2b31a39 100644 --- a/src/manager/libPick.ts +++ b/src/manager/libPick.ts @@ -24,6 +24,9 @@ class LibPick { constructor () { this.commonPath = opeParam.prjInfo.libCommonPath; this.customPath = opeParam.prjInfo.libCustomPath; + if (!this.customPath) { + this.customPath = 'no custom path is defined, see Prj->Lib->Custom->Path'; + } this.commonQuickPickItem = { label: "$(libpick-common) common", @@ -177,9 +180,9 @@ class LibPick { } } -function pickLibrary() { +async function pickLibrary() { const picker = new LibPick(); - picker.pickItems(); + await picker.pickItems(); } export { diff --git a/src/manager/prj.ts b/src/manager/prj.ts index 3bdb4e8..16e319c 100644 --- a/src/manager/prj.ts +++ b/src/manager/prj.ts @@ -106,8 +106,7 @@ class PrjManage { searchPathSet.checkAdd(hardwareInfo.sim); searchPathSet.checkAdd(prjInfo.getLibraryCommonPaths()); searchPathSet.checkAdd(prjInfo.getLibraryCustomPaths()); - - + MainOutput.report(' search folders: ', ReportType.Debug); searchPathSet.files.forEach(p => MainOutput.report(p, ReportType.Debug)); diff --git a/src/monitor/event.ts b/src/monitor/event.ts index 3b9bc02..8334fb8 100644 --- a/src/monitor/event.ts +++ b/src/monitor/event.ts @@ -167,21 +167,27 @@ class PpyAction extends BaseAction { // get path set from opeParam that used to tell if need to remake HdlMonitor private getImportantPathSet(): Set { const pathSet = new Set(); - pathSet.add(opeParam.prjInfo.arch.hardware.sim); - pathSet.add(opeParam.prjInfo.arch.hardware.src); - pathSet.add(opeParam.prjInfo.libCommonPath); - pathSet.add(opeParam.prjInfo.libCustomPath); + pathSet.add(opeParam.prjInfo.hardwareSimPath); + pathSet.add(opeParam.prjInfo.hardwareSrcPath); + for (const path of opeParam.prjInfo.getLibraryCommonPaths()) { + pathSet.add(path); + } + for (const path of opeParam.prjInfo.getLibraryCustomPaths()) { + pathSet.add(path); + } return pathSet; } public async updateProperty(m: HdlMonitor) { const originalPathSet = this.getImportantPathSet(); const originalHdlFiles = prjManage.getPrjHardwareFiles(); - + const rawPrjInfo = opeParam.getRawUserPrjInfo(); opeParam.mergePrjInfo(rawPrjInfo); const currentPathSet = this.getImportantPathSet(); + console.log(originalPathSet, currentPathSet); + if (isSameSet(originalPathSet, currentPathSet)) { return; } @@ -189,7 +195,7 @@ class PpyAction extends BaseAction { vscode.window.withProgress(options, async () => await this.refreshHdlMonitor(m, originalHdlFiles)); } - public async refreshHdlMonitor(m: HdlMonitor, originalHdlFiles: AbsPath[]) { + public async refreshHdlMonitor(m: HdlMonitor, originalHdlFiles: AbsPath[]) { m.remakeHdlMonitor(); // update pl