forked from platformio/platformio-core
Significantly improve "Project Generator" // Resolve #280
This commit is contained in:
@@ -376,3 +376,29 @@ def get_frameworks(type_=None):
|
||||
return frameworks[type_]
|
||||
|
||||
return frameworks
|
||||
|
||||
|
||||
def where_is_program(program, envpath=None):
|
||||
env = os.environ
|
||||
if envpath:
|
||||
env['PATH'] = envpath
|
||||
|
||||
# try OS's built-in commands
|
||||
try:
|
||||
result = exec_command(
|
||||
["where" if "windows" in get_systype() else "which", program],
|
||||
env=env
|
||||
)
|
||||
if result['returncode'] == 0 and isfile(result['out'].strip()):
|
||||
return result['out'].strip()
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# look up in $PATH
|
||||
for bin_dir in env.get("PATH", "").split(os.pathsep):
|
||||
if isfile(join(bin_dir, program)):
|
||||
return join(bin_dir, program)
|
||||
elif isfile(join(bin_dir, "%s.exe" % program)):
|
||||
return join(bin_dir, "%s.exe" % program)
|
||||
|
||||
return program
|
||||
|
Reference in New Issue
Block a user