#fix digital-ide.tool.clean

This commit is contained in:
锦恢 2023-07-14 02:53:45 +08:00
parent dbbae190d1
commit 2ad67933b1
6 changed files with 68 additions and 2 deletions

View File

@ -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);
}

View File

@ -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');
}
}

View File

@ -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 <add event> manually here
await ppyAction.add(opeParam.propertyJsonPath, hdlMonitor);
}
// overwrite content in current property.json to property-init.json

View File

@ -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;

View File

@ -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);

11
src/test/manager/.vscode/property.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"toolChain": "xilinx",
"prjName": {
"PL": "template"
},
"soc": {
"core": "none"
},
"enableShowLog": false,
"device": "none"
}