From 5bfde4ee72e5ef4f59d97947f195189e1c3ed8ff Mon Sep 17 00:00:00 2001
From: Egor Tensin <Egor.Tensin@gmail.com>
Date: Fri, 7 May 2021 17:57:47 +0300
Subject: project.toolset: move _full_exe_name to utils

---
 project/toolset.py | 33 +++------------------------------
 project/utils.py   | 30 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/project/toolset.py b/project/toolset.py
index b9cb6c3..c0c771d 100644
--- a/project/toolset.py
+++ b/project/toolset.py
@@ -35,9 +35,9 @@ import os.path
 import shutil
 
 import project.mingw
-from project.os import on_cygwin, on_linux, on_windows
+from project.os import on_windows
 from project.platform import Platform
-from project.utils import temp_file
+from project.utils import full_exe_name, temp_file
 
 
 class MSVCVersion(Enum):
@@ -338,33 +338,6 @@ class MSVC(Toolset):
         return args
 
 
-def _full_exe_name(exe):
-    if on_linux():
-        # There's no PATHEXT on Linux.
-        return exe
-    # b2 on Windows/Cygwin doesn't like it when the executable name doesn't
-    # include the extension.
-    dir_path = os.path.dirname(exe) or None
-    path = shutil.which(exe, path=dir_path)
-    if not path:
-        raise RuntimeError(f"executable '{exe}' could not be found")
-    if on_cygwin():
-        # On Cygwin, shutil.which('gcc') == '/usr/bin/gcc' and shutil.which('gcc.exe')
-        # == '/usr/bin/gcc.exe'; we want the latter version.  shutil.which('clang++')
-        # == '/usr/bin/clang++' is fine though, since it _is_ the complete path
-        # (clang++ is a symlink).
-        if os.path.exists(path) and os.path.exists(path + '.exe'):
-            path += '.exe'
-    if dir_path:
-        # If it was found in a specific directory, include the directory in the
-        # result.  shutil.which returns the executable name prefixed with the
-        # path argument.
-        return path
-    # If it was found in PATH, just return the basename (which includes the
-    # extension).
-    return os.path.basename(path)
-
-
 class BoostCustom(Toolset):
     COMPILER_VERSION = 'custom'
 
@@ -375,7 +348,7 @@ class BoostCustom(Toolset):
         version = BoostCustom.COMPILER_VERSION
         self.version = version
         path = path or ''
-        path = path and _full_exe_name(path)
+        path = path and full_exe_name(path)
         self.path = path
         build_options = build_options or []
         self.build_options = build_options
diff --git a/project/utils.py b/project/utils.py
index 711db97..39dfb0d 100644
--- a/project/utils.py
+++ b/project/utils.py
@@ -7,11 +7,14 @@ from contextlib import contextmanager
 import functools
 import logging
 import os.path
+import shutil
 import subprocess
 import sys
 import tempfile
 import time
 
+from project.os import on_cygwin, on_linux
+
 
 def normalize_path(s):
     return os.path.abspath(os.path.normpath(s))
@@ -21,6 +24,33 @@ def mkdir_parent(path):
     os.makedirs(path, exist_ok=True)
 
 
+def full_exe_name(exe):
+    if on_linux():
+        # There's no PATHEXT on Linux.
+        return exe
+    # b2 on Windows/Cygwin doesn't like it when the executable name doesn't
+    # include the extension.
+    dir_path = os.path.dirname(exe) or None
+    path = shutil.which(exe, path=dir_path)
+    if not path:
+        raise RuntimeError(f"executable '{exe}' could not be found")
+    if on_cygwin():
+        # On Cygwin, shutil.which('gcc') == '/usr/bin/gcc' and shutil.which('gcc.exe')
+        # == '/usr/bin/gcc.exe'; we want the latter version.  shutil.which('clang++')
+        # == '/usr/bin/clang++' is fine though, since it _is_ the complete path
+        # (clang++ is a symlink).
+        if os.path.exists(path) and os.path.exists(path + '.exe'):
+            path += '.exe'
+    if dir_path:
+        # If it was found in a specific directory, include the directory in the
+        # result.  shutil.which returns the executable name prefixed with the
+        # path argument.
+        return path
+    # If it was found in PATH, just return the basename (which includes the
+    # extension).
+    return os.path.basename(path)
+
+
 @contextmanager
 def setup_logging():
     logging.basicConfig(
-- 
cgit v1.2.3