1
0
Эх сурвалжийг харах

tools: add clangd support (#9772)

* tools: add clangd support
* [tools] use pip install scons
* [tools/vsc] fix path for in windows and linux
Supper Thomas 4 сар өмнө
parent
commit
b81d73e847
2 өөрчлөгдсөн 12 нэмэгдсэн , 3 устгасан
  1. 2 2
      .devcontainer/Dockerfile
  2. 10 1
      tools/vsc.py

+ 2 - 2
.devcontainer/Dockerfile

@@ -9,7 +9,7 @@ RUN apt-get update
 
 RUN apt-get upgrade -y
 
-RUN apt-get install -y vim git wget python3 python-is-python3 pip gcc-arm-none-eabi scons libncurses5-dev
+RUN apt-get install -y vim git wget python3 python-is-python3 pip gcc-arm-none-eabi libncurses5-dev
 
 RUN DEBIAN_FRONTEND=noninteractive apt-get install -y qemu-system-arm
 
@@ -34,7 +34,7 @@ RUN git clone https://github.com/RT-Thread/packages.git /root/.env/packages/pack
 
 ENV PATH="/root/.env/tools/scripts:$PATH"
 
-RUN pip install requests psutil kconfiglib tqdm -qq
+RUN pip install scons requests psutil kconfiglib tqdm -qq
 
 ENV RTT_EXEC_PATH=/usr/bin
 

+ 10 - 1
tools/vsc.py

@@ -108,8 +108,17 @@ def GenerateCFiles(env):
         target_path_list = []
         for path in path_list:
             if path['path'] != '.':
-                path['name'] = 'rtthread/' + '/'.join([p for p in path['path'].split('\\') if p != '..'])
+                normalized_path = path['path'].replace('\\', os.path.sep)
+                segments = [p for p in normalized_path.split(os.path.sep) if p != '..']
+                path['name'] = 'rtthread/' + '/'.join(segments)
         json_obj['folders'] = path_list
+        if os.path.exists('compile_commands.json'):
+            json_obj['settings'] = {
+            "clangd.arguments": [
+                "--compile-commands-dir=.",
+                "--header-insertion=never"
+            ]
+            }
         vsc_space_file.write(json.dumps(json_obj, ensure_ascii=False, indent=4))
         vsc_space_file.close()    
     return