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

Method normalize_command

helper/buildparser.py:170–203  ·  view source on GitHub ↗
(self, cmd: str)

Source from the content-addressed store, hash-verified

168 json.dump(data, f)
169
170 def normalize_command(self, cmd: str) -> str:
171 cmd_pattern = re.compile(r"(ar|llvm-ar|llvm-ar-10|clang|clang\+\+) ")
172 unnecessary_opts = {
173 "-O4",
174 "-O3",
175 "-O2",
176 "-O1",
177 "-Og",
178 "-Os",
179 "-Oz",
180 "-Ofast",
181 "-O0",
182 "-O",
183 "-DNDEBUG",
184 "-fno-exceptions",
185 "-std=gnu99",
186 }
187
188 cmd = cmd[cmd_pattern.search(cmd).start() :]
189 tokens = []
190 for token in cmd.split():
191 token = token.strip()
192 if (
193 not token
194 or token in unnecessary_opts
195 or token.startswith("-Werror")
196 or token.startswith("-fsanitize")
197 ):
198 continue
199 if token.startswith("&&"):
200 tokens.clear()
201 tokens.append(token)
202
203 return " ".join(tokens)

Callers 1

parse_commandMethod · 0.95

Calls 3

compileMethod · 0.45
startMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected