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

Function command_json_to_workspace

tools/targets/vsc.py:163–195  ·  view source on GitHub ↗
(root_path,command_json_path)

Source from the content-addressed store, hash-verified

161 print(f'Workspace file {workspace_filename} created.')
162
163def command_json_to_workspace(root_path,command_json_path):
164
165 with open('build/compile_commands.json', 'r') as f:
166 compile_commands = json.load(f)
167
168 source_dirs = extract_source_dirs(compile_commands)
169 tree = build_tree(source_dirs)
170 #print_tree(tree)
171 filtered_tree = filt_tree(tree)
172 print("Filtered Directory Tree:")
173 #print_tree(filtered_tree)
174
175 # 打印filtered_tree的root节点的相对路径
176 root_key = list(filtered_tree.keys())[0]
177 print(f"Root node relative path: {root_key}")
178
179 # 初始化exclude_fold集合
180 exclude_fold = set()
181
182 # os.chdir(root_path)
183 # 轮询root文件夹下面的每一个文件夹和子文件夹
184 for root, dirs, files in os.walk(root_path):
185 # 检查当前root是否在filtered_tree中
186 if not is_path_in_tree(root, filtered_tree):
187 exclude_fold.add(root)
188 dirs[:] = [] # 不往下轮询子文件夹
189 continue
190 for dir in dirs:
191 dir_path = os.path.join(root, dir)
192 if not is_path_in_tree(dir_path, filtered_tree):
193 exclude_fold.add(dir_path)
194
195 generate_code_workspace_file(exclude_fold,command_json_path,root_path)
196
197def delete_repeatelist(data):
198 temp_dict = set([str(item) for item in data])

Callers 1

GenerateCFilesFunction · 0.85

Calls 9

extract_source_dirsFunction · 0.85
build_treeFunction · 0.85
filt_treeFunction · 0.85
is_path_in_treeFunction · 0.85
walkMethod · 0.80
openFunction · 0.50
setFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected