MCPcopy Create free account
hub / github.com/boostorg/build / find_tool

Function find_tool

v2/tools/common.py:358–390  ·  view source on GitHub ↗

Attempts to find tool (binary) named 'name' in PATH and in 'additional-paths'. If found in path, returns 'name'. If found in additional paths, returns full name. If the tool is found in several directories, returns the first path found. Otherwise, returns the empt

(name, additional_paths = [], path_last = False)

Source from the content-addressed store, hash-verified

356
357# ported from trunk@47174
358def find_tool(name, additional_paths = [], path_last = False):
359 """ Attempts to find tool (binary) named 'name' in PATH and in
360 'additional-paths'. If found in path, returns 'name'. If
361 found in additional paths, returns full name. If the tool
362 is found in several directories, returns the first path found.
363 Otherwise, returns the empty string. If 'path_last' is specified,
364 path is checked after 'additional_paths'.
365 """
366 assert(isinstance(name, str))
367 assert(isinstance(additional_paths, list))
368 assert(isinstance(path_last, bool))
369
370 programs = path.programs_path()
371 match = path.glob(programs, [name, name + '.exe'])
372 additional_match = path.glob(additional_paths, [name, name + '.exe'])
373
374 result = []
375 if path_last:
376 result = additional_match
377 if not result and match:
378 result = match
379
380 else:
381 if match:
382 result = match
383
384 elif additional_match:
385 result = additional_match
386
387 if result:
388 return path.native(result[0])
389 else:
390 return ''
391
392#ported from trunk@47281
393def check_tool_aux(command):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected