Skip to content

Commit 3eec9a4

Browse files
committed
build(bootstrap): find_tool also looks at prefixes
1 parent b2e623c commit 3eec9a4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

bootstrap.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,26 @@ def reg_lookup(base, subkey):
684684
return None
685685

686686
def find_tool(self, tool):
687+
# Environment variable {tool}_ROOT and {tool}_DIR
688+
env_suffixes = ["ROOT", "DIR", "PATH", "HOME", "INSTALL_DIR", "EXECUTABLE"]
689+
env_prefixes = [tool.upper(), tool.lower(), tool.title()]
690+
for env_prefix in env_prefixes:
691+
for env_suffix in env_suffixes:
692+
env_var = f"{env_prefix}_{env_suffix}"
693+
env_path = os.environ.get(env_var)
694+
if env_path and os.path.exists(env_path):
695+
if self.is_executable(env_path):
696+
return env_path
697+
if os.path.isdir(env_path):
698+
tool_filename = tool if tool.endswith(".exe") else tool + ".exe"
699+
tool_path = os.path.join(env_path, tool_filename)
700+
if self.is_executable(tool_path):
701+
return tool_path
702+
tool_bin_path = os.path.join(env_path, 'bin', tool_filename)
703+
if self.is_executable(tool_bin_path):
704+
return tool_bin_path
705+
706+
# Look for the tool in the system PATH and special cases for Windows
687707
tool_path = shutil.which(tool)
688708
if not tool_path and self.is_windows():
689709
tool_path = self.find_vs_tool(tool)

0 commit comments

Comments
 (0)