Skip to content

fix: support hcpu/lcpu project entry for run triggers#26

Merged
HalfSweet merged 2 commits intomainfrom
fix-project
Mar 3, 2026
Merged

fix: support hcpu/lcpu project entry for run triggers#26
HalfSweet merged 2 commits intomainfrom
fix-project

Conversation

@HalfSweet
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings February 11, 2026 09:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates project path resolution so build/run-related features work when the project’s SConscript lives under project/hcpu or project/lcpu (instead of only project/).

Changes:

  • Add LCPU_SUBFOLDER constant and extend project detection to locate SConscript under project/hcpu, project/lcpu, or project/.
  • Extend getProjectInfo() to return the resolved project entry path (absolute + workspace-relative).
  • Update terminal cd behavior, board command generation, and clangd config generation to use the resolved project entry path.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/projectUtils.ts Adds workspace root helper and logic to resolve the effective project entry directory based on where SConscript is found.
src/services/terminalService.ts Uses resolved project entry path when cd-ing the terminal into the project.
src/services/boardService.ts Uses resolved project entry path/relative path for build folder and board search path computations.
src/constants/index.ts Adds LCPU_SUBFOLDER = 'lcpu'.
src/commands/configCommands.ts Builds clangd --compile-commands-dir using the resolved project entry relative path.
Comments suppressed due to low confidence (2)

src/services/boardService.ts:166

  • projectPath falls back to an empty string when getProjectInfo() returns null. That makes subsequent path.relative(projectPath, ...) calculations use the process CWD (Node treats "" as "."), which can generate incorrect --board_search_path values for project_local/custom boards. Use a deterministic fallback (e.g. ${workspaceRoot}/project) or return/throw when projectInfo is missing so path.relative always has a valid base path.
    const projectInfo = getProjectInfo();
    const projectPath = projectInfo?.projectEntryPath || '';

    let boardSearchArg = '';
    const availableBoards = await this.discoverBoards();
    const currentBoard = availableBoards.find(b => b.name === boardName);

    if (currentBoard) {
      if (currentBoard.type === 'sdk') {
        boardSearchArg = '';
      } else if (currentBoard.type === 'project_local') {
        const projectLocalBoardsDir = path.dirname(currentBoard.path);
        const relativeToProject = path.relative(projectPath, projectLocalBoardsDir);
        boardSearchArg = ` --board_search_path="${relativeToProject}"`;
      } else if (currentBoard.type === 'custom') {
        const relativeToProject = path.relative(projectPath, currentBoard.path);
        boardSearchArg = ` --board_search_path="${path.dirname(relativeToProject)}"`;

src/services/boardService.ts:192

  • Same issue as getCompileCommand: falling back to projectPath = '' makes path.relative(projectPath, ...) compute relative paths from the process CWD, producing incorrect --board_search_path values when projectInfo is null. Prefer a deterministic fallback base path (workspaceRoot/project) or fail early if no project can be resolved.
    const projectInfo = getProjectInfo();
    const projectPath = projectInfo?.projectEntryPath || '';

    let boardSearchArg = '';
    const availableBoards = await this.discoverBoards();
    const currentBoard = availableBoards.find(b => b.name === boardName);

    if (currentBoard && currentBoard.type !== 'sdk') {
      if (currentBoard.type === 'project_local') {
        const projectLocalBoardsDir = path.dirname(currentBoard.path);
        const relativeToProject = path.relative(projectPath, projectLocalBoardsDir);
        boardSearchArg = ` --board_search_path="${relativeToProject}"`;
      } else if (currentBoard.type === 'custom') {
        const relativeToProject = path.relative(projectPath, currentBoard.path);
        boardSearchArg = ` --board_search_path="${path.dirname(relativeToProject)}"`;
      }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/projectUtils.ts
Copy link
Copy Markdown
Collaborator

@livewithme livewithme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以修改一下

Comment thread src/services/boardService.ts Outdated
Comment thread src/services/boardService.ts Outdated
Comment thread src/services/terminalService.ts Outdated
Copy link
Copy Markdown
Collaborator

@livewithme livewithme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

未发现问题

@HalfSweet HalfSweet merged commit 9885f8b into main Mar 3, 2026
4 checks passed
@HalfSweet HalfSweet deleted the fix-project branch March 3, 2026 11:31
livewithme pushed a commit that referenced this pull request Mar 4, 2026
* fix: support hcpu/lcpu project entry for run triggers

Co-authored-by: bakacai <bakacai@outlook.com>
livewithme pushed a commit that referenced this pull request Mar 17, 2026
* fix: support hcpu/lcpu project entry for run triggers

Co-authored-by: bakacai <bakacai@outlook.com>
livewithme pushed a commit that referenced this pull request Mar 17, 2026
* fix: support hcpu/lcpu project entry for run triggers

Co-authored-by: bakacai <bakacai@outlook.com>
livewithme added a commit that referenced this pull request Mar 20, 2026
* fix: support hcpu/lcpu project entry for run triggers (#26)

* fix: support hcpu/lcpu project entry for run triggers

Co-authored-by: bakacai <bakacai@outlook.com>

* feat: 添加编译,文件是否保存检查

* chore: 添加遗漏的Save Dialog Alert 文本

* fix: 2 conversation advice

* refactor(save-check): 重构保存检查的二次弹窗逻辑

* chore: 删除不记住

* chore: 回退 boardService

* chore: rebase 之后功能修复,构建也需要检测时候保存

* fix: 修复QuickPick buildWithCheck 错误

* optimize: 1. 选择保存当前文件情况下,如果存在多个文件未保存,弹出选项给用户选择,2. 只有一个文件未保存的情况下,将焦点且到未保存文件,再进行保存

* optimize: 优化添加项目配置管理方式 设置构建保存偏好

* chore: 把构建保存配置到外层

---------

Co-authored-by: luyaoyao <382708508@qq.com>
Co-authored-by: bakacai <bakacai@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants