Readable error when toolchain paths not set.

Fixes #2360.

New error:
[Error] Toolchain path does not exist for IAR.
Current value: /default/path/that/doesnt/exist
(System exit before any build system calls)
pull/2418/head
Sarah Marsh 2016-08-10 11:49:57 -05:00
parent 52658e5131
commit 1445886844
4 changed files with 26 additions and 0 deletions

View File

@ -188,6 +188,23 @@ 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):
print('[ERROR] Toolchain path does not exist for %s.\n'
'Current value: %s' % (self.name, self.toolchain_path))
sys.exit()
return function(self, *args, **kwargs)
return perform_check
class mbedToolchain:
# Verbose logging
VERBOSE = True
@ -702,6 +719,7 @@ 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
@ -900,6 +918,7 @@ 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
@ -911,6 +930,7 @@ class mbedToolchain:
return needed_update
@check_toolchain_path
def link_program(self, r, tmp_path, name):
needed_update = False
ext = 'bin'

View File

@ -81,6 +81,8 @@ 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():

View File

@ -110,6 +110,8 @@ class GCC(mbedToolchain):
self.ar = join(tool_path, "arm-none-eabi-ar")
self.elf2bin = join(tool_path, "arm-none-eabi-objcopy")
self.toolchain_path = tool_path
def parse_dependencies(self, dep_path):
dependencies = []
buff = open(dep_path).readlines()

View File

@ -101,6 +101,8 @@ 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())]