diff --git a/l10n/bundle.l10n.de.json b/l10n/bundle.l10n.de.json index fc2d268..0e0f3c3 100644 --- a/l10n/bundle.l10n.de.json +++ b/l10n/bundle.l10n.de.json @@ -59,5 +59,6 @@ "info.dide-doc.no-port-info": "Keine Portinformationen", "info.dide-doc.no-dep-info": "Keine Abhängigkeitsinformationen", "info.dide-doc.source.cannot-find": "Nicht gefunden", - "info.command.instantiation.pick-title": "Select a Module" + "info.command.instantiation.pick-title": "Select a Module", + "warn.command.clean.prjPath-is-workspace": "arch.prjPath is the same as the workspace path, the clean will delete the project, please check your arch.prjPath!" } \ No newline at end of file diff --git a/l10n/bundle.l10n.en.json b/l10n/bundle.l10n.en.json index ddba595..207a78a 100644 --- a/l10n/bundle.l10n.en.json +++ b/l10n/bundle.l10n.en.json @@ -59,5 +59,6 @@ "info.dide-doc.no-port-info": "No port information", "info.dide-doc.no-dep-info": "No dependency information", "info.dide-doc.source.cannot-find": "Cannot find", - "info.command.instantiation.pick-title": "Select a Module" + "info.command.instantiation.pick-title": "Select a Module", + "warn.command.clean.prjPath-is-workspace": "arch.prjPath is the same as the workspace path, the clean will delete the project, please check your arch.prjPath!" } \ No newline at end of file diff --git a/l10n/bundle.l10n.ja.json b/l10n/bundle.l10n.ja.json index 6395ad6..6f2b335 100644 --- a/l10n/bundle.l10n.ja.json +++ b/l10n/bundle.l10n.ja.json @@ -59,5 +59,6 @@ "info.dide-doc.no-port-info": "ポート情報がありません", "info.dide-doc.no-dep-info": "依存情報がありません", "info.dide-doc.source.cannot-find": "見つかりません", - "info.command.instantiation.pick-title": "Select a Module" + "info.command.instantiation.pick-title": "Select a Module", + "warn.command.clean.prjPath-is-workspace": "arch.prjPath is the same as the workspace path, the clean will delete the project, please check your arch.prjPath!" } \ No newline at end of file diff --git a/l10n/bundle.l10n.zh-cn.json b/l10n/bundle.l10n.zh-cn.json index 5cceb77..8501c65 100644 --- a/l10n/bundle.l10n.zh-cn.json +++ b/l10n/bundle.l10n.zh-cn.json @@ -59,5 +59,6 @@ "info.dide-doc.no-port-info": "没有端口信息", "info.dide-doc.no-dep-info": "没有依赖信息", "info.dide-doc.source.cannot-find": "无法找到", - "info.command.instantiation.pick-title": "选择一个模块" + "info.command.instantiation.pick-title": "选择一个模块", + "warn.command.clean.prjPath-is-workspace": "arch.prjPath 和当前的工作区目录相同, clean 功能可能会删除整个项目,请检查你的 arch.prjPath !" } \ No newline at end of file diff --git a/l10n/bundle.l10n.zh-tw.json b/l10n/bundle.l10n.zh-tw.json index 27af218..7e1dd85 100644 --- a/l10n/bundle.l10n.zh-tw.json +++ b/l10n/bundle.l10n.zh-tw.json @@ -59,5 +59,6 @@ "info.dide-doc.no-port-info": "沒有端口信息", "info.dide-doc.no-dep-info": "沒有依賴信息", "info.dide-doc.source.cannot-find": "無法找到", - "info.command.instantiation.pick-title": "Select a Module" + "info.command.instantiation.pick-title": "Select a Module", + "warn.command.clean.prjPath-is-workspace": "arch.prjPath is the same as the workspace path, the clean will delete the project, please check your arch.prjPath!" } \ No newline at end of file diff --git a/package.json b/package.json index e55e4be..bf71743 100644 --- a/package.json +++ b/package.json @@ -592,6 +592,11 @@ }, "category": "Digital-IDE", "title": "%digital-ide.waveviewer.show.title%" + }, + { + "command": "digital-ide.tool.clean", + "category": "Digital-IDE", + "title": "%digital-ide.tool.clean.title%" } ], "menus": { @@ -1066,7 +1071,7 @@ "fontCharacter": "\\e7a8" } }, - "instance-systemverilog":{ + "instance-systemverilog": { "description": "icon of system-verilog in TOOL.instance", "default": { "fontPath": "./images/icons/iconfont.woff2", diff --git a/src/function/index.ts b/src/function/index.ts index 3e7efd2..e07dd5c 100644 --- a/src/function/index.ts +++ b/src/function/index.ts @@ -22,7 +22,6 @@ import { hdlPath } from '../hdlFs'; import { LspClient, opeParam } from '../global'; import { DoFastToolChainType, SyncFastRequestType } from '../global/lsp'; import { makeDocBody } from './hdlDoc/html'; -import { State } from 'vscode-languageclient'; function registerDocumentation(context: vscode.ExtensionContext) { vscode.commands.registerCommand('digital-ide.hdlDoc.showWebview', async (uri: vscode.Uri) => { @@ -92,6 +91,7 @@ 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); + vscode.commands.registerCommand('digital-ide.tool.clean', treeView.clean); } function registerLsp(context: vscode.ExtensionContext, version: string) { diff --git a/src/function/treeView/command.ts b/src/function/treeView/command.ts index a9e88de..69240f6 100644 --- a/src/function/treeView/command.ts +++ b/src/function/treeView/command.ts @@ -6,6 +6,7 @@ import { MainOutput, opeParam } from '../../global'; import { hdlDir, hdlFile, hdlPath } from '../../hdlFs'; import { getIconConfig } from '../../hdlFs/icons'; import { hdlIgnore } from '../../manager/ignore'; +import { t } from '../../i18n'; interface CommandDataItem { name: string, @@ -191,18 +192,16 @@ class ToolTreeProvider extends BaseCommandTreeProvider { } }; super(config, 'TOOL'); - - vscode.commands.registerCommand('digital-ide.tool.clean', this.clean); } public async clean() { const workspacePath = opeParam.workspacePath; + const prjPath = opeParam.prjStructure.prjPath; // move bd * ip const plName = opeParam.prjInfo.prjName.PL; const targetPath = fspath.dirname(opeParam.prjInfo.arch.hardware.src); - // TODO: 适配更多的 toolChain const sourceIpPath = `${workspacePath}/prj/xilinx/${plName}.srcs/sources_1/ip`; const sourceBdPath = `${workspacePath}/prj/xilinx/${plName}.srcs/sources_1/bd`; @@ -212,32 +211,75 @@ class ToolTreeProvider extends BaseCommandTreeProvider { hdlDir.mvdir(sourceBdPath, targetPath, true); MainOutput.report("move dir from " + sourceBdPath + " to " + targetPath); - // if (prjPath !== opeParam.workspacePath) { - // hdlDir.rmdir(prjPath); - // hdlDir.rmdir(xilFolder); - // MainOutput.report("remove dir : " + prjPath); - // MainOutput.report("remove dir : " + xilFolder); - // } else { - // vscode.window.showWarningMessage("arch.prjPath is the same as the workspace path, the clean will delete the project, please check your arch.prjPath!"); - // } + if (prjPath !== opeParam.workspacePath) { + hdlDir.rmdir(prjPath); + const xilFolder = hdlPath.join(opeParam.workspacePath, '.Xil'); + hdlDir.rmdir(xilFolder); + MainOutput.report("remove dir : " + prjPath); + MainOutput.report("remove dir : " + xilFolder); + } else { + vscode.window.showWarningMessage(t('warn.command.clean.prjPath-is-workspace')); + } - // const ignores = hdlIgnore.getIgnoreFiles(); - // const strFiles = hdlFile.pickFileRecursive(workspacePath, ignores, p => p.endsWith('.str')); - // for (const path of strFiles) { - // hdlFile.removeFile(path); - // MainOutput.report("remove file " + path); - // } + const ignores = hdlIgnore.getIgnoreFiles(); + const strFiles = hdlFile.pickFileRecursive(workspacePath, ignores, p => p.endsWith('.str')); + for (const path of strFiles) { + hdlFile.removeFile(path); + MainOutput.report("remove file " + path); + } - // const logFiles = hdlFile.pickFileRecursive(workspacePath, ignores, p => p.endsWith('.log')); - // for (const path of logFiles) { - // hdlFile.readFile(path); - // } + const logFiles = hdlFile.pickFileRecursive(workspacePath, ignores, p => p.endsWith('.log')); + for (const path of logFiles) { + hdlFile.readFile(path); + } MainOutput.report('finish digital-ide.tool.clean'); } } +export async function clean() { + const workspacePath = opeParam.workspacePath; + const prjPath = opeParam.prjStructure.prjPath; + + // move bd * ip + const plName = opeParam.prjInfo.prjName.PL; + const targetPath = fspath.dirname(opeParam.prjInfo.arch.hardware.src); + + const sourceIpPath = `${workspacePath}/prj/xilinx/${plName}.srcs/sources_1/ip`; + const sourceBdPath = `${workspacePath}/prj/xilinx/${plName}.srcs/sources_1/bd`; + + hdlDir.mvdir(sourceIpPath, targetPath, true); + MainOutput.report("move dir from " + sourceIpPath + " to " + targetPath); + + hdlDir.mvdir(sourceBdPath, targetPath, true); + MainOutput.report("move dir from " + sourceBdPath + " to " + targetPath); + + if (prjPath !== opeParam.workspacePath) { + hdlDir.rmdir(prjPath); + const xilFolder = hdlPath.join(opeParam.workspacePath, '.Xil'); + hdlDir.rmdir(xilFolder); + MainOutput.report("remove dir : " + prjPath); + MainOutput.report("remove dir : " + xilFolder); + } else { + vscode.window.showWarningMessage(t('warn.command.clean.prjPath-is-workspace')); + } + + const ignores = hdlIgnore.getIgnoreFiles(); + const strFiles = hdlFile.pickFileRecursive(workspacePath, ignores, p => p.endsWith('.str')); + for (const path of strFiles) { + hdlFile.removeFile(path); + MainOutput.report("remove file " + path); + } + + const logFiles = hdlFile.pickFileRecursive(workspacePath, ignores, p => p.endsWith('.log')); + for (const path of logFiles) { + hdlFile.readFile(path); + } + + MainOutput.report('finish digital-ide.tool.clean'); +} + const hardwareTreeProvider = new HardwareTreeProvider(); const softwareTreeProvider = new SoftwareTreeProvider(); diff --git a/src/function/treeView/index.ts b/src/function/treeView/index.ts index 069bb26..50b472d 100644 --- a/src/function/treeView/index.ts +++ b/src/function/treeView/index.ts @@ -3,7 +3,7 @@ import * as fs from 'fs'; import * as fspath from 'path'; import { hdlFile, hdlPath } from '../../hdlFs'; -import { hardwareTreeProvider, softwareTreeProvider, toolTreeProvider } from './command'; +import { clean, hardwareTreeProvider, softwareTreeProvider, toolTreeProvider } from './command'; import { moduleTreeProvider, ModuleDataItem } from './tree'; import { Range } from '../../hdlParser/common'; import { MainOutput, opeParam, ReportType } from '../../global'; @@ -90,5 +90,6 @@ export { expandTreeView, collapseTreeView, openFileByUri, - refreshArchTree + refreshArchTree, + clean }; \ No newline at end of file diff --git a/src/manager/PL/xilinx.ts b/src/manager/PL/xilinx.ts index 9b0f3c3..02aefa1 100644 --- a/src/manager/PL/xilinx.ts +++ b/src/manager/PL/xilinx.ts @@ -187,9 +187,13 @@ class XilinxOperation { _this.onVivadoClose(); }, 100); - function launchScript(): Promise { + function launchScript(): Promise { + if (!opeParam.workspacePath) { + return Promise.resolve(undefined); + } // 执行 cmd 启动 - const vivadoProcess = spawn(cmd, [], { shell: true, stdio: 'pipe' }); + console.log('spawn process in ', opeParam.workspacePath); + const vivadoProcess = spawn(cmd, [], { shell: true, stdio: 'pipe', cwd: opeParam.workspacePath }); vivadoProcess.on('close', () => { onVivadoClose();