#fix prj
This commit is contained in:
parent
ae2c5a1365
commit
dbbae190d1
@ -58,15 +58,15 @@ const PrjInfoDefaults: PrjInfoMeta = {
|
|||||||
|
|
||||||
get arch() {
|
get arch() {
|
||||||
return {
|
return {
|
||||||
prjPath: '',
|
prjPath: '.',
|
||||||
hardware: {
|
hardware: {
|
||||||
src: '',
|
src: '.',
|
||||||
sim: '',
|
sim: '.',
|
||||||
data: ''
|
data: '.'
|
||||||
},
|
},
|
||||||
software: {
|
software: {
|
||||||
src: '',
|
src: '.',
|
||||||
data: ''
|
data: '.'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -127,5 +127,6 @@ function cpdir(src: AbsPath, dest: AbsPath, cover: boolean) {
|
|||||||
export {
|
export {
|
||||||
mkdir,
|
mkdir,
|
||||||
rmdir,
|
rmdir,
|
||||||
cpdir
|
cpdir,
|
||||||
|
mvdir
|
||||||
};
|
};
|
@ -79,7 +79,9 @@ class PrjManage {
|
|||||||
{ title: 'No', value: false }
|
{ title: 'No', value: false }
|
||||||
);
|
);
|
||||||
if (res?.value) {
|
if (res?.value) {
|
||||||
vscode.commands.executeCommand('digital-ide.property-json.generate');
|
await this.generatePropertyJson();
|
||||||
|
const rawPrjInfo = hdlFile.readJSON(propertyJsonPath) as RawPrjInfo;
|
||||||
|
opeParam.mergePrjInfo(rawPrjInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,6 +127,7 @@ class PrjManage {
|
|||||||
}
|
}
|
||||||
await this.initOpeParam(context);
|
await this.initOpeParam(context);
|
||||||
MainOutput.report('finish initialise opeParam', ReportType.Info);
|
MainOutput.report('finish initialise opeParam', ReportType.Info);
|
||||||
|
prjManage.refreshPrjFolder();
|
||||||
|
|
||||||
const hdlFiles = await this.getPrjHardwareFiles();
|
const hdlFiles = await this.getPrjHardwareFiles();
|
||||||
MainOutput.report(`finish collect ${hdlFiles.length} hdl files`, ReportType.Info);
|
MainOutput.report(`finish collect ${hdlFiles.length} hdl files`, ReportType.Info);
|
||||||
@ -143,22 +146,25 @@ class PrjManage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async refreshPrjFolder() {
|
public async refreshPrjFolder() {
|
||||||
// TODO : finish this
|
// read new prj from ppy
|
||||||
// 无工程配置文件则直接退出
|
const rawPrjInfo = opeParam.getRawUserPrjInfo();
|
||||||
if (!opeParam.prjInfo) {
|
|
||||||
return;
|
if (rawPrjInfo.arch) {
|
||||||
|
// configure user's info
|
||||||
|
await this.createFolderByRawPrjInfo(rawPrjInfo);
|
||||||
|
} else {
|
||||||
|
// configure by default
|
||||||
|
await this.createFolderByDefault(rawPrjInfo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const prjInfo = opeParam.prjInfo;
|
public async createFolderByRawPrjInfo(rawPrjInfo: RawPrjInfo) {
|
||||||
|
if (rawPrjInfo.arch) {
|
||||||
|
hdlDir.mkdir(rawPrjInfo.arch.prjPath);
|
||||||
|
|
||||||
// 如果是用户配置文件结构,检查并生成相关文件夹
|
const hardware = rawPrjInfo.arch.hardware;
|
||||||
if (prjInfo.arch) {
|
const software = rawPrjInfo.arch.software;
|
||||||
hdlDir.mkdir(prjInfo.arch.prjPath);
|
|
||||||
const hardware = prjInfo.arch.hardware;
|
|
||||||
const software = prjInfo.arch.software;
|
|
||||||
|
|
||||||
if (hardware) {
|
if (hardware) {
|
||||||
hdlDir.mkdir(hardware.src);
|
hdlDir.mkdir(hardware.src);
|
||||||
@ -172,29 +178,26 @@ class PrjManage {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 先直接创建工程文件夹
|
|
||||||
hdlDir.mkdir(`${opeParam.workspacePath}/prj`);
|
|
||||||
|
|
||||||
// 初始化文件结构的路径
|
public async createFolderByDefault(rawPrjInfo: RawPrjInfo) {
|
||||||
const userPath = `${opeParam.workspacePath}/user`;
|
// create prj first
|
||||||
const softwarePath = `${opeParam.workspacePath}/user/Software`;
|
const defaultPrjPath = hdlPath.join(opeParam.workspacePath, 'prj');
|
||||||
const hardwarePath = `${opeParam.workspacePath}/user/Hardware`;
|
hdlDir.mkdir(defaultPrjPath);
|
||||||
|
|
||||||
let nextmode = "PL";
|
// basic path
|
||||||
// 再对源文件结构进行创建
|
const userPath = hdlPath.join(opeParam.workspacePath, 'user');
|
||||||
if (prjInfo.soc.core !== 'none') {
|
const softwarePath = hdlPath.join(userPath, 'Software');
|
||||||
nextmode = "LS";
|
const hardwarePath = hdlPath.join(userPath, 'Hardware');
|
||||||
}
|
|
||||||
|
const nextmode = this.getNextMode(rawPrjInfo);
|
||||||
|
const currmode = this.getCurrentMode(softwarePath, hardwarePath);
|
||||||
|
|
||||||
let currmode = "PL";
|
|
||||||
if (fs.existsSync(softwarePath) || fs.existsSync(hardwarePath)) {
|
|
||||||
currmode = "LS";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currmode === nextmode) {
|
if (currmode === nextmode) {
|
||||||
const hardware = opeParam.prjInfo.ARCH.Hardware;
|
const hardware = opeParam.prjInfo.arch.hardware;
|
||||||
const software = opeParam.prjInfo.ARCH.Software;
|
const software = opeParam.prjInfo.arch.software;
|
||||||
|
|
||||||
hdlDir.mkdir(hardware.src);
|
hdlDir.mkdir(hardware.src);
|
||||||
hdlDir.mkdir(hardware.sim);
|
hdlDir.mkdir(hardware.sim);
|
||||||
@ -203,44 +206,69 @@ class PrjManage {
|
|||||||
hdlDir.mkdir(software.src);
|
hdlDir.mkdir(software.src);
|
||||||
hdlDir.mkdir(software.data);
|
hdlDir.mkdir(software.data);
|
||||||
}
|
}
|
||||||
return;
|
} else if (currmode === "PL" && nextmode === "LS") {
|
||||||
}
|
|
||||||
|
|
||||||
if (currmode === "PL" && nextmode === "LS") {
|
|
||||||
hdlDir.mkdir(hardwarePath);
|
hdlDir.mkdir(hardwarePath);
|
||||||
hdlDir.readdir(userPath, true, (folder) => {
|
|
||||||
if (folder !== "Hardware") {
|
|
||||||
hdlDir.mvdir(folder, hardwarePath);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
hdlDir.mkdir(`${softwarePath}/data`);
|
for (const path of fs.readdirSync(userPath)) {
|
||||||
hdlDir.mkdir(`${softwarePath}/src`);
|
const filePath = hdlPath.join(userPath, path);
|
||||||
|
if (filePath !== 'Hardware') {
|
||||||
|
hdlDir.mvdir(filePath, hardwarePath, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const softwareDataPath = hdlPath.join(softwarePath, 'data');
|
||||||
|
const softwareSrcPath = hdlPath.join(softwarePath, 'src');
|
||||||
|
|
||||||
|
hdlDir.mkdir(softwareDataPath);
|
||||||
|
hdlDir.mkdir(softwareSrcPath);
|
||||||
}
|
}
|
||||||
else if (currmode === "LS" && nextmode === "PL") {
|
else if (currmode === "LS" && nextmode === "PL") {
|
||||||
const needNotice = vscode.workspace.getConfiguration().get('PRJ.file.structure.notice', true);
|
const needNotice = vscode.workspace.getConfiguration().get('PRJ.file.structure.notice', true);
|
||||||
if (needNotice) {
|
if (needNotice) {
|
||||||
let select = await vscode.window.showWarningMessage("Software will be deleted.", 'Yes', 'No');
|
const res = await vscode.window.showWarningMessage(
|
||||||
if (select === "Yes") {
|
"Software will be deleted.",
|
||||||
|
{ modal: true },
|
||||||
|
{ title: 'Yes', value: true },
|
||||||
|
{ title: 'No', value: false }
|
||||||
|
);
|
||||||
|
if (res?.value) {
|
||||||
hdlDir.rmdir(softwarePath);
|
hdlDir.rmdir(softwarePath);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hdlDir.rmdir(softwarePath);
|
hdlDir.rmdir(softwarePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hdlFile.isExist(hardwarePath)) {
|
if (fs.existsSync(hardwarePath)) {
|
||||||
hdlDir.readdir(hardwarePath, true, (folder) => {
|
for (const path of fs.readdirSync(hardwarePath)) {
|
||||||
hdlDir.mvdir(folder, userPath);
|
const filePath = hdlPath.join(hardwarePath, path);
|
||||||
})
|
hdlDir.mvdir(filePath, userPath, true);
|
||||||
|
}
|
||||||
hdlDir.rmdir(hardwarePath);
|
hdlDir.rmdir(hardwarePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
hdlDir.mkdir(`${userPath}/src`);
|
const userSrcPath = hdlPath.join(userPath, 'src');
|
||||||
hdlDir.mkdir(`${userPath}/sim`);
|
const userSimPath = hdlPath.join(userPath, 'sim');
|
||||||
hdlDir.mkdir(`${userPath}/data`);
|
const userDataPath = hdlPath.join(userPath, 'data');
|
||||||
|
|
||||||
|
hdlDir.mkdir(userSrcPath);
|
||||||
|
hdlDir.mkdir(userSimPath);
|
||||||
|
hdlDir.mkdir(userDataPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getNextMode(rawPrjInfo: RawPrjInfo): 'PL' | 'LS' {
|
||||||
|
if (rawPrjInfo.soc && rawPrjInfo.soc.core !== 'none') {
|
||||||
|
return 'LS';
|
||||||
|
}
|
||||||
|
return 'PL';
|
||||||
|
}
|
||||||
|
|
||||||
|
public getCurrentMode(softwarePath: AbsPath, hardwarePath: AbsPath): 'PL' | 'LS' {
|
||||||
|
if (fs.existsSync(softwarePath) || fs.existsSync(hardwarePath)) {
|
||||||
|
return 'LS';
|
||||||
|
}
|
||||||
|
return 'PL';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const prjManage = new PrjManage();
|
const prjManage = new PrjManage();
|
||||||
|
@ -5,7 +5,7 @@ import * as vscode from 'vscode';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import { refreshArchTree } from '../function/treeView';
|
import { refreshArchTree } from '../function/treeView';
|
||||||
import { AbsPath, MainOutput, opeParam, RelPath, ReportType } from '../global';
|
import { AbsPath, MainOutput, opeParam, PrjInfoDefaults, RelPath, ReportType } from '../global';
|
||||||
import { isSameSet } from '../global/util';
|
import { isSameSet } from '../global/util';
|
||||||
import { hdlFile, hdlPath } from '../hdlFs';
|
import { hdlFile, hdlPath } from '../hdlFs';
|
||||||
import { hdlParam, HdlSymbol } from '../hdlParser';
|
import { hdlParam, HdlSymbol } from '../hdlParser';
|
||||||
@ -160,19 +160,22 @@ class PpyAction extends BaseAction {
|
|||||||
async add(path: string, m: HdlMonitor): Promise<void> {
|
async add(path: string, m: HdlMonitor): Promise<void> {
|
||||||
console.log('PpyAction add');
|
console.log('PpyAction add');
|
||||||
assert.equal(hdlPath.toSlash(path), opeParam.propertyJsonPath);
|
assert.equal(hdlPath.toSlash(path), opeParam.propertyJsonPath);
|
||||||
this.updateProperty(m);
|
await this.updateProperty(Event.Add, m);
|
||||||
|
prjManage.refreshPrjFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
async unlink(path: string, m: HdlMonitor): Promise<void> {
|
async unlink(path: string, m: HdlMonitor): Promise<void> {
|
||||||
console.log('PpyAction unlink');
|
console.log('PpyAction unlink');
|
||||||
assert.equal(hdlPath.toSlash(path), opeParam.propertyJsonPath);
|
assert.equal(hdlPath.toSlash(path), opeParam.propertyJsonPath);
|
||||||
this.updateProperty(m);
|
await this.updateProperty(Event.Unlink, m);
|
||||||
|
prjManage.refreshPrjFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
async change(path: string, m: HdlMonitor): Promise<void> {
|
async change(path: string, m: HdlMonitor): Promise<void> {
|
||||||
console.log('PpyAction change');
|
console.log('PpyAction change');
|
||||||
assert.equal(hdlPath.toSlash(path), opeParam.propertyJsonPath);
|
assert.equal(hdlPath.toSlash(path), opeParam.propertyJsonPath);
|
||||||
this.updateProperty(m);
|
await this.updateProperty(Event.Change, m);
|
||||||
|
prjManage.refreshPrjFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
// get path set from opeParam that used to tell if need to remake HdlMonitor
|
// get path set from opeParam that used to tell if need to remake HdlMonitor
|
||||||
@ -189,12 +192,17 @@ class PpyAction extends BaseAction {
|
|||||||
return pathSet;
|
return pathSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateProperty(m: HdlMonitor) {
|
public async updateProperty(e: Event, m: HdlMonitor) {
|
||||||
const originalPathSet = this.getImportantPathSet();
|
const originalPathSet = this.getImportantPathSet();
|
||||||
const originalHdlFiles = await prjManage.getPrjHardwareFiles();
|
const originalHdlFiles = await prjManage.getPrjHardwareFiles();
|
||||||
const originalLibState = opeParam.prjInfo.library.state;
|
const originalLibState = opeParam.prjInfo.library.state;
|
||||||
|
|
||||||
const rawPrjInfo = opeParam.getRawUserPrjInfo();
|
const rawPrjInfo = opeParam.getRawUserPrjInfo();
|
||||||
|
// when delete, make ws path to be main parse path
|
||||||
|
if (e === Event.Unlink) {
|
||||||
|
rawPrjInfo.arch = PrjInfoDefaults.arch;
|
||||||
|
}
|
||||||
|
|
||||||
opeParam.mergePrjInfo(rawPrjInfo);
|
opeParam.mergePrjInfo(rawPrjInfo);
|
||||||
|
|
||||||
const currentPathSet = this.getImportantPathSet();
|
const currentPathSet = this.getImportantPathSet();
|
||||||
@ -203,7 +211,7 @@ class PpyAction extends BaseAction {
|
|||||||
if (isSameSet(originalPathSet, currentPathSet)) {
|
if (isSameSet(originalPathSet, currentPathSet)) {
|
||||||
// skip hdl remake
|
// skip hdl remake
|
||||||
if (originalLibState !== currentLibState) {
|
if (originalLibState !== currentLibState) {
|
||||||
const fileChange = libManage.processLibFiles(opeParam.prjInfo.library);
|
const fileChange = await libManage.processLibFiles(opeParam.prjInfo.library);
|
||||||
MainOutput.report(`libManage finish process, add ${fileChange.add.length} files, del ${fileChange.del.length} files`, ReportType.Info);
|
MainOutput.report(`libManage finish process, add ${fileChange.add.length} files, del ${fileChange.del.length} files`, ReportType.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
src/test/manager/user/src/hello.v
Normal file
6
src/test/manager/user/src/hello.v
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module hello(
|
||||||
|
input clk, reset,
|
||||||
|
output value
|
||||||
|
);
|
||||||
|
|
||||||
|
endmodule
|
@ -1,6 +1,6 @@
|
|||||||
module SimpleAdd_2(
|
module SimpleAdd_2(
|
||||||
input [8:0] a, b,
|
input [7:0] a, b,
|
||||||
output [8:0] c
|
output [7:0] c
|
||||||
);
|
);
|
||||||
|
|
||||||
assign c = a + b;
|
assign c = a + b;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user