From 7fee932ade69d8ebe6ad8f8c70ecd805777e6bed Mon Sep 17 00:00:00 2001 From: Kirigaya <1193466151@qq.com> Date: Wed, 19 Apr 2023 22:52:26 +0800 Subject: [PATCH] save --- package.json | 194 ++++++++++++++++++++++--------- package.nls.json | 13 ++- package.nls.zh-cn.json | 13 ++- package.nls.zh-tw.json | 13 ++- src/extension.ts | 11 +- src/function/treeView/command.ts | 2 +- src/function/treeView/tree.ts | 17 +++ src/hdlFs/file.ts | 2 + src/hdlParser/core.ts | 4 + src/manager/PL/index.ts | 186 +++++++++++++++++++++++++++++ src/manager/PL/xilinx.ts | 24 ++-- src/manager/PS/index.ts | 61 ++++++++++ src/manager/PS/xilinx.ts | 7 +- src/manager/common.ts | 37 ++++++ src/manager/index.ts | 18 ++- src/manager/prj.ts | 35 +++++- 16 files changed, 546 insertions(+), 91 deletions(-) create mode 100644 src/manager/PL/index.ts create mode 100644 src/manager/PS/index.ts create mode 100644 src/manager/common.ts diff --git a/package.json b/package.json index 66356e4..ccbe09e 100644 --- a/package.json +++ b/package.json @@ -31,11 +31,18 @@ "description": "path of the dictionary of \"custom\" in library" }, "prj.file.structure.notice": { - "scope": "window", - "type": "boolean", - "default": true, - "description": "notice when change file structure" - }, + "scope": "window", + "type": "boolean", + "default": true, + "description": "notice when change file structure" + }, + "prj.vivado.install.path": { + "scope": "window", + "type": "string", + "default": "", + "description": "set the xilinx install path. \n e.g. : D:/APP/vivado_18_3/Vivado/2018.3/bin \n This applies only to WIN For other systems, add it to environment variables" + }, + "prj.xsdk.install.path": {}, "function.doc.webview.backgroundImage": { "type": "string", "default": "", @@ -175,14 +182,14 @@ } }, { - "command": "digital-ide.pickLibrary", - "title": "import library", - "icon": { - "light": "images/svg/light/library.svg", - "dark": "images/svg/dark/library.svg" - }, - "category": "Digital-IDE" - }, + "command": "digital-ide.pickLibrary", + "title": "%digital-ide.pickLibrary.title%", + "icon": { + "light": "images/svg/light/library.svg", + "dark": "images/svg/dark/library.svg" + }, + "category": "Digital-IDE" + }, { "command": "digital-ide.treeView.arch.expand", "category": "tool", @@ -207,9 +214,9 @@ "title": "%digital-ide.treeView.arch.openFile.title%" }, { - "command": "digital-ide.tool.tool.clean", + "command": "digital-ide.tool.clean", "category": "tool", - "title": "%digital-ide.tool.tool.clean.title%" + "title": "%digital-ide.tool.clean.title%" }, { "command": "digital-ide.soft.launch", @@ -285,26 +292,101 @@ "command": "digital-ide.hard.exit", "category": "tool", "title": "%digital-ide.hard.exit.title%" + }, + { + "command": "digital-ide.pl.setSrcTop", + "category": "pl", + "title": "%digital-ide.pl.setSrcTop.title%" + }, + { + "command": "digital-ide.pl.setSimTop", + "category": "pl", + "title": "%digital-ide.pl.setSimTop.title%" + }, + { + "command": "digital-ide.pl.addDevice", + "category": "pl", + "title": "%digital-ide.pl.addDevice.title%" + }, + { + "command": "digital-ide.pl.delDevice", + "category": "pl", + "title": "%digital-ide.pl.delDevice.title%" + }, + { + "command": "digital-ide.pl.addFile", + "category": "pl", + "title": "%digital-ide.pl.addFile.title%" + }, + { + "command": "digital-ide.pl.delFile", + "category": "pl", + "title": "%digital-ide.pl.delFile.title%" + }, + { + "command": "digital-ide.netlist", + "icon": { + "light": "images/svg/light/netlist.svg", + "dark": "images/svg/dark/netlist.svg" + }, + "category": "tool", + "title": "%digital-ide.netlist.title%" + }, + { + "command": "digital-ide.fsm", + "icon": { + "light": "images/svg/light/fsm.svg", + "dark": "images/svg/dark/fsm.svg" + }, + "category": "tool", + "title": "%digital-ide.fsm.title%" } ], "menus": { "view/title": [ - { - "command": "digital-ide.treeView.arch.collapse", - "group": "navigation", - "when": "view == digital-ide-treeView-arch" - }, - { - "command": "digital-ide.pickLibrary", - "group": "navigation", - "when": "view == digital-ide-treeView-arch" - }, - { - "command": "digital-ide.treeView.arch.refresh", - "group": "navigation", - "when": "view == digital-ide-treeView-arch" - } - ], + { + "command": "digital-ide.treeView.arch.collapse", + "group": "navigation", + "when": "view == digital-ide-treeView-arch" + }, + { + "command": "digital-ide.pickLibrary", + "group": "navigation", + "when": "view == digital-ide-treeView-arch" + }, + { + "command": "digital-ide.treeView.arch.refresh", + "group": "navigation", + "when": "view == digital-ide-treeView-arch" + } + ], + "view/item/context": [ + { + "command": "digital-ide.tool.icarus.simulateFile", + "group": "inline@1", + "when": "view == digital-ide-treeView-arch && viewItem == file" + }, + { + "command": "digital-ide.netlist", + "group": "inline@3", + "when": "view == digital-ide-treeView-arch && viewItem == file" + }, + { + "command": "digital-ide.pl.setSrcTop", + "group": "navigation@1", + "when": "view == digital-ide-treeView-arch && viewItem == file" + }, + { + "command": "digital-ide.pl.setSimTop", + "group": "navigation@2", + "when": "view == digital-ide-treeView-arch && viewItem == file" + }, + { + "command": "digital-ide.tool.icarus.simulateFile", + "group": "navigation@3", + "when": "view == digital-ide-treeView-arch && viewItem == file" + } + ], "editor/title": [ { "when": "editorLangId == verilog || editorLangId == systemverilog || editorLangId == vhdl", @@ -320,33 +402,33 @@ }, "viewsContainers": { "activitybar": [ - { - "id": "TreeView", - "title": "Digital-IDE: TreeView", - "icon": "images/svg/view.svg" - } - ] + { + "id": "TreeView", + "title": "Digital-IDE: TreeView", + "icon": "images/svg/view.svg" + } + ] }, "views": { - "TreeView": [ - { - "id": "digital-ide-treeView-arch", - "name": "architecture" - }, - { - "id": "digital-ide-treeView-tool", - "name": "TOOL Options" - }, - { - "id": "digital-ide-treeView-hardware", - "name": "HARD Options" - }, - { - "id": "digital-ide-treeView-software", - "name": "SOFT Options" - } - ] - }, + "TreeView": [ + { + "id": "digital-ide-treeView-arch", + "name": "architecture" + }, + { + "id": "digital-ide-treeView-tool", + "name": "TOOL Options" + }, + { + "id": "digital-ide-treeView-hardware", + "name": "HARD Options" + }, + { + "id": "digital-ide-treeView-software", + "name": "SOFT Options" + } + ] + }, "keybindings": [ { "command": "digital-ide.tool.instance", diff --git a/package.nls.json b/package.nls.json index 372f648..a3be695 100644 --- a/package.nls.json +++ b/package.nls.json @@ -11,7 +11,7 @@ "digital-ide.treeView.arch.collapse.title": "collapse all the items in tree view", "digital-ide.treeView.arch.refresh.title": "refresh the tree view", "digital-ide.treeView.arch.openFile.title": "Open the corresponding file in tree view", - "digital-ide.tool.tool.clean.title": "Clean the current project", + "digital-ide.tool.clean.title": "Clean the current project", "digital-ide.soft.launch.title": "Launch SDK development assist function", "digital-ide.soft.build.title": "Build the current SDK project", "digital-ide.soft.download.title": "Download the boot file into the device", @@ -26,5 +26,14 @@ "digital-ide.hard.build.bitstream.title": "Generate the BIT File", "digital-ide.hard.program.title": "Download the bit file into the device", "digital-ide.hard.gui.title": "Open the GUI", - "digital-ide.hard.exit.title": "Exit the current project" + "digital-ide.hard.exit.title": "Exit the current project", + "digital-ide.pickLibrary.title": "select lib from custom & common", + "digital-ide.pl.setSrcTop.title": "set as top file of src", + "digital-ide.pl.setSimTop.title": "set as top file of sim", + "digital-ide.pl.addDevice.title": "add device", + "digital-ide.pl.delDevice.title": "del device", + "digital-ide.pl.addFile.title": "add file", + "digital-ide.pl.delFile.title": "del file", + "digital-ide.netlist.title": "netlist", + "digital-ide.fsm.title": "finite state machine" } \ No newline at end of file diff --git a/package.nls.zh-cn.json b/package.nls.zh-cn.json index ebd5d80..65a1a05 100644 --- a/package.nls.zh-cn.json +++ b/package.nls.zh-cn.json @@ -11,7 +11,7 @@ "digital-ide.treeView.arch.collapse.title": "崩溃树视图中的所有项目", "digital-ide.treeView.arch.refresh.title": "刷新树视图", "digital-ide.treeView.arch.openFile.title": "在树视图打开相应的文件", - "digital-ide.tool.tool.clean.title": "干净的当前项目", + "digital-ide.tool.clean.title": "干净的当前项目", "digital-ide.soft.launch.title": "启动SDK开发辅助功能", "digital-ide.soft.build.title": "建立项目当前的SDK", "digital-ide.soft.download.title": "下载文件到设备引导", @@ -26,5 +26,14 @@ "digital-ide.hard.build.bitstream.title": "生成一些文件", "digital-ide.hard.program.title": "下载文件到设备", "digital-ide.hard.gui.title": "打开界面", - "digital-ide.hard.exit.title": "退出当前项目" + "digital-ide.hard.exit.title": "退出当前项目", + "digital-ide.pickLibrary.title": "从自定义选择自由和普遍", + "digital-ide.pl.setSrcTop.title": "设置为src的top", + "digital-ide.pl.setSimTop.title": "设置为sim的top", + "digital-ide.pl.addDevice.title": "添加device", + "digital-ide.pl.delDevice.title": "删除device", + "digital-ide.pl.addFile.title": "添加文件", + "digital-ide.pl.delFile.title": "d删除文件", + "digital-ide.netlist.title": "netlist", + "digital-ide.fsm.title": "有限状态机" } \ No newline at end of file diff --git a/package.nls.zh-tw.json b/package.nls.zh-tw.json index 67b7825..86ebf78 100644 --- a/package.nls.zh-tw.json +++ b/package.nls.zh-tw.json @@ -11,7 +11,7 @@ "digital-ide.treeView.arch.collapse.title": "崩潰樹視圖中的所有項目", "digital-ide.treeView.arch.refresh.title": "刷新樹視圖", "digital-ide.treeView.arch.openFile.title": "在樹視圖打開相應的文件", - "digital-ide.tool.tool.clean.title": "乾淨的當前項目", + "digital-ide.tool.clean.title": "乾淨的當前項目", "digital-ide.soft.launch.title": "啟動SDK開發輔助功能", "digital-ide.soft.build.title": "建立項目當前的SDK", "digital-ide.soft.download.title": "下載文件到設備引導", @@ -26,5 +26,14 @@ "digital-ide.hard.build.bitstream.title": "生成一些文件", "digital-ide.hard.program.title": "下載文件到設備", "digital-ide.hard.gui.title": "打開界面", - "digital-ide.hard.exit.title": "退出當前項目" + "digital-ide.hard.exit.title": "退出當前項目", + "digital-ide.pickLibrary.title": "從自定義選擇自由和普遍", + "digital-ide.pl.setSrcTop.title": "設置為src的文件", + "digital-ide.pl.setSimTop.title": "設置為文件的sim卡", + "digital-ide.pl.addDevice.title": "添加設備", + "digital-ide.pl.delDevice.title": "德爾設備", + "digital-ide.pl.addFile.title": "添加文件", + "digital-ide.pl.delFile.title": "del文件", + "digital-ide.netlist.title": "網表", + "digital-ide.fsm.title": "有限狀態機" } \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index bee71ba..cba6f8d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -11,16 +11,9 @@ async function registerCommand(context: vscode.ExtensionContext) { } async function launch(context: vscode.ExtensionContext) { - console.time('launch'); - prjManage.initOpeParam(context); - console.log(opeParam.prjInfo); + await prjManage.initialise(context); + await registerCommand(context); - const hdlFiles = prjManage.getPrjHardwareFiles(); - await hdlParam.initialize(hdlFiles); - - console.timeLog('launch'); - - await registerCommand(context); MainOutput.report('Digital-IDE has launched, Version: 0.3.0'); MainOutput.report('OS: ' + opeParam.os); } diff --git a/src/function/treeView/command.ts b/src/function/treeView/command.ts index 39d1b17..fbe310f 100644 --- a/src/function/treeView/command.ts +++ b/src/function/treeView/command.ts @@ -180,7 +180,7 @@ class ToolTreeProvider extends BaseCommandTreeProvider { constructor() { const config: CommandConfig = { Clean: { - cmd: 'digital-ide.tool.tool.clean', + cmd: 'digital-ide.tool.clean', icon: 'clean', tip: 'Clean the current project' } diff --git a/src/function/treeView/tree.ts b/src/function/treeView/tree.ts index 9f010d9..6874433 100644 --- a/src/function/treeView/tree.ts +++ b/src/function/treeView/tree.ts @@ -82,6 +82,8 @@ class ModuleTreeProvider implements vscode.TreeDataProvider { public refreshSrc() { this.treeEventEmitter.fire(this.srcRootItem); + console.log('enter'); + } public refreshSim() { @@ -134,6 +136,8 @@ class ModuleTreeProvider implements vscode.TreeDataProvider { public getChildren(element?: ModuleDataItem | undefined): vscode.ProviderResult { if (element) { + console.log(element); + const name = element.name; if (name === 'sim' || name === 'src') { element.parent = null; @@ -182,6 +186,8 @@ class ModuleTreeProvider implements vscode.TreeDataProvider { const range = firstTop.range; const parent = element; + + const tops = topModuleItemList.filter(item => item.path === path && item.name === name); const adjustItemList = []; if (tops.length > 0 || !hdlParam.hasHdlModule(path, name)) { @@ -271,6 +277,17 @@ class ModuleTreeProvider implements vscode.TreeDataProvider { } } } + + public getItemType(item: ModuleDataItem): string | null { + if (!item) { + return null; + } + let currentLevel = item; + while (currentLevel.parent) { + currentLevel = currentLevel.parent; + } + return currentLevel.type; + } } const moduleTreeProvider = new ModuleTreeProvider(); diff --git a/src/hdlFs/file.ts b/src/hdlFs/file.ts index ca459b6..911381d 100644 --- a/src/hdlFs/file.ts +++ b/src/hdlFs/file.ts @@ -179,6 +179,8 @@ function writeFile(path: AbsPath, content: string): boolean { function readJSON(path: AbsPath): object { try { + console.log(path); + const context = fs.readFileSync(path, 'utf-8'); return JSON.parse(context); } catch (err) { diff --git a/src/hdlParser/core.ts b/src/hdlParser/core.ts index 3154dfa..f393295 100644 --- a/src/hdlParser/core.ts +++ b/src/hdlParser/core.ts @@ -167,6 +167,10 @@ class HdlParam { return dependencies; } + public getUnhandleInstanceNumber(): number { + return this.unhandleInstances.size; + } + public getUnhandleInstanceByType(typeName: string): HdlInstance | undefined { for (const inst of this.unhandleInstances) { if (inst.type === typeName) { diff --git a/src/manager/PL/index.ts b/src/manager/PL/index.ts new file mode 100644 index 0000000..d9a09fe --- /dev/null +++ b/src/manager/PL/index.ts @@ -0,0 +1,186 @@ +import * as vscode from 'vscode'; + +import { PLConfig, XilinxOperation } from './xilinx'; +import { BaseManage } from '../common'; +import { opeParam } from '../../global'; +import { ToolChainType } from '../../global/enum'; +import { hdlFile, hdlPath } from '../../hdlFs'; +import { moduleTreeProvider, ModuleDataItem } from '../../function/treeView/tree'; +import { HdlFileType } from '../../hdlParser/common'; +import { PropertySchema } from '../../global/propertySchema'; + +class PlManage extends BaseManage { + config: PLConfig; + + constructor() { + super(); + this.config = { + tool: 'default', + path: '', + ope: new XilinxOperation(), + terminal: this.createTerminal('Hardware') + }; + + if (opeParam.prjInfo.toolChain) { + this.config.tool = opeParam.prjInfo.toolChain; + } + + const curToolChain = this.config.tool; + if (curToolChain === ToolChainType.Xilinx) { + const vivadoPath = vscode.workspace.getConfiguration('prj.vivado.install').get('path', ''); + if (hdlFile.isDir(vivadoPath)) { + this.config.path = hdlPath.join(hdlPath.toSlash(vivadoPath), 'vivado'); + if (opeParam.os === 'win32') { + this.config.path += '.bat'; + } + } else { + this.config.path = 'vivado'; + } + } + } + + + launch() { + this.config.ope.launch(this.config); + } + + refresh() { + if (!this.config.terminal) { + return null; + } + + this.config.ope.refresh(this.config.terminal); + } + + simulate() { + if (!this.config.terminal) { + return null; + } + + this.config.ope.simulate(this.config); + } + + build() { + if (!this.config.terminal) { + return null; + } + + this.config.ope.build(this.config); + } + + synth() { + if (!this.config.terminal) { + return null; + } + + this.config.ope.synth(this.config); + } + + impl() { + if (!this.config.terminal) { + return null; + } + + this.config.ope.impl(this.config); + } + + bit() { + if (!this.config.terminal) { + return null; + } + + this.config.ope.generateBit(this.config); + } + + program() { + if (!this.config.terminal) { + return null; + } + + this.config.ope.program(this.config); + } + + gui() { + this.config.ope.gui(this.config); + } + + exit() { + if (!this.config.terminal) { + return null; + } + + this.config.terminal.show(true); + this.config.terminal.sendText(`exit`); + this.config.terminal.sendText(`exit`); + this.config.terminal = null; + } + + + setSrcTop(item: ModuleDataItem) { + this.config.ope.setSrcTop(item.name, this.config); + const type = moduleTreeProvider.getItemType(item); + if (type === HdlFileType.Src) { + moduleTreeProvider.setFirstTop(HdlFileType.Src, item.name, item.path); + moduleTreeProvider.refreshSrc(); + } + } + + setSimTop(item: ModuleDataItem) { + this.config.ope.setSimTop(item.name, this.config); + const type = moduleTreeProvider.getItemType(item); + if (type === HdlFileType.Sim) { + moduleTreeProvider.setFirstTop(HdlFileType.Sim, item.name, item.path); + moduleTreeProvider.refreshSim(); + } + } + + + async addFiles(files: string[]) { + this.config.ope.addFiles(files, this.config); + } + + async delFiles(files: string[]) { + this.config.ope.delFiles(files, this.config); + } + + async addDevice() { + const propertySchema = opeParam.propertySchemaPath; + let propertyParam = hdlFile.readJSON(propertySchema) as PropertySchema; + const device = await vscode.window.showInputBox({ + password: false, + ignoreFocusOut: true, + placeHolder: 'Please input the name of device' + }); + + if (!device) { + return; + } + + if (!propertyParam.properties.device.enum.includes(device)) { + propertyParam.properties.device.enum.push(device); + hdlFile.writeJSON(propertySchema, propertyParam); + vscode.window.showInformationMessage(`Add the ${device} successfully!!!`); + } else { + vscode.window.showWarningMessage("The device already exists."); + } + } + + async delDevice() { + const propertySchema = opeParam.propertySchemaPath; + let propertyParam = hdlFile.readJSON(propertySchema) as PropertySchema; + const device = await vscode.window.showQuickPick(propertyParam.properties.device.enum); + if (!device) { + return; + } + + const index = propertyParam.properties.device.enum.indexOf(device); + propertyParam.properties.device.enum.splice(index, 1); + hdlFile.writeJSON(propertySchema, propertyParam); + vscode.window.showInformationMessage(`Delete the ${device} successfully!!!`); + } +} + + +export { + PlManage, +}; \ No newline at end of file diff --git a/src/manager/PL/xilinx.ts b/src/manager/PL/xilinx.ts index 952f206..bb0f826 100644 --- a/src/manager/PL/xilinx.ts +++ b/src/manager/PL/xilinx.ts @@ -23,10 +23,10 @@ interface TopMod { }; interface PLConfig { - terminal? : vscode.Terminal | null, + terminal : vscode.Terminal | null, tool? : string, // 工具类型 path? : string, // 第三方工具运行路径 - ope? : XilinxOperation, + ope : XilinxOperation, }; interface PLPrjInfo { @@ -152,7 +152,7 @@ class XilinxOperation { } const tclPath = hdlPath.join(this.xilinxPath, 'launch.tcl'); - scripts.push(this.refresh({terminal: null})); + scripts.push(this.refresh()); scripts.push(`file delete ${tclPath} -force`); const tclCommands = scripts.join('\n') + '\n'; @@ -177,7 +177,7 @@ class XilinxOperation { scripts.push(`open_project ${path} -quiet`); } - refresh(config: PLConfig): string { + refresh(terminal?: vscode.Terminal): string { const scripts: string[] = []; // 清除所有源文件 scripts.push(`remove_files -quiet [get_files]`); @@ -284,7 +284,7 @@ class XilinxOperation { hdlFile.writeFile(scriptPath, script); const cmd = `source ${scriptPath} -quiet`; - config.terminal?.sendText(cmd); + terminal?.sendText(cmd); return cmd; } @@ -561,7 +561,10 @@ class XilinxBd { this.extensionPath = opeParam.extensionPath; this.xbdPath = hdlPath.join(this.extensionPath, 'lib', 'bd', 'xilinx'); this.schemaPath = opeParam.propertySchemaPath; + + this.schemaCont = hdlFile.readJSON(this.schemaPath) as PropertySchema; + this.bdEnum = this.schemaCont.properties.soc.properties.bd.enum; this.bdRepo = this.setting.get('PRJ.xilinx.BD.repo.path', ''); } @@ -630,9 +633,7 @@ class XilinxBd { hdlFile.writeJSON(this.schemaPath, this.schemaCont); } - /** - * - */ + delete() { this.getConfig(); vscode.window.showQuickPick(this.bdEnum).then(select => { @@ -810,10 +811,9 @@ const tools = { }; -const xilinxBd = new XilinxBd(); - -module.exports = { +export { XilinxOperation, tools, - xilinxBd + XilinxBd, + PLConfig }; diff --git a/src/manager/PS/index.ts b/src/manager/PS/index.ts new file mode 100644 index 0000000..a914df4 --- /dev/null +++ b/src/manager/PS/index.ts @@ -0,0 +1,61 @@ +import * as vscode from 'vscode'; +import { opeParam } from '../../global'; +import { ToolChainType } from '../../global/enum'; +import { hdlFile, hdlPath } from '../../hdlFs'; +import { BaseManage } from '../common'; + +import { PSConfig, XilinxOperation } from './xilinx'; + + +class PsManage extends BaseManage { + config: PSConfig; + + constructor() { + super(); + this.config = { + tool : 'default', + path : '', + ope : new XilinxOperation(), + terminal : this.createTerminal('PS') + }; + + + // get tool chain + if (opeParam.prjInfo.toolChain) { + this.config.tool = opeParam.prjInfo.toolChain; + } + + // get install path & operation object + if (this.config.tool === ToolChainType.Xilinx) { + const xsdkPath = vscode.workspace.getConfiguration('prj.xsdk.install').get('path', ''); + if (hdlFile.isDir(xsdkPath)) { + this.config.path = hdlPath.join(hdlPath.toSlash(xsdkPath), 'xsct'); + if (opeParam.os === "win32") { + this.config.path += '.bat'; + } + } else { + this.config.path = 'xsct'; + } + } + } + + launch() { + this.config.terminal = this.createTerminal('Software'); + this.config.ope.launch(this.config); + } + + build() { + this.config.terminal = this.createTerminal('Software'); + this.config.ope.build(this.config); + } + + program() { + this.config.terminal = this.createTerminal('Software'); + this.config.ope.program(this.config); + } +} + + +export { + PsManage, +}; \ No newline at end of file diff --git a/src/manager/PS/xilinx.ts b/src/manager/PS/xilinx.ts index 518d4a3..34f40ec 100644 --- a/src/manager/PS/xilinx.ts +++ b/src/manager/PS/xilinx.ts @@ -15,10 +15,10 @@ interface XilinxOperationConfig { } interface PSConfig { - terminal? : vscode.Terminal | null, + terminal : vscode.Terminal, tool? : string, // 工具类型 path? : string, // 第三方工具运行路径 - ope? : XilinxOperation, + ope : XilinxOperation, } /** @@ -120,5 +120,6 @@ file delete ${scriptPath} -force\n`; } export { - XilinxOperation + XilinxOperation, + PSConfig }; \ No newline at end of file diff --git a/src/manager/common.ts b/src/manager/common.ts new file mode 100644 index 0000000..d241718 --- /dev/null +++ b/src/manager/common.ts @@ -0,0 +1,37 @@ +import * as vscode from 'vscode'; + +class BaseManage { + /** + * 创建终端,并返回对应的属性 + * @param name 终端名 + * @returns 终端属性 + */ + createTerminal(name: string) { + const terminal = this.getTerminal(name); + if (terminal) { + return terminal; + } + + return vscode.window.createTerminal({ + name: name + }); + } + + /** + * 获取终端对应的属性 + * @param name 终端名 + * @returns 终端属性 + */ + getTerminal(name: string): vscode.Terminal | null { + for (const terminal of vscode.window.terminals) { + if (terminal.name === name) { + return terminal; + } + } + return null; + } +} + +export { + BaseManage +}; \ No newline at end of file diff --git a/src/manager/index.ts b/src/manager/index.ts index 3a6e596..8fc106f 100644 --- a/src/manager/index.ts +++ b/src/manager/index.ts @@ -1,17 +1,33 @@ import * as vscode from 'vscode'; +import * as assert from 'assert'; import { prjManage } from './prj'; import { pickLibrary } from './libPick'; - function registerManagerCommands(context: vscode.ExtensionContext) { + // make ps and ps have been prepared + assert(prjManage.pl, 'pl is undefined'); + assert(prjManage.ps, 'ps is undefined'); + + const plManage = prjManage.pl; + const psManage = prjManage.ps; + vscode.commands.registerCommand('digital-ide.property-json.generate', prjManage.generatePropertyJson); vscode.commands.registerCommand('digital-ide.property-json.overwrite', prjManage.overwritePropertyJson); // libpick vscode.commands.registerCommand('digital-ide.pickLibrary', pickLibrary); + // ps + vscode.commands.registerCommand('digital-ide.pl.setSrcTop', (item) => plManage.setSrcTop(item)); + vscode.commands.registerCommand('digital-ide.pl.setSimTop', (item) => plManage.setSimTop(item)); + vscode.commands.registerCommand('digital-ide.pl.addDevice', () => plManage.addDevice()); + vscode.commands.registerCommand('digital-ide.pl.delDevice', () => plManage.delDevice()); + vscode.commands.registerCommand('digital-ide.pl.addFile', files => plManage.addFiles(files)); + vscode.commands.registerCommand('digital-ide.pl.delFile', files => plManage.delFiles(files)); + // pl + } export { diff --git a/src/manager/prj.ts b/src/manager/prj.ts index 34791ee..0d01077 100644 --- a/src/manager/prj.ts +++ b/src/manager/prj.ts @@ -2,13 +2,19 @@ import * as vscode from 'vscode'; import * as fs from 'fs'; -import { AbsPath, opeParam } from '../global'; +import { AbsPath, MainOutput, opeParam, ReportType } from '../global'; import { PathSet } from '../global/util'; import { RawPrjInfo } from '../global/prjInfo'; import { hdlFile, hdlPath } from '../hdlFs'; import { libManage } from './lib'; +import { hdlParam } from '../hdlParser'; +import { PlManage } from './PL'; +import { PsManage } from './PS'; class PrjManage { + pl?: PlManage; + ps?: PsManage; + // generate property template and write it to .vscode/property.json public async generatePropertyJson() { if (fs.existsSync(opeParam.propertyJsonPath)) { @@ -78,7 +84,8 @@ class PrjManage { const hardwareInfo = prjInfo.arch.hardware; // handle library first - libManage.processLibFiles(prjInfo.library); + const fileChange = libManage.processLibFiles(prjInfo.library); + MainOutput.report(`libManage finish process, add ${fileChange.add.length} files, del ${fileChange.del.length} files`, ReportType.Info); // add possible folder to search searchPathSet.checkAdd(hardwareInfo.src); @@ -94,8 +101,30 @@ class PrjManage { return hdlFile.getHDLFiles(searchPaths, ignores); } - public initialise() { + public async initialise(context: vscode.ExtensionContext, countTimeCost: boolean = true) { + if (countTimeCost) { + console.time('launch'); + } + this.initOpeParam(context); + MainOutput.report('finish initialise opeParam', ReportType.Info); + + const hdlFiles = this.getPrjHardwareFiles(); + MainOutput.report(`finish collect ${hdlFiles.length} hdl files`, ReportType.Info); + + await hdlParam.initialize(hdlFiles); + const unhandleNum = hdlParam.getUnhandleInstanceNumber(); + MainOutput.report(`finish analyse ${hdlFiles.length} hdl files, find ${unhandleNum} unsolved instances`, ReportType.Info); + + this.pl = new PlManage(); + this.ps = new PsManage(); + MainOutput.report('create pl and ps', ReportType.Info); + + + + if (countTimeCost) { + console.timeLog('launch'); + } } }