diff --git a/src/function/index.ts b/src/function/index.ts index 97c4ff1..b29f38c 100644 --- a/src/function/index.ts +++ b/src/function/index.ts @@ -46,7 +46,6 @@ function registerTreeView(context: vscode.ExtensionContext) { vscode.commands.registerCommand('digital-ide.treeView.arch.collapse', treeView.collapseTreeView); vscode.commands.registerCommand('digital-ide.treeView.arch.refresh', treeView.refreshArchTree); vscode.commands.registerCommand('digital-ide.treeView.arch.openFile', treeView.openFileByUri); - } diff --git a/src/function/treeView/command.ts b/src/function/treeView/command.ts index fbe310f..9dc9ba4 100644 --- a/src/function/treeView/command.ts +++ b/src/function/treeView/command.ts @@ -1,6 +1,9 @@ /* eslint-disable @typescript-eslint/naming-convention */ import * as vscode from 'vscode'; +import { MainOutput, opeParam } from '../../global'; +import { hdlDir, hdlFile, hdlPath } from '../../hdlFs'; import { getIconConfig } from '../../hdlFs/icons'; +import { hdlIgnore } from '../../manager/ignore'; interface CommandDataItem { name: string, @@ -186,6 +189,30 @@ class ToolTreeProvider extends BaseCommandTreeProvider { } }; super(config, 'TOOL'); + + vscode.commands.registerCommand('digital-ide.tool.clean', this.clean); + } + + public async clean() { + const prjPath = opeParam.prjInfo.arch.prjPath; + const xilFolder = hdlPath.join(opeParam.workspacePath, '.Xil'); + + hdlDir.rmdir(prjPath); + hdlDir.rmdir(xilFolder); + + const ignores = hdlIgnore.getIgnoreFiles(); + + const strFiles = hdlFile.pickFileRecursive(opeParam.workspacePath, ignores, p => p.endsWith('.str')); + for (const path of strFiles) { + hdlFile.removeFile(path); + } + + const logFiles = hdlFile.pickFileRecursive(opeParam.workspacePath, ignores, p => p.endsWith('.log')); + for (const path of logFiles) { + hdlFile.readFile(path); + } + + MainOutput.report('finish digital-ide.tool.clean'); } } diff --git a/src/manager/prj.ts b/src/manager/prj.ts index 2d38a69..b9ea168 100644 --- a/src/manager/prj.ts +++ b/src/manager/prj.ts @@ -11,6 +11,8 @@ import { hdlParam } from '../hdlParser'; import { PlManage } from './PL'; import { PsManage } from './PS'; import { hdlIgnore } from './ignore'; +import { ppyAction } from '../monitor/event'; +import { hdlMonitor } from '../monitor'; class PrjManage { pl?: PlManage; @@ -23,8 +25,11 @@ class PrjManage { return; } const template = hdlFile.readJSON(opeParam.propertyInitPath) as RawPrjInfo; - hdlFile.writeJSON(opeParam.propertyJsonPath, template); + + // TODO : this is a bug, that monitor cannot sense the add event of ppy + // so we need to do manually here + await ppyAction.add(opeParam.propertyJsonPath, hdlMonitor); } // overwrite content in current property.json to property-init.json diff --git a/src/monitor/event.ts b/src/monitor/event.ts index 2148b8b..23a92b5 100644 --- a/src/monitor/event.ts +++ b/src/monitor/event.ts @@ -200,11 +200,27 @@ class PpyAction extends BaseAction { const rawPrjInfo = opeParam.getRawUserPrjInfo(); // when delete, make ws path to be main parse path if (e === Event.Unlink) { + console.log('unlink ppy, PrjInfoDefaults.arch:', PrjInfoDefaults.arch); + rawPrjInfo.arch = PrjInfoDefaults.arch; } opeParam.mergePrjInfo(rawPrjInfo); + // // when delete, make ws path to be main parse path + // if (e === Event.Unlink) { + // const prjInfoArch = opeParam.prjInfo.arch; + // const workspacePath = opeParam.workspacePath; + + // // TODO : more elegant ? + // prjInfoArch.hardware.src = workspacePath; + // prjInfoArch.hardware.sim = workspacePath; + // prjInfoArch.hardware.data = workspacePath; + // prjInfoArch.prjPath = workspacePath; + // prjInfoArch.software.data = workspacePath; + // prjInfoArch.software.src = workspacePath; + // } + const currentPathSet = this.getImportantPathSet(); const currentLibState = opeParam.prjInfo.library.state; diff --git a/src/monitor/index.ts b/src/monitor/index.ts index 470e80d..8d21dc3 100644 --- a/src/monitor/index.ts +++ b/src/monitor/index.ts @@ -81,6 +81,14 @@ class HdlMonitor{ } } + public remakePpyMonitor() { + if (this.ppyMonitor) { + this.ppyMonitor.close(); + this.ppyMonitor = this.getPpyMonitor(); + this.registerPpyMonitorListener(); + } + } + public registerHdlMonitorListener() { Event.hdlAction.listenAdd(this); Event.hdlAction.listenChange(this); diff --git a/src/test/manager/.vscode/property.json b/src/test/manager/.vscode/property.json new file mode 100644 index 0000000..7dc2beb --- /dev/null +++ b/src/test/manager/.vscode/property.json @@ -0,0 +1,11 @@ +{ + "toolChain": "xilinx", + "prjName": { + "PL": "template" + }, + "soc": { + "core": "none" + }, + "enableShowLog": false, + "device": "none" +} \ No newline at end of file