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

Method replace_link_lib

helper/driverbuilder.py:225–244  ·  view source on GitHub ↗
(self, cmd: str, libname: str, opt: str)

Source from the content-addressed store, hash-verified

223
224 # Heuristics
225 def replace_link_lib(self, cmd: str, libname: str, opt: str) -> str:
226 archive = f"{libname}.a"
227 patterns = ["-l" + libname[3:], archive]
228 tokens = cmd.split()
229 place = set()
230
231 for i, token in enumerate(tokens):
232 if Path(token).name == archive or token in patterns:
233 place.add(i)
234
235 if not place:
236 raise RuntimeError("Not Found Link Option [ " + cmd + " ]")
237
238 place = sorted(place)
239 tokens[place[0]] = opt
240
241 for index in reversed(place[1:]):
242 del tokens[index]
243
244 return " ".join(tokens)
245
246
247def prepare_git(git: Git, name: str, dst: Path, src: Path):

Callers 1

get_link_cmdMethod · 0.95

Calls 2

PathClass · 0.50
addMethod · 0.45

Tested by

no test coverage detected