-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[vscode] Add VSCode workspace generation for vscode_extension. #10462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 introduces a dedicated VSCode workspace generator for the vscode_extension
, adding support for .vscode/c_cpp_properties.json
and .vscode/settings.json
, and wiring it into the SCons build workflow as a new vsc_workspace
target.
- Added
GenerateVSCodeWorkspace
and helperfind_rtconfig_dirs
intools/targets/vsc.py
- Updated CLI options to include
vsc_workspace
intools/options.py
- Registered the new
vsc_workspace
SCons target intools/building.py
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
tools/targets/vsc.py | New workspace generation functions; output of C/C++ properties and settings JSON |
tools/options.py | Extended --target help to list vsc_workspace |
tools/building.py | Exported default env and added vsc_workspace target handler |
Comments suppressed due to low confidence (1)
tools/targets/vsc.py:338
- Docstring claims 'up to 4 levels deep' but the implementation only looks at immediate children and their parent. Update the doc or implement deeper recursion to match.
Search for subdirectories containing 'rtconfig.h' under 'bsp_dir' (up to 4 levels deep), excluding 'project_dir'.
list = os.listdir(bsp_dir) | ||
for item in list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Variable name 'list' shadows the built-in type. Rename it (e.g., to 'entries' or 'items') to avoid confusion.
list = os.listdir(bsp_dir) | |
for item in list: | |
entries = os.listdir(bsp_dir) | |
for item in entries: |
Copilot uses AI. Check for mistakes.
bsp_dir = os.path.join(cwd, workspace_data.get('bsps', {}).get('folder', '')) | ||
if not bsp_dir: | ||
print('No BSP directories found in the workspace file, skip generating.') | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check never triggers because os.path.join(cwd, '')
returns cwd
, not an empty string. Consider verifying the 'folder' key exists or use os.path.exists
to detect missing BSP directory.
bsp_dir = os.path.join(cwd, workspace_data.get('bsps', {}).get('folder', '')) | |
if not bsp_dir: | |
print('No BSP directories found in the workspace file, skip generating.') | |
return | |
folder = workspace_data.get('bsps', {}).get('folder') | |
if not folder: | |
print('No BSP folder specified in the workspace file, skip generating.') | |
return | |
bsp_dir = os.path.join(cwd, folder) | |
if not os.path.exists(bsp_dir): | |
print(f'BSP directory "{bsp_dir}" does not exist, skip generating.') | |
return |
Copilot uses AI. Check for mistakes.
except Exception as e: | ||
print('Error reading workspace file, skip generating.') | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching the base Exception silently may mask errors. Catch more specific exceptions (e.g., IOError
, json.JSONDecodeError
) or log the exception details for easier debugging.
except Exception as e: | |
print('Error reading workspace file, skip generating.') | |
return | |
except FileNotFoundError as e: | |
print(f'Workspace file not found: {e}, skip generating.') | |
return | |
except json.JSONDecodeError as e: | |
print(f'Error decoding JSON from workspace file: {e}, skip generating.') | |
return |
Copilot uses AI. Check for mistakes.
这个太可以了 |
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
当使用vscode(及扩展)打开RT-Thread目录时,可以生成一定的类workspace配置,只关注感兴趣的bsp,把其他无关bsp自动排除。
你的解决方案是什么 (what is your solution)
在RT-Thread根目录下使用scons生成适合的配置。<注:若类似stm32这样的bsp,需要自行先解决
pkgs --update
的问题>请提供验证的bsp和config (provide the config and bsp)
pkgs --update
更新>]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up