Skip to content

Commit b81d73e

Browse files
authored
tools: add clangd support (#9772)
* tools: add clangd support * [tools] use pip install scons * [tools/vsc] fix path for in windows and linux
1 parent 4125582 commit b81d73e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.devcontainer/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apt-get update
99

1010
RUN apt-get upgrade -y
1111

12-
RUN apt-get install -y vim git wget python3 python-is-python3 pip gcc-arm-none-eabi scons libncurses5-dev
12+
RUN apt-get install -y vim git wget python3 python-is-python3 pip gcc-arm-none-eabi libncurses5-dev
1313

1414
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y qemu-system-arm
1515

@@ -34,7 +34,7 @@ RUN git clone https://github.com/RT-Thread/packages.git /root/.env/packages/pack
3434

3535
ENV PATH="/root/.env/tools/scripts:$PATH"
3636

37-
RUN pip install requests psutil kconfiglib tqdm -qq
37+
RUN pip install scons requests psutil kconfiglib tqdm -qq
3838

3939
ENV RTT_EXEC_PATH=/usr/bin
4040

tools/vsc.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,17 @@ def GenerateCFiles(env):
108108
target_path_list = []
109109
for path in path_list:
110110
if path['path'] != '.':
111-
path['name'] = 'rtthread/' + '/'.join([p for p in path['path'].split('\\') if p != '..'])
111+
normalized_path = path['path'].replace('\\', os.path.sep)
112+
segments = [p for p in normalized_path.split(os.path.sep) if p != '..']
113+
path['name'] = 'rtthread/' + '/'.join(segments)
112114
json_obj['folders'] = path_list
115+
if os.path.exists('compile_commands.json'):
116+
json_obj['settings'] = {
117+
"clangd.arguments": [
118+
"--compile-commands-dir=.",
119+
"--header-insertion=never"
120+
]
121+
}
113122
vsc_space_file.write(json.dumps(json_obj, ensure_ascii=False, indent=4))
114123
vsc_space_file.close()
115124
return

0 commit comments

Comments
 (0)