Clone of official tools
Diff: build.py
- Revision:
- 31:8ea194f6145b
- Parent:
- 24:25bff2709c20
- Child:
- 35:da9c89f8be7d
--- a/build.py Mon Aug 29 11:56:59 2016 +0100 +++ b/build.py Wed Jan 04 11:58:24 2017 -0600 @@ -27,16 +27,17 @@ 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 +from tools.options import extract_profile from tools.build_api import build_library, build_mbed_libs, build_lib from tools.build_api import mcu_toolchain_matrix from tools.build_api import static_analysis_scan, static_analysis_scan_lib, static_analysis_scan_library from tools.build_api import print_build_results from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT -from utils import argparse_filestring_type +from utils import argparse_filestring_type, args_error from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, CLI_COLOR_MAP from utils import argparse_filestring_type, argparse_dir_not_parent @@ -161,12 +162,16 @@ print mcu_toolchain_matrix(platform_filter=options.general_filter_regex) exit(0) + # Get target list targets = options.mcu if options.mcu else TARGET_NAMES # Get toolchains list toolchains = options.tool if options.tool else TOOLCHAINS + if options.source_dir and not options.build_dir: + args_error(parser, "argument --build is required by argument --source") + if options.color: # This import happens late to prevent initializing colorization when we don't need it import colorize @@ -209,17 +214,29 @@ # CPPCHECK code validation if options.cppcheck_validation: for toolchain in toolchains: + if not TOOLCHAIN_CLASSES[toolchain].check_executable(): + 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, search_path)) for target in targets: try: mcu = TARGET_MAP[target] # CMSIS and MBED libs analysis - static_analysis_scan(mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, verbose=options.verbose, jobs=options.jobs) + profile = extract_profile(parser, options, toolchain) + static_analysis_scan( + mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, + verbose=options.verbose, jobs=options.jobs, + build_profile=profile) for lib_id in libraries: # Static check for library - static_analysis_scan_lib(lib_id, mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, - options=options.options, - extra_verbose=options.extra_verbose_notify, verbose=options.verbose, jobs=options.jobs, clean=options.clean, - macros=options.macros) + static_analysis_scan_lib( + lib_id, mcu, toolchain, CPPCHECK_CMD, + CPPCHECK_MSG_FORMAT, + extra_verbose=options.extra_verbose_notify, + verbose=options.verbose, jobs=options.jobs, + clean=options.clean, macros=options.macros, + build_profile=profile) pass except Exception, e: if options.verbose: @@ -239,9 +256,9 @@ else: try: mcu = TARGET_MAP[target] + profile = extract_profile(parser, options, toolchain) if options.source_dir: lib_build_res = build_library(options.source_dir, options.build_dir, mcu, toolchain, - options=options.options, extra_verbose=options.extra_verbose_notify, verbose=options.verbose, silent=options.silent, @@ -249,26 +266,27 @@ clean=options.clean, archive=(not options.no_archive), macros=options.macros, - name=options.artifact_name) + name=options.artifact_name, + build_profile=profile) else: lib_build_res = build_mbed_libs(mcu, toolchain, - options=options.options, extra_verbose=options.extra_verbose_notify, verbose=options.verbose, silent=options.silent, jobs=options.jobs, clean=options.clean, - macros=options.macros) + macros=options.macros, + build_profile=profile) for lib_id in libraries: build_lib(lib_id, mcu, toolchain, - options=options.options, extra_verbose=options.extra_verbose_notify, verbose=options.verbose, silent=options.silent, clean=options.clean, macros=options.macros, - jobs=options.jobs) + jobs=options.jobs, + build_profile=profile) if lib_build_res: successes.append(tt_id) else: