MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / generate_code_workspace_file

Function generate_code_workspace_file

tools/targets/vsc.py:129–161  ·  view source on GitHub ↗
(source_dirs,command_json_path,root_path)

Source from the content-addressed store, hash-verified

127
128
129def generate_code_workspace_file(source_dirs,command_json_path,root_path):
130 current_working_directory = os.getcwd()
131 current_folder_name = os.path.basename(current_working_directory)
132
133 relative_dirs = []
134 for dir_path in source_dirs:
135 try:
136 rel_path = os.path.relpath(dir_path, root_path)
137 relative_dirs.append(rel_path)
138 except ValueError:
139 continue
140
141 root_rel_path = os.path.relpath(root_path, current_working_directory)
142 command_json_path = os.path.relpath(current_working_directory, root_path) + os.sep
143 workspace_data = {
144 "folders": [
145 {
146 "path": f"{root_rel_path}"
147 }
148 ],
149 "settings": {
150 "clangd.arguments": [
151 f"--compile-commands-dir={command_json_path}",
152 "--header-insertion=never"
153 ],
154 "files.exclude": {dir.replace('\\','/'): True for dir in sorted(relative_dirs)}
155 }
156 }
157 workspace_filename = f'{current_folder_name}.code-workspace'
158 with open(workspace_filename, 'w') as f:
159 json.dump(workspace_data, f, indent=4)
160
161 print(f'Workspace file {workspace_filename} created.')
162
163def command_json_to_workspace(root_path,command_json_path):
164

Callers 1

Calls 2

openFunction · 0.50
dumpMethod · 0.45

Tested by

no test coverage detected