Commit 978dd1cf authored by Ximin Luo's avatar Ximin Luo

Only check "g" prefix for a certain whitelist set of commands

parent 54d4bb1a
......@@ -152,6 +152,10 @@ EXTERNAL_TOOLS = {
'debian': 'binutils-multiarch',
'arch': 'binutils',
'objcopy': {
'debian': 'binutils-multiarch',
'arch': 'binutils',
'objdump': {
'debian': 'binutils-multiarch',
'arch': 'binutils',
......@@ -256,3 +260,17 @@ EXTERNAL_TOOLS = {
# readelf -> arm-none-eabi-readelf, etc
# diff -> gdiff, etc
# GNU programs whose names differ on some non-GNU systems such as FreeBSD etc
# AND where the CLI or output of the programs differ from the non-GNU system
# versions. In these cases, add them here and make sure you wrap uses of them
# in get_tool_name() to pick up the alternate names.
# If we only use POSIX CLI options and the output is identical to the system
# version (so that our tests don't break) then it's unnecessary to add it here.
......@@ -29,7 +29,7 @@ except ImportError:
from distutils.spawn import find_executable
from .profiling import profile
from .external_tools import EXTERNAL_TOOLS, REMAPPED_TOOL_NAMES
# Memoize calls to ``distutils.spawn.find_executable`` to avoid excessive stat
# calls
......@@ -75,7 +75,7 @@ def tool_required(command):
This ensures that any os.environ['PATH'] modifications are
performed prior to the `find_executable` tests.
if command == get_tool_name(command) and not os_is_gnu():
if command == get_tool_name(command) and not os_is_gnu() and tool_is_gnu(command):
# try "g" + command for each tool, if we're on a non-GNU system
if find_executable("g" + command):
tool_prepend_prefix("g", command)
......@@ -88,6 +88,9 @@ def tool_required(command):
return tool_check
return wrapper
def tool_is_gnu(command):
return command in GNU_TOOL_NAMES
def os_is_gnu():
system = platform.system()
return system in ("Linux", "GNU") or system.startswith("GNU/")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment