From 61dee45dcab6c341beb7fbb833442cd7d9cc33e0 Mon Sep 17 00:00:00 2001 From: Sarah Marsh Date: Mon, 12 Sep 2016 18:54:39 -0500 Subject: [PATCH 1/4] Revise checking toolchain path --- tools/build.py | 9 ++++++++- tools/make.py | 13 ++++++++++--- tools/test.py | 10 +++++++++- tools/toolchains/__init__.py | 20 -------------------- tools/toolchains/arm.py | 18 ++++++++++-------- tools/toolchains/gcc.py | 23 ++++++++++++++++++----- tools/toolchains/iar.py | 16 +++++++++------- 7 files changed, 64 insertions(+), 45 deletions(-) diff --git a/tools/build.py b/tools/build.py index d988a0a649..66f94fe0b0 100644 --- a/tools/build.py +++ b/tools/build.py @@ -27,7 +27,7 @@ ROOT = abspath(join(dirname(__file__), "..")) sys.path.insert(0, ROOT) -from tools.toolchains import TOOLCHAINS +from tools.toolchains import TOOLCHAINS, TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS from tools.toolchains import mbedToolchain from tools.targets import TARGET_NAMES, TARGET_MAP from tools.options import get_default_options_parser @@ -161,6 +161,7 @@ if __name__ == '__main__': print mcu_toolchain_matrix(platform_filter=options.general_filter_regex) exit(0) + # Get target list targets = options.mcu if options.mcu else TARGET_NAMES @@ -212,6 +213,12 @@ if __name__ == '__main__': # CPPCHECK code validation if options.cppcheck_validation: for toolchain in toolchains: + if not TOOLCHAIN_CLASSES[toolchain].check_executable(): + if TOOLCHAIN_PATHS[toolchain] == '': + TOOLCHAIN_PATHS[toolchain] = "No path set" + args_error(parser, "Could not find executable for %s.\n" + "Currently set search path: %s" + % (toolchain, TOOLCHAIN_PATHS[toolchain])) for target in targets: try: mcu = TARGET_MAP[target] diff --git a/tools/make.py b/tools/make.py index 0541d5e760..556b914487 100644 --- a/tools/make.py +++ b/tools/make.py @@ -21,7 +21,8 @@ TEST BUILD & RUN import sys from time import sleep from shutil import copy -from os.path import join, abspath, dirname, isfile, isdir +from os.path import join, abspath, dirname, exists +from distutils.spawn import find_executable # Be sure that the tools directory is in the search path ROOT = abspath(join(dirname(__file__), "..")) @@ -46,8 +47,7 @@ from tools.build_api import mcu_toolchain_matrix from utils import argparse_filestring_type from utils import argparse_many from utils import argparse_dir_not_parent -from argparse import ArgumentTypeError -from tools.toolchains import mbedToolchain +from tools.toolchains import mbedToolchain, TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS from tools.settings import CLI_COLOR_MAP if __name__ == '__main__': @@ -232,6 +232,13 @@ if __name__ == '__main__': else: notify = None + if not TOOLCHAIN_CLASSES[toolchain].check_executable(): + if TOOLCHAIN_PATHS[toolchain] == '': + TOOLCHAIN_PATHS[toolchain] = "No path set" + args_error(parser, "Could not find executable for %s.\n" + "Currently set search path: %s" + %(toolchain,TOOLCHAIN_PATHS[toolchain])) + # Test for test_no in p: test = Test(test_no) diff --git a/tools/test.py b/tools/test.py index 101af3fb33..491139d35b 100644 --- a/tools/test.py +++ b/tools/test.py @@ -35,7 +35,7 @@ from tools.utils import mkdir, ToolException, NotSupportedException, args_error from tools.test_exporters import ReportExporter, ResultExporterType from utils import argparse_filestring_type, argparse_lowercase_type, argparse_many from utils import argparse_dir_not_parent -from tools.toolchains import mbedToolchain +from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS, TOOLCHAIN_CLASSES from tools.settings import CLI_COLOR_MAP if __name__ == '__main__': @@ -115,6 +115,13 @@ if __name__ == '__main__': args_error(parser, "argument -t/--tool is required") toolchain = options.tool[0] + if not TOOLCHAIN_CLASSES[toolchain].check_executable(): + if TOOLCHAIN_PATHS[toolchain] == '': + TOOLCHAIN_PATHS[toolchain] = "No path set" + args_error(parser, "Could not find executable for %s.\n" + "Currently set search path: %s" + % (toolchain, TOOLCHAIN_PATHS[toolchain])) + # Find all tests in the relevant paths for path in all_paths: all_tests.update(find_tests(path, mcu, toolchain, options.options, @@ -196,6 +203,7 @@ if __name__ == '__main__': print "Failed to build library" else: # Build all the tests + test_build_success, test_build = build_tests(tests, [options.build_dir], options.build_dir, mcu, toolchain, options=options.options, clean=options.clean, diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index ed351006da..92f5f2e1f1 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -188,23 +188,6 @@ LEGACY_TOOLCHAIN_NAMES = { } -def check_toolchain_path(function): - """Check if the path to toolchain is valid. Exit if not. - Use this function as a decorator. Causes a system exit if the path does - not exist. Execute the function as normal if the path does exist. - - Positional arguments: - function -- the function to decorate - """ - def perform_check(self, *args, **kwargs): - if not exists(self.toolchain_path) and not exists(self.toolchain_path+'.exe'): - error_string = 'Could not find executable for %s.\n Currently ' \ - 'set search path: %s'% (self.name, self.toolchain_path) - raise Exception(error_string) - return function(self, *args, **kwargs) - return perform_check - - class mbedToolchain: # Verbose logging VERBOSE = True @@ -720,7 +703,6 @@ class mbedToolchain: # THIS METHOD IS BEING CALLED BY THE MBED ONLINE BUILD SYSTEM # ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY - @check_toolchain_path def compile_sources(self, resources, build_path, inc_dirs=None): # Web IDE progress bar for project build files_to_compile = resources.s_sources + resources.c_sources + resources.cpp_sources @@ -919,7 +901,6 @@ class mbedToolchain: else: raise ToolException(_stderr) - @check_toolchain_path def build_library(self, objects, dir, name): needed_update = False lib = self.STD_LIB_NAME % name @@ -931,7 +912,6 @@ class mbedToolchain: return needed_update - @check_toolchain_path def link_program(self, r, tmp_path, name): needed_update = False ext = 'bin' diff --git a/tools/toolchains/arm.py b/tools/toolchains/arm.py index a7ecc848a4..407d5374d5 100644 --- a/tools/toolchains/arm.py +++ b/tools/toolchains/arm.py @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. """ import re -from os.path import join, dirname, splitext, basename +from os.path import join, dirname, splitext, basename, exists from distutils.spawn import find_executable from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS @@ -42,6 +42,15 @@ class ARM(mbedToolchain): 'ld': [], } + @staticmethod + def check_executable(): + if not TOOLCHAIN_PATHS["ARM"] or not exists(TOOLCHAIN_PATHS['ARM']): + exe = find_executable('armcc') + if not exe: + return False + TOOLCHAIN_PATHS['ARM'] = dirname(dirname(exe)) + return True + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) @@ -56,11 +65,6 @@ class ARM(mbedToolchain): else: cpu = target.core - if not TOOLCHAIN_PATHS['ARM']: - exe = find_executable('armcc') - if exe: - TOOLCHAIN_PATHS['ARM'] = dirname(dirname(exe)) - ARM_BIN = join(TOOLCHAIN_PATHS['ARM'], "bin") ARM_INC = join(TOOLCHAIN_PATHS['ARM'], "include") @@ -86,8 +90,6 @@ class ARM(mbedToolchain): self.ar = join(ARM_BIN, "armar") self.elf2bin = join(ARM_BIN, "fromelf") - self.toolchain_path = TOOLCHAIN_PATHS['ARM'] - def parse_dependencies(self, dep_path): dependencies = [] for line in open(dep_path).readlines(): diff --git a/tools/toolchains/gcc.py b/tools/toolchains/gcc.py index 27bc11fede..c66b7c45c7 100644 --- a/tools/toolchains/gcc.py +++ b/tools/toolchains/gcc.py @@ -111,11 +111,6 @@ class GCC(mbedToolchain): self.ar = join(tool_path, "arm-none-eabi-ar") self.elf2bin = join(tool_path, "arm-none-eabi-objcopy") - if tool_path: - self.toolchain_path = main_cc - else: - self.toolchain_path = find_executable("arm-none-eabi-gcc") or '' - def parse_dependencies(self, dep_path): dependencies = [] buff = open(dep_path).readlines() @@ -275,6 +270,15 @@ class GCC(mbedToolchain): class GCC_ARM(GCC): + @staticmethod + def check_executable(): + if not TOOLCHAIN_PATHS["GCC_ARM"] or not exists(TOOLCHAIN_PATHS['GCC_ARM']): + exe = find_executable('arm-none-eabi-gcc') + if not exe: + return False + TOOLCHAIN_PATHS['GCC_ARM'] = dirname(exe) + return True + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_ARM'], extra_verbose=extra_verbose) @@ -300,6 +304,15 @@ class GCC_ARM(GCC): class GCC_CR(GCC): + @staticmethod + def check_executable(): + if not TOOLCHAIN_PATHS["GCC_CR"] or not exists(TOOLCHAIN_PATHS['GCC_CR']): + exe = find_executable('arm-none-eabi-gcc') + if not exe: + return False + TOOLCHAIN_PATHS['GCC_CR'] = dirname(exe) + return True + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_CR'], extra_verbose=extra_verbose) diff --git a/tools/toolchains/iar.py b/tools/toolchains/iar.py index ca41f845b2..fc7047b080 100644 --- a/tools/toolchains/iar.py +++ b/tools/toolchains/iar.py @@ -45,6 +45,15 @@ class IAR(mbedToolchain): 'ld': ["--skip_dynamic_initialization", "--threaded_lib"], } + @staticmethod + def check_executable(): + if not TOOLCHAIN_PATHS["IAR"] or not exists(TOOLCHAIN_PATHS['IAR']): + exe = find_executable('iccarm') + if not exe: + return False + TOOLCHAIN_PATHS['IAR'] = dirname(dirname(exe)) + return True + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) if target.core == "Cortex-M7F" or target.core == "Cortex-M7FD": @@ -52,11 +61,6 @@ class IAR(mbedToolchain): else: cpuchoice = target.core - if not TOOLCHAIN_PATHS['IAR']: - exe = find_executable('iccarm') - if exe: - TOOLCHAIN_PATHS['IAR'] = dirname(dirname(exe)) - # flags_cmd are used only by our scripts, the project files have them already defined, # using this flags results in the errors (duplication) # asm accepts --cpu Core or --fpu FPU, not like c/c++ --cpu=Core @@ -108,8 +112,6 @@ class IAR(mbedToolchain): self.ar = join(IAR_BIN, "iarchive") self.elf2bin = join(IAR_BIN, "ielftool") - self.toolchain_path = TOOLCHAIN_PATHS['IAR'] - def parse_dependencies(self, dep_path): return [(self.CHROOT if self.CHROOT else '')+path.strip() for path in open(dep_path).readlines() if (path and not path.isspace())] From 8b74c5b3c7badf41339d8c8ad7e327a9323ba77d Mon Sep 17 00:00:00 2001 From: Sarah Marsh Date: Tue, 13 Sep 2016 12:06:01 -0500 Subject: [PATCH 2/4] Docstrings. Empty executable search path handling. --- tools/build.py | 5 ++--- tools/make.py | 5 ++--- tools/test.py | 5 ++--- tools/toolchains/arm.py | 3 +++ tools/toolchains/gcc.py | 6 ++++++ tools/toolchains/iar.py | 3 +++ 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/tools/build.py b/tools/build.py index 66f94fe0b0..7915ed03a4 100644 --- a/tools/build.py +++ b/tools/build.py @@ -214,11 +214,10 @@ if __name__ == '__main__': if options.cppcheck_validation: for toolchain in toolchains: if not TOOLCHAIN_CLASSES[toolchain].check_executable(): - if TOOLCHAIN_PATHS[toolchain] == '': - TOOLCHAIN_PATHS[toolchain] = "No path set" + search_path = TOOLCHAIN_PATHS[toolchain] or "No path set" args_error(parser, "Could not find executable for %s.\n" "Currently set search path: %s" - % (toolchain, TOOLCHAIN_PATHS[toolchain])) + % (toolchain, search_path)) for target in targets: try: mcu = TARGET_MAP[target] diff --git a/tools/make.py b/tools/make.py index 556b914487..e8d5a06d8b 100644 --- a/tools/make.py +++ b/tools/make.py @@ -233,11 +233,10 @@ if __name__ == '__main__': notify = None if not TOOLCHAIN_CLASSES[toolchain].check_executable(): - if TOOLCHAIN_PATHS[toolchain] == '': - TOOLCHAIN_PATHS[toolchain] = "No path set" + search_path = TOOLCHAIN_PATHS[toolchain] or "No path set" args_error(parser, "Could not find executable for %s.\n" "Currently set search path: %s" - %(toolchain,TOOLCHAIN_PATHS[toolchain])) + %(toolchain,search_path)) # Test for test_no in p: diff --git a/tools/test.py b/tools/test.py index 491139d35b..5b8f9d97a3 100644 --- a/tools/test.py +++ b/tools/test.py @@ -116,11 +116,10 @@ if __name__ == '__main__': toolchain = options.tool[0] if not TOOLCHAIN_CLASSES[toolchain].check_executable(): - if TOOLCHAIN_PATHS[toolchain] == '': - TOOLCHAIN_PATHS[toolchain] = "No path set" + search_path = TOOLCHAIN_PATHS[toolchain] or "No path set" args_error(parser, "Could not find executable for %s.\n" "Currently set search path: %s" - % (toolchain, TOOLCHAIN_PATHS[toolchain])) + % (toolchain, search_path)) # Find all tests in the relevant paths for path in all_paths: diff --git a/tools/toolchains/arm.py b/tools/toolchains/arm.py index 407d5374d5..26f6441833 100644 --- a/tools/toolchains/arm.py +++ b/tools/toolchains/arm.py @@ -44,6 +44,9 @@ class ARM(mbedToolchain): @staticmethod def check_executable(): + """Returns True if the executable (armcc) location specified by the + user exists OR the executable can be found on the PATH. + Returns False otherwise.""" if not TOOLCHAIN_PATHS["ARM"] or not exists(TOOLCHAIN_PATHS['ARM']): exe = find_executable('armcc') if not exe: diff --git a/tools/toolchains/gcc.py b/tools/toolchains/gcc.py index c66b7c45c7..fc54c25dae 100644 --- a/tools/toolchains/gcc.py +++ b/tools/toolchains/gcc.py @@ -272,6 +272,9 @@ class GCC(mbedToolchain): class GCC_ARM(GCC): @staticmethod def check_executable(): + """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.""" if not TOOLCHAIN_PATHS["GCC_ARM"] or not exists(TOOLCHAIN_PATHS['GCC_ARM']): exe = find_executable('arm-none-eabi-gcc') if not exe: @@ -306,6 +309,9 @@ class GCC_ARM(GCC): class GCC_CR(GCC): @staticmethod def check_executable(): + """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.""" if not TOOLCHAIN_PATHS["GCC_CR"] or not exists(TOOLCHAIN_PATHS['GCC_CR']): exe = find_executable('arm-none-eabi-gcc') if not exe: diff --git a/tools/toolchains/iar.py b/tools/toolchains/iar.py index fc7047b080..01ac99846d 100644 --- a/tools/toolchains/iar.py +++ b/tools/toolchains/iar.py @@ -47,6 +47,9 @@ class IAR(mbedToolchain): @staticmethod def check_executable(): + """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.""" if not TOOLCHAIN_PATHS["IAR"] or not exists(TOOLCHAIN_PATHS['IAR']): exe = find_executable('iccarm') if not exe: From ab92a5ace20a1668b708a7de22f35132ca963368 Mon Sep 17 00:00:00 2001 From: Sarah Marsh Date: Tue, 13 Sep 2016 13:38:58 -0500 Subject: [PATCH 3/4] Toolchain check generic in mbedToolchain --- tools/make.py | 3 +-- tools/toolchains/__init__.py | 39 ++++++++++++++++++++++++++++++++++++ tools/toolchains/arm.py | 10 ++------- tools/toolchains/gcc.py | 17 +++------------- tools/toolchains/iar.py | 10 ++------- 5 files changed, 47 insertions(+), 32 deletions(-) diff --git a/tools/make.py b/tools/make.py index e8d5a06d8b..4434931f8e 100644 --- a/tools/make.py +++ b/tools/make.py @@ -21,8 +21,7 @@ TEST BUILD & RUN import sys from time import sleep from shutil import copy -from os.path import join, abspath, dirname, exists -from distutils.spawn import find_executable +from os.path import join, abspath, dirname # Be sure that the tools directory is in the search path ROOT = abspath(join(dirname(__file__), "..")) diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index 92f5f2e1f1..28a485d63a 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -27,6 +27,7 @@ from inspect import getmro from copy import deepcopy from tools.config import Config from abc import ABCMeta, abstractmethod +from distutils.spawn import find_executable from multiprocessing import Pool, cpu_count from tools.utils import run_cmd, mkdir, rel_path, ToolException, NotSupportedException, split_path, compile_worker @@ -1091,6 +1092,44 @@ class mbedToolchain: self.config_processed = True return self.config_file + @staticmethod + def generic_check_executable(tool_key, executable_name, levels_up, + nested_dir=None): + """ + Positional args: + tool_key: the key to index TOOLCHAIN_PATHS + executable_name: the toolchain's named executable (ex. armcc) + levels_up: each toolchain joins the toolchain_path, some + variable directories (bin, include), and the executable name, + so the TOOLCHAIN_PATH value must be appropriately distanced + + Keyword args: + nested_dir: the directory within TOOLCHAIN_PATHS where the executable + is found (ex: 'bin' for ARM\bin\armcc (necessary to check for path + that will be used by toolchain's compile) + + Returns True if the executable location specified by the user + exists and is valid OR the executable can be found on the PATH. + Returns False otherwise. + """ + # Search PATH if user did not specify a path or specified path doesn't + # exist. + if not TOOLCHAIN_PATHS[tool_key] or not exists(TOOLCHAIN_PATHS[tool_key]): + exe = find_executable(executable_name) + if not exe: + return False + for level in range(levels_up): + # move up the specified number of directories + exe = dirname(exe) + TOOLCHAIN_PATHS[tool_key] = exe + if nested_dir: + subdir = join(TOOLCHAIN_PATHS[tool_key], nested_dir, + executable_name) + else: + subdir = join(TOOLCHAIN_PATHS[tool_key],executable_name) + # User could have specified a path that exists but does not contain exe + return exists(subdir) or exists(subdir +'.exe') + @abstractmethod def get_config_option(self, config_header): """Generate the compiler option that forces the inclusion of the configuration diff --git a/tools/toolchains/arm.py b/tools/toolchains/arm.py index 26f6441833..7ec6bad145 100644 --- a/tools/toolchains/arm.py +++ b/tools/toolchains/arm.py @@ -15,8 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. """ import re -from os.path import join, dirname, splitext, basename, exists -from distutils.spawn import find_executable +from os.path import join, dirname, splitext, basename from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS from tools.hooks import hook_tool @@ -47,12 +46,7 @@ class ARM(mbedToolchain): """Returns True if the executable (armcc) location specified by the user exists OR the executable can be found on the PATH. Returns False otherwise.""" - if not TOOLCHAIN_PATHS["ARM"] or not exists(TOOLCHAIN_PATHS['ARM']): - exe = find_executable('armcc') - if not exe: - return False - TOOLCHAIN_PATHS['ARM'] = dirname(dirname(exe)) - return True + return mbedToolchain.generic_check_executable("ARM", 'armcc', 2, 'bin') def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) diff --git a/tools/toolchains/gcc.py b/tools/toolchains/gcc.py index fc54c25dae..451711a93d 100644 --- a/tools/toolchains/gcc.py +++ b/tools/toolchains/gcc.py @@ -15,8 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. """ import re -from os.path import join, basename, splitext, dirname, exists -from distutils.spawn import find_executable +from os.path import join, basename, splitext from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS from tools.hooks import hook_tool @@ -275,12 +274,7 @@ class GCC_ARM(GCC): """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.""" - if not TOOLCHAIN_PATHS["GCC_ARM"] or not exists(TOOLCHAIN_PATHS['GCC_ARM']): - exe = find_executable('arm-none-eabi-gcc') - if not exe: - return False - TOOLCHAIN_PATHS['GCC_ARM'] = dirname(exe) - return True + return mbedToolchain.generic_check_executable("GCC_ARM", 'arm-none-eabi-gcc', 1) def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_ARM'], extra_verbose=extra_verbose) @@ -312,12 +306,7 @@ class GCC_CR(GCC): """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.""" - if not TOOLCHAIN_PATHS["GCC_CR"] or not exists(TOOLCHAIN_PATHS['GCC_CR']): - exe = find_executable('arm-none-eabi-gcc') - if not exe: - return False - TOOLCHAIN_PATHS['GCC_CR'] = dirname(exe) - return True + return mbedToolchain.generic_check_executable("GCC_CR", 'arm-none-eabi-gcc', 1) def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_CR'], extra_verbose=extra_verbose) diff --git a/tools/toolchains/iar.py b/tools/toolchains/iar.py index 01ac99846d..447761944d 100644 --- a/tools/toolchains/iar.py +++ b/tools/toolchains/iar.py @@ -16,8 +16,7 @@ limitations under the License. """ import re from os import remove -from os.path import join, exists, dirname, splitext, exists -from distutils.spawn import find_executable +from os.path import join, splitext from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS from tools.hooks import hook_tool @@ -50,12 +49,7 @@ class IAR(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.""" - if not TOOLCHAIN_PATHS["IAR"] or not exists(TOOLCHAIN_PATHS['IAR']): - exe = find_executable('iccarm') - if not exe: - return False - TOOLCHAIN_PATHS['IAR'] = dirname(dirname(exe)) - return True + return mbedToolchain.generic_check_executable("IAR", 'iccarm', 2, "bin") def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) From 8670598115174524c657b747229ccc1a43c7878c Mon Sep 17 00:00:00 2001 From: Sarah Marsh Date: Tue, 13 Sep 2016 16:26:58 -0500 Subject: [PATCH 4/4] Abstract check_executable added --- tools/toolchains/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index 28a485d63a..aa0dd9baff 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -1130,6 +1130,13 @@ class mbedToolchain: # User could have specified a path that exists but does not contain exe return exists(subdir) or exists(subdir +'.exe') + @abstractmethod + def check_executable(self): + """Returns True if the executable (armcc) location specified by the + user exists OR the executable can be found on the PATH. + Returns False otherwise.""" + raise NotImplemented + @abstractmethod def get_config_option(self, config_header): """Generate the compiler option that forces the inclusion of the configuration