diff --git a/tools/toolchains/gcc.py b/tools/toolchains/gcc.py index 46d9f1a23d..718eabfe30 100644 --- a/tools/toolchains/gcc.py +++ b/tools/toolchains/gcc.py @@ -15,7 +15,8 @@ See the License for the specific language governing permissions and limitations under the License. """ import re -from os.path import join, basename, splitext, dirname +from os.path import join, basename, splitext, dirname, exists +from distutils.spawn import find_executable from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS from tools.hooks import hook_tool @@ -285,7 +286,15 @@ class GCC(mbedToolchain): """Returns True if the executable (arm-none-eabi-gcc) location specified by the user exists OR the executable can be found on the PATH. Returns False otherwise.""" - return mbedToolchain.generic_check_executable("GCC_ARM", 'arm-none-eabi-gcc', 1) + if not TOOLCHAIN_PATHS['GCC_ARM'] or not exists(TOOLCHAIN_PATHS['GCC_ARM']): + if find_executable('arm-none-eabi-gcc'): + TOOLCHAIN_PATHS['GCC_ARM'] = '' + return True + else: + return False + else: + exec_name = join(TOOLCHAIN_PATHS['GCC_ARM'], 'arm-none-eabi-gcc') + return exists(exec_name) or exists(exec_name + '.exe') class GCC_ARM(GCC): pass