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

Function extract_source_dirs

tools/targets/vsc.py:85–110  ·  view source on GitHub ↗
(compile_commands)

Source from the content-addressed store, hash-verified

83 print_tree(subtree, indent + ' ')
84
85def extract_source_dirs(compile_commands):
86 source_dirs = set()
87
88 for entry in compile_commands:
89 file_path = os.path.abspath(entry['file'])
90
91 if file_path.endswith('.c'):
92 dir_path = os.path.dirname(file_path)
93 source_dirs.add(dir_path)
94 # command or arguments
95 command = entry.get('command') or entry.get('arguments')
96
97 if isinstance(command, str):
98 parts = command.split()
99 else:
100 parts = command
101 # 读取-I或者/I
102 for i, part in enumerate(parts):
103 if part.startswith('-I'):
104 include_dir = part[2:] if len(part) > 2 else parts[i + 1]
105 source_dirs.add(os.path.abspath(include_dir))
106 elif part.startswith('/I'):
107 include_dir = part[2:] if len(part) > 2 else parts[i + 1]
108 source_dirs.add(os.path.abspath(include_dir))
109
110 return sorted(source_dirs)
111
112
113def is_path_in_tree(path, tree):

Callers 1

Calls 2

setFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected