MCPcopy Create free account
hub / github.com/Samsung/UTopia / BuildParser

Class BuildParser

helper/buildparser.py:86–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84
85
86class BuildParser:
87 def __init__(self, path: Path, buildpath: Path):
88
89 self.path = path.resolve()
90 self.buildpath = buildpath.resolve()
91 assert self.path.is_absolute()
92 assert self.buildpath.is_absolute()
93 assert self.output_dir.exists()
94 assert self.build_log_path.exists()
95 assert self.buildpath.exists()
96
97 @property
98 def output_dir(self) -> Path:
99 return self.path / "output"
100
101 @property
102 def build_db_dir(self) -> Path:
103 return self.output_dir / "build_db"
104
105 @property
106 def build_log_path(self) -> Path:
107 return self.output_dir / "build.log"
108
109 def parse(self, real: bool = True) -> Tuple[Dict, Dict, Dict, Dict]:
110 with open(self.build_log_path) as f:
111 lines = f.read().replace("\\\n", "").split("\n")
112
113 compiles, links, assems = [], [], []
114 for line in lines:
115 if not line:
116 continue
117 command = self.parse_command(line)
118 if command.is_link():
119 links.append(command)
120 else:
121 compiles.append(command)
122 if command.is_assemble():
123 assems.append(command)
124
125 srcs = dict()
126 for cmd in compiles:
127 for src in cmd.sources(True):
128 srcs[src] = cmd
129
130 compiles = {
131 compile_cmd.output(real): compile_cmd for compile_cmd in compiles
132 }
133 links = {link_cmd.output(real): link_cmd for link_cmd in links}
134 assems = {assem_cmd.output(real): assem_cmd for assem_cmd in assems}
135
136 return srcs, compiles, links, assems
137
138 def parse_command(self, captured_command: str) -> CMD:
139 tokens = [
140 token.strip()
141 for token in captured_command.split("|autofuzz_splitter|")
142 if token.strip()
143 ]

Callers 2

build_ast_irFunction · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected