From 138e43dc4daf3897fedc92427d6efabafbfa6479 Mon Sep 17 00:00:00 2001 From: LSTM-Kirigaya <1193466151@qq.com> Date: Wed, 9 Oct 2024 12:55:04 +0800 Subject: [PATCH] update --- script/command/pull-digital-lsp.py | 41 ++++++++++++++++++++++++++++++ src/function/lsp-client/index.ts | 14 +++++++--- src/function/sim/simulate.ts | 7 ++++- src/hdlParser/core.ts | 12 +++++++-- 4 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 script/command/pull-digital-lsp.py diff --git a/script/command/pull-digital-lsp.py b/script/command/pull-digital-lsp.py new file mode 100644 index 0000000..52e5cd0 --- /dev/null +++ b/script/command/pull-digital-lsp.py @@ -0,0 +1,41 @@ +import tarfile +import os + +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument('--version', default='0.4.0') +args = parser.parse_args() +version_string = args.version + +def compress_to_tar_gz(source_dir, output_filename): + with tarfile.open(output_filename, "w:gz") as tar: + if os.path.isdir(source_dir): + # 如果是目录,递归添加目录中的所有文件 + for root, dirs, files in os.walk(source_dir): + for file in files: + file_path = os.path.join(root, file) + arcname = os.path.relpath(file_path, source_dir) + tar.add(file_path, arcname=arcname) + else: + # 如果是文件,直接添加文件 + tar.add(source_dir, arcname=os.path.basename(source_dir)) + +os.system('scp -P 8024 dide@nc-ai.cn:/home/dide/project/digital-lsp-server/target/release/digital-lsp digital-lsp') +compress_to_tar_gz('digital-lsp', f'digital-lsp_{version_string}_linux_amd64.tar.gz') + +os.system('scp -P 8024 dide@nc-ai.cn:/home/dide/project/digital-lsp-server/target/aarch64-unknown-linux-gnu/release/digital-lsp digital-lsp') +compress_to_tar_gz('digital-lsp', f'digital-lsp_{version_string}_linux_aarch64.tar.gz') + +os.system('scp -P 8024 dide@nc-ai.cn:/home/dide/project/digital-lsp-server/target/x86_64-pc-windows-gnu/release/digital-lsp.exe digital-lsp.exe') +compress_to_tar_gz('digital-lsp.exe', f'digital-lsp_{version_string}_windows_amd64.tar.gz') + +os.system('scp -P 8024 dide@nc-ai.cn:/home/dide/project/digital-lsp-server/target/aarch64-pc-windows-msvc/release/digital-lsp.exe digital-lsp.exe') +compress_to_tar_gz('digital-lsp.exe', f'digital-lsp_{version_string}_windows_aarch64.tar.gz') + +os.system('scp -P 8024 dide@nc-ai.cn:/home/dide/project/digital-lsp-server/target/x86_64-apple-darwin/release/digital-lsp digital-lsp') +compress_to_tar_gz('digital-lsp', f'digital-lsp_{version_string}_darwin_amd64.tar.gz') + +os.system('scp -P 8024 dide@nc-ai.cn:/home/dide/project/digital-lsp-server/target/aarch64-apple-darwin/release/digital-lsp digital-lsp') +compress_to_tar_gz('digital-lsp', f'digital-lsp_{version_string}_darwin_aarch64.tar.gz') + diff --git a/src/function/lsp-client/index.ts b/src/function/lsp-client/index.ts index 8384ed0..61e0ed6 100644 --- a/src/function/lsp-client/index.ts +++ b/src/function/lsp-client/index.ts @@ -14,7 +14,7 @@ import { platform } from "os"; import { IProgress, LspClient } from '../../global'; import axios, { AxiosResponse } from "axios"; import { chooseBestDownloadSource, getGiteeDownloadLink, getGithubDownloadLink, getPlatformPlatformSignature } from "./cdn"; -import { hdlDir } from "../../hdlFs"; +import { hdlDir, hdlPath } from "../../hdlFs"; function getLspServerExecutionName() { const osname = platform(); @@ -39,7 +39,13 @@ function extractTarGz(filePath: string, outputDir: string): Promise { inputStream.pipe(gunzip).pipe(extract); return new Promise((resolve, reject) => { - extract.on('finish', resolve); + extract.on('finish', () => { + for (const file of fs.readdirSync(outputDir)) { + const filePath = hdlPath.join(outputDir, file); + fs.chmodSync(filePath, '755'); + } + resolve(); + }); extract.on('error', reject); }) } @@ -104,7 +110,9 @@ export async function downloadLsp(context: vscode.ExtensionContext, version: str }, reportInterval); const signature = getPlatformPlatformSignature().toString(); - const downloadLink = await chooseBestDownloadSource(signature, version, timeout); + const downloadLink = await chooseBestDownloadSource(signature, version, timeout); + console.log('choose download link: ' + downloadLink); + clearInterval(intervalHandler); return downloadLink }); diff --git a/src/function/sim/simulate.ts b/src/function/sim/simulate.ts index 339d062..fdf6d68 100644 --- a/src/function/sim/simulate.ts +++ b/src/function/sim/simulate.ts @@ -231,7 +231,7 @@ class IcarusSimulate extends Simulate { const simLibPaths = this.getSimLibArr(this.toolChain); - const macroIncludeArgs = this.makeMacroIncludeArguments(iverilogCompileOptions.includes); + const macroIncludeArgs = this.makeMacroIncludeArguments(iverilogCompileOptions.includes); const dependenceArgs = this.makeDependenceArguments(dependences); const thirdLibraryArgs = this.makeThirdLibraryArguments(simLibPaths); @@ -244,6 +244,11 @@ class IcarusSimulate extends Simulate { const outVvpPath = makeSafeArgPath(hdlPath.join(simConfig.simulationHome, 'out.vvp')); const mainPath = makeSafeArgPath(path); + // console.log(macroIncludeArgs); + // console.log(thirdLibraryDirArgs); + // console.log(dependenceArgs); + // console.log(thirdLibraryFileArgs); + const cmd = `${iverilogPath} ${argu} -o ${outVvpPath} -s ${name} ${macroIncludeArgs} ${thirdLibraryDirArgs} ${mainPath} ${dependenceArgs} ${thirdLibraryFileArgs}`; MainOutput.report(cmd, ReportType.Run); return cmd; diff --git a/src/hdlParser/core.ts b/src/hdlParser/core.ts index 345ba68..cbacfba 100644 --- a/src/hdlParser/core.ts +++ b/src/hdlParser/core.ts @@ -179,7 +179,7 @@ class HdlParam { } else if (status === common.InstModPathStatus.Others && inst.instModPath) { dependencies.others.push(inst.instModPath); } - const instDependencies = this.getAllDependences(inst.module.path, inst.module.name); + const instDependencies = this.getAllDependences(inst.module.path, inst.module.name); if (instDependencies) { dependencies.current.push(...instDependencies.current); dependencies.include.push(...instDependencies.include); @@ -561,7 +561,7 @@ class HdlModule { const instModName = rawHdlInstance.type; if (this.languageId === HdlLangID.Verilog || this.languageId === HdlLangID.SystemVerilog) { - const searchResult = this.searchInstModPath(instModName); + const searchResult = this.searchInstModPath(instModName); const hdlInstance = new HdlInstance(rawHdlInstance.name, rawHdlInstance.type, searchResult.path, @@ -643,6 +643,11 @@ class HdlModule { } } + /** + * @description 计算出当前 instance 和父组件的 包含关系 + * @param instModName instance 的名字 + * @returns InstModPathSearchResult + */ private searchInstModPath(instModName: string): common.InstModPathSearchResult { // search path of instance // priority: "current file" -> "included files" -> "other hdls in the project" @@ -661,7 +666,10 @@ class HdlModule { // search included file for (const include of this.file.macro.includes) { const absIncludePath = hdlPath.rel2abs(this.path, include.path); + console.log(absIncludePath); const includeFile = hdlParam.getHdlFile(absIncludePath); + console.log(includeFile); + if (includeFile) { excludeFile.add(includeFile); if (includeFile.hasHdlModule(instModName)) {