From 227ffecb8326f85899607f7e821a601a916d24f9 Mon Sep 17 00:00:00 2001 From: Martin Kojtal Date: Wed, 20 Apr 2016 13:04:53 +0100 Subject: [PATCH 1/2] Make - handle invalid targets (catch KeyError) --- tools/make.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/make.py b/tools/make.py index 6ae1e4b095..9c72cf17d4 100755 --- a/tools/make.py +++ b/tools/make.py @@ -240,7 +240,12 @@ if __name__ == '__main__': if options.build_dir is not None: build_dir = options.build_dir - target = TARGET_MAP[mcu] + try: + target = TARGET_MAP[mcu] + except KeyError: + print "[ERROR] Target %s not supported" % mcu + sys.exit(1) + try: bin_file = build_project(test.source_dir, build_dir, target, toolchain, test.dependencies, options.options, linker_script=options.linker_script, From 3e9149025911aca79a927b7fa8c38b7f794d912c Mon Sep 17 00:00:00 2001 From: Martin Kojtal Date: Wed, 20 Apr 2016 13:16:37 +0100 Subject: [PATCH 2/2] Build - raise exception if toolchain is not recognized This sends the message that toolchain specified is not valid. --- tools/build_api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/build_api.py b/tools/build_api.py index 76a627c463..8fb46015da 100644 --- a/tools/build_api.py +++ b/tools/build_api.py @@ -83,7 +83,11 @@ def build_project(src_path, build_path, target, toolchain_name, """ This function builds project. Project can be for example one test / UT """ # Toolchain instance - toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, notify, macros, silent, extra_verbose=extra_verbose) + try: + toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, notify, macros, silent, extra_verbose=extra_verbose) + except KeyError as e: + raise KeyError("Toolchain %s not supported" % toolchain_name) + toolchain.VERBOSE = verbose toolchain.jobs = jobs toolchain.build_all = clean