#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"); // await vlogFast("e:/Project/Digial-IDE/TestWs/simulate/user/sim/tb_file/scc018ug_hd_rvt.v");
console.log(hdlParam); 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('Digital-IDE has launched, Version: 0.3.0');
MainOutput.report('OS: ' + opeParam.os); MainOutput.report('OS: ' + opeParam.os);

View File

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

View File

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

View File

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

View File

@ -107,7 +107,6 @@ class PrjManage {
searchPathSet.checkAdd(prjInfo.getLibraryCommonPaths()); searchPathSet.checkAdd(prjInfo.getLibraryCommonPaths());
searchPathSet.checkAdd(prjInfo.getLibraryCustomPaths()); searchPathSet.checkAdd(prjInfo.getLibraryCustomPaths());
MainOutput.report('<getPrjHardwareFiles> search folders: ', ReportType.Debug); MainOutput.report('<getPrjHardwareFiles> search folders: ', ReportType.Debug);
searchPathSet.files.forEach(p => MainOutput.report(p, 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 // get path set from opeParam that used to tell if need to remake HdlMonitor
private getImportantPathSet(): Set<AbsPath | RelPath> { private getImportantPathSet(): Set<AbsPath | RelPath> {
const pathSet = new Set<AbsPath | RelPath>(); const pathSet = new Set<AbsPath | RelPath>();
pathSet.add(opeParam.prjInfo.arch.hardware.sim); pathSet.add(opeParam.prjInfo.hardwareSimPath);
pathSet.add(opeParam.prjInfo.arch.hardware.src); pathSet.add(opeParam.prjInfo.hardwareSrcPath);
pathSet.add(opeParam.prjInfo.libCommonPath); for (const path of opeParam.prjInfo.getLibraryCommonPaths()) {
pathSet.add(opeParam.prjInfo.libCustomPath); pathSet.add(path);
}
for (const path of opeParam.prjInfo.getLibraryCustomPaths()) {
pathSet.add(path);
}
return pathSet; return pathSet;
} }
@ -182,6 +186,8 @@ class PpyAction extends BaseAction {
opeParam.mergePrjInfo(rawPrjInfo); opeParam.mergePrjInfo(rawPrjInfo);
const currentPathSet = this.getImportantPathSet(); const currentPathSet = this.getImportantPathSet();
console.log(originalPathSet, currentPathSet);
if (isSameSet(originalPathSet, currentPathSet)) { if (isSameSet(originalPathSet, currentPathSet)) {
return; return;
} }