#fix bug of libPick

This commit is contained in:
锦恢 2023-07-08 03:50:42 +08:00
parent bf91a08b17
commit 554897eb0b
6 changed files with 90 additions and 52 deletions

View File

@ -60,6 +60,9 @@ async function launch(context: vscode.ExtensionContext) {
// await vlogFast("e:/Project/Digial-IDE/TestWs/simulate/user/sim/tb_file/scc018ug_hd_rvt.v");
console.log(hdlParam);
console.log(opeParam.prjInfo.library.hardware.common);
console.log(opeParam.prjInfo.library.hardware.custom);
MainOutput.report('Digital-IDE has launched, Version: 0.3.0');
MainOutput.report('OS: ' + opeParam.os);

View File

@ -166,6 +166,7 @@ class OpeParam {
*/
public getUserPrjInfo(): PrjInfo {
const userPrjInfo = new PrjInfo();
userPrjInfo.initContextPath(this.extensionPath, this.workspacePath);
const rawPrjInfo = this.getRawUserPrjInfo();
userPrjInfo.merge(rawPrjInfo);
return userPrjInfo;

View File

@ -24,26 +24,40 @@ type PrjInfoMeta = Record<keyof PrjInfoSchema, any>;
type RawPrjInfoMeta = OptionalPickType<PrjInfoMeta>;
const PrjInfoDefaults: PrjInfoMeta = {
toolChain: ToolChainType.Xilinx,
prjName: {
PL: 'template',
PS: 'template'
get toolChain() {
return ToolChainType.Xilinx;
},
IP_REPO: [],
get prjName() {
return {
PL: 'template',
PS: 'template'
};
},
soc: {
get IP_REPO() {
return [];
},
get soc() {
return {
core: '',
bd: '',
os: '',
app: ''
};
},
enableShowLog: false,
device: 'none',
get enableShowLog() {
return false;
}
arch: {
get device() {
return 'none';
},
get arch() {
return {
prjPath: '',
hardware: {
src: '',
@ -54,14 +68,17 @@ const PrjInfoDefaults: PrjInfoMeta = {
src: '',
data: ''
}
};
},
library: {
get library() {
return {
state: LibraryState.Unknown,
hardware: {
common: [],
custom: []
}
};
}
};
@ -250,7 +267,8 @@ class PrjInfo implements PrjInfoMeta {
public updatePathWisely<T extends string>(obj: Record<T, AbsPath | AbsPath[]>,
attr: T,
path?: Path | Path[],
root?: AbsPath) {
root?: AbsPath,
defaultPath: Path | Path[] = '') {
if (path) {
if (path instanceof Array) {
const actualPaths = [];
@ -268,7 +286,7 @@ class PrjInfo implements PrjInfoMeta {
}
}
} else {
obj[attr] = '';
obj[attr] = defaultPath;
}
}
@ -409,14 +427,22 @@ class PrjInfo implements PrjInfoMeta {
} else {
this._library.state = library.state;
}
} else {
this._library.state = library.state;
}
if (library.hardware) {
// TODO : finish this when you can acquire root of common and custom
const commonPath = this.libCommonPath;
const customPath = this.libCustomPath;
this.updatePathWisely(this.library.hardware, 'common', library.hardware.common, commonPath);
this.updatePathWisely(this.library.hardware, 'custom', library.hardware.custom, customPath);
this.library.hardware.common = library.hardware.common ? library.hardware.common : [];
// this.updatePathWisely(this.library.hardware, 'common', library.hardware.common, commonPath, []);
this.updatePathWisely(this.library.hardware, 'custom', library.hardware.custom, customPath, []);
} else {
this._library.hardware = library.hardware;
}
} else {
this._library.hardware = PrjInfoDefaults.library.hardware;
this._library.state = PrjInfoDefaults.library.state;
}
}
@ -479,7 +505,7 @@ class PrjInfo implements PrjInfoMeta {
public get libCommonPath(): AbsPath {
const libPath = join(this._extensionPath, 'lib', 'common');
if (!fs.existsSync(libPath)) {
vscode.window.showErrorMessage('common lib path in extension is invalid, maybe extension has been corrupted, reinstall the extension');
vscode.window.showErrorMessage('common lib path: "' + libPath + '" in extension is invalid, maybe extension has been corrupted, reinstall the extension');
}
return libPath;
}

View File

@ -24,6 +24,9 @@ class LibPick {
constructor () {
this.commonPath = opeParam.prjInfo.libCommonPath;
this.customPath = opeParam.prjInfo.libCustomPath;
if (!this.customPath) {
this.customPath = 'no custom path is defined, see Prj->Lib->Custom->Path';
}
this.commonQuickPickItem = {
label: "$(libpick-common) common",
@ -177,9 +180,9 @@ class LibPick {
}
}
function pickLibrary() {
async function pickLibrary() {
const picker = new LibPick();
picker.pickItems();
await picker.pickItems();
}
export {

View File

@ -107,7 +107,6 @@ class PrjManage {
searchPathSet.checkAdd(prjInfo.getLibraryCommonPaths());
searchPathSet.checkAdd(prjInfo.getLibraryCustomPaths());
MainOutput.report('<getPrjHardwareFiles> search folders: ', ReportType.Debug);
searchPathSet.files.forEach(p => MainOutput.report(p, ReportType.Debug));

View File

@ -167,10 +167,14 @@ class PpyAction extends BaseAction {
// get path set from opeParam that used to tell if need to remake HdlMonitor
private getImportantPathSet(): Set<AbsPath | RelPath> {
const pathSet = new Set<AbsPath | RelPath>();
pathSet.add(opeParam.prjInfo.arch.hardware.sim);
pathSet.add(opeParam.prjInfo.arch.hardware.src);
pathSet.add(opeParam.prjInfo.libCommonPath);
pathSet.add(opeParam.prjInfo.libCustomPath);
pathSet.add(opeParam.prjInfo.hardwareSimPath);
pathSet.add(opeParam.prjInfo.hardwareSrcPath);
for (const path of opeParam.prjInfo.getLibraryCommonPaths()) {
pathSet.add(path);
}
for (const path of opeParam.prjInfo.getLibraryCustomPaths()) {
pathSet.add(path);
}
return pathSet;
}
@ -182,6 +186,8 @@ class PpyAction extends BaseAction {
opeParam.mergePrjInfo(rawPrjInfo);
const currentPathSet = this.getImportantPathSet();
console.log(originalPathSet, currentPathSet);
if (isSameSet(originalPathSet, currentPathSet)) {
return;
}