Exemple #1
0
def main():
    """Entry point"""

    official_targets = get_mbed_official_release("5")
    official_target_names = [x[0] for x in official_targets]


    parser = ArgumentParser()
    parser.add_argument("-c", dest="config", default="examples.json")
    parser.add_argument("-e", "--example",
                        help=("filter the examples used in the script"),
                        type=argparse_many(lambda x: x),
                        default=[])
    subparsers = parser.add_subparsers()
    import_cmd = subparsers.add_parser("import")
    import_cmd.set_defaults(fn=do_import)
    clone_cmd = subparsers.add_parser("clone")
    clone_cmd.set_defaults(fn=do_clone)
    deploy_cmd = subparsers.add_parser("deploy")
    deploy_cmd.set_defaults(fn=do_deploy)
    version_cmd = subparsers.add_parser("tag")
    version_cmd.add_argument("tag")
    version_cmd.set_defaults(fn=do_versionning)
    compile_cmd = subparsers.add_parser("compile")
    compile_cmd.set_defaults(fn=do_compile),
    compile_cmd.add_argument(
        "toolchains", nargs="*", default=SUPPORTED_TOOLCHAINS,
        type=argparse_force_uppercase_type(SUPPORTED_TOOLCHAINS,
                                           "toolchain")),
    compile_cmd.add_argument("-m", "--mcu",
                             help=("build for the given MCU (%s)" %
                                ', '.join(official_target_names)),
                            metavar="MCU",
                            type=argparse_many(
                                argparse_force_uppercase_type(
                                    official_target_names, "MCU")),
                            default=official_target_names)
    export_cmd = subparsers.add_parser("export")
    export_cmd.set_defaults(fn=do_export),
    export_cmd.add_argument(
        "ide", nargs="*", default=SUPPORTED_IDES,
        type=argparse_force_uppercase_type(SUPPORTED_IDES,
                                           "ide"))
    export_cmd.add_argument("-m", "--mcu",
                             help=("build for the given MCU (%s)" %
                                ', '.join(official_target_names)),
                            metavar="MCU",
                            type=argparse_many(
                                argparse_force_uppercase_type(
                                    official_target_names, "MCU")),
                            default=official_target_names)
    args = parser.parse_args()
    config = json.load(open(os.path.join(os.path.dirname(__file__),
                               args.config)))

    all_examples = []
    for example in config['examples']:
        all_examples = all_examples + [basename(x['repo']) for x in lib.get_repo_list(example)]
    examples = [x for x in all_examples if x in args.example] if args.example else all_examples
    return args.fn(args, config, examples)
Exemple #2
0
def target_cross_toolchain(allowed_toolchains,
                           features=[],
                           targets=TARGET_MAP.keys()):
    """Generate pairs of target and toolchains

    Args:
    allowed_toolchains - a list of all possible toolchains

    Kwargs:
    features - the features that must be in the features array of a
               target
    targets - a list of available targets
    """
    for target, toolchains in get_mbed_official_release("5"):
        for toolchain in toolchains:
            if (toolchain in allowed_toolchains and target in targets
                    and all(feature in TARGET_MAP[target].features
                            for feature in features)):
                yield target, toolchain
Exemple #3
0
def target_cross_ide(allowed_ides, features=[], targets=[]):
    """Generate pairs of target and ides

    Args:
    allowed_ides - a list of all possible IDEs

    Kwargs:
    features - the features that must be in the features array of a
               target
    targets - a list of available targets
    """
    if len(targets) == 0:
        targets = TARGET_MAP.keys()

    for target, toolchains in get_mbed_official_release("5"):
        for ide in allowed_ides:
            if (EXPORTERS[ide].TOOLCHAIN in toolchains
                    and target in EXPORTERS[ide].TARGETS and target in targets
                    and all(feature in TARGET_MAP[target].features
                            for feature in features)):
                yield target, ide
Exemple #4
0
import os, getpass, sys, json, time, requests, logging
from os.path import dirname, abspath, basename, join
import argparse
import subprocess
import re
import hglib
import argparse

# Be sure that the tools directory is in the search path
ROOT = abspath(join(dirname(__file__), ".."))
sys.path.insert(0, ROOT)

from tools.build_api import get_mbed_official_release

OFFICIAL_MBED_LIBRARY_BUILD = get_mbed_official_release('2')


def get_compilation_failure(messages):
    """ Reads the json formatted 'messages' and checks for compilation errors.
        If there is a genuine compilation error then there should be a new 
        message containing a severity field = Error and an accompanying message 
        with the compile error text. Any other combination is considered an 
        internal compile engine failure 
    Args:
    messages - json formatted text returned by the online compiler API.
    
    Returns:
    Either "Error" or "Internal" to indicate an actual compilation error or an 
    internal IDE API fault.
def main():
    """Entry point"""

    ide_list = ["iar", "uvision"]

    default_v2 = [test_name_known("MBED_BLINKY")]
    default_v5 = [check_valid_mbed_os('tests-mbedmicro-rtos-mbed-basic')]

    parser = argparse.ArgumentParser(
        description="Test progen builders. Leave any flag off"
        " to run with all possible options.")
    parser.add_argument("-i",
                        dest="ides",
                        default=ide_list,
                        type=argparse_many(
                            argparse_force_lowercase_type(
                                ide_list, "toolchain")),
                        help="The target IDE: %s" % str(ide_list))

    parser.add_argument("-p",
                        type=argparse_many(test_known),
                        dest="programs",
                        help="The index of the desired test program: [0-%d]" %
                        (len(TESTS) - 1))

    parser.add_argument("-n",
                        type=argparse_many(test_name_known),
                        dest="programs",
                        help="The name of the desired test program")

    parser.add_argument("-m",
                        "--mcu",
                        help=("Generate projects for the given MCUs"),
                        metavar="MCU",
                        type=argparse_many(str.upper))

    parser.add_argument("-os-tests",
                        type=argparse_many(check_valid_mbed_os),
                        dest="os_tests",
                        help="Mbed-os tests")

    parser.add_argument("-c",
                        "--clean",
                        dest="clean",
                        action="store_true",
                        help="clean up the exported project files",
                        default=False)

    parser.add_argument("--release",
                        dest="release",
                        type=check_version,
                        help="Which version of mbed to test",
                        default=RELEASE_VERSIONS[-1])

    parser.add_argument("--profile",
                        dest="profile",
                        action="append",
                        type=argparse_filestring_type,
                        default=[])

    options = parser.parse_args()
    # targets in chosen release
    targetnames = [
        target[0] for target in get_mbed_official_release(options.release)
    ]
    # all targets in release are default
    test_targets = options.mcu or targetnames
    if not all([t in targetnames for t in test_targets]):
        args_error(
            parser, "Only specify targets in release %s:\n%s" %
            (options.release, columnate(sorted(targetnames))))

    v2_tests, v5_tests = [], []
    if options.release == '5':
        v5_tests = options.os_tests or default_v5
    elif options.release == '2':
        v2_tests = options.programs or default_v2

    tests = []
    default_test = {
        key: None
        for key in ['ide', 'mcu', 'name', 'id', 'src', 'log']
    }
    for mcu in test_targets:
        for ide in options.ides:
            log = "build_log.txt" if ide == 'iar' \
                else join('build', 'build_log.txt')
            # add each test case to the tests array
            default_test.update({'mcu': mcu, 'ide': ide, 'log': log})
            for test in v2_tests:
                default_test.update({'name': TESTS[test]["id"], 'id': test})
                tests.append(copy(default_test))
            for test in v5_tests:
                default_test.update({'name': test[0], 'src': [test[1], ROOT]})
                tests.append(copy(default_test))
    test = ExportBuildTest(tests, parser, options)
    test.batch_tests(clean=options.clean)
    print_results(test.successes, test.failures, test.skips)
    sys.exit(len(test.failures))
Exemple #6
0
# Be sure that the tools directory is in the search path
ROOT = abspath(join(dirname(__file__), ".."))
sys.path.insert(0, ROOT)

from tools.build_api import build_mbed_libs
from tools.build_api import write_build_report
from tools.build_api import get_mbed_official_release
from tools.options import extract_profile
from tools.targets import TARGET_MAP, TARGET_NAMES
from tools.test_exporters import ReportExporter, ResultExporterType
from tools.test_api import SingleTestRunner
from tools.test_api import singletest_in_cli_mode
from tools.paths import TEST_DIR, MBED_LIBRARIES
from tools.tests import TEST_MAP

OFFICIAL_MBED_LIBRARY_BUILD = get_mbed_official_release('2')

if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option('-o', '--official', dest="official_only", default=False, action="store_true",
                      help="Build using only the official toolchain for each target")
    parser.add_option("-j", "--jobs", type="int", dest="jobs",
                      default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
                      default=False, help="Verbose diagnostic output")
    parser.add_option("-t", "--toolchains", dest="toolchains", help="Use toolchains names separated by comma")

    parser.add_option("--profile", dest="profile", action="append", default=[])

    parser.add_option("-p", "--platforms", dest="platforms", default="", help="Build only for the platform namesseparated by comma")
def main():
    """Entry point"""

    ide_list = ["iar", "uvision"]

    default_v2 = [test_name_known("MBED_BLINKY")]
    default_v5 = [check_valid_mbed_os('tests-mbedmicro-rtos-mbed-basic')]

    parser = argparse.ArgumentParser(description=
                                     "Test progen builders. Leave any flag off"
                                     " to run with all possible options.")
    parser.add_argument("-i",
                        dest="ides",
                        default=ide_list,
                        type=argparse_many(argparse_force_lowercase_type(
                            ide_list, "toolchain")),
                        help="The target IDE: %s"% str(ide_list))

    parser.add_argument( "-p",
                        type=argparse_many(test_known),
                        dest="programs",
                        help="The index of the desired test program: [0-%d]"
                             % (len(TESTS) - 1))

    parser.add_argument("-n",
                        type=argparse_many(test_name_known),
                        dest="programs",
                        help="The name of the desired test program")

    parser.add_argument("-m", "--mcu",
                        help=("Generate projects for the given MCUs"),
                        metavar="MCU",
                        type=argparse_many(str.upper))

    parser.add_argument("-os-tests",
                        type=argparse_many(check_valid_mbed_os),
                        dest="os_tests",
                        help="Mbed-os tests")

    parser.add_argument("-c", "--clean",
                        dest="clean",
                        action="store_true",
                        help="clean up the exported project files",
                        default=False)

    parser.add_argument("--release",
                        dest="release",
                        type=check_version,
                        help="Which version of mbed to test",
                        default=RELEASE_VERSIONS[-1])

    parser.add_argument("--profile",
                        dest="profile",
                        action="append",
                        type=argparse_filestring_type,
                        default=[])

    options = parser.parse_args()
    # targets in chosen release
    targetnames = [target[0] for target in
                   get_mbed_official_release(options.release)]
    # all targets in release are default
    test_targets = options.mcu or targetnames
    if not all([t in targetnames for t in test_targets]):
        args_error(parser, "Only specify targets in release %s:\n%s"
                   %(options.release, columnate(sorted(targetnames))))

    v2_tests, v5_tests = [],[]
    if options.release == '5':
        v5_tests = options.os_tests or default_v5
    elif options.release == '2':
        v2_tests = options.programs or default_v2

    tests = []
    default_test = {key:None for key in ['ide', 'mcu', 'name', 'id', 'src', 'log']}
    for mcu in test_targets:
        for ide in options.ides:
            log = "build_log.txt" if ide == 'iar' \
                else join('build', 'build_log.txt')
            # add each test case to the tests array
            default_test.update({'mcu': mcu, 'ide': ide, 'log':log})
            for test in v2_tests:
                default_test.update({'name':TESTS[test]["id"], 'id':test})
                tests.append(copy(default_test))
            for test in v5_tests:
                default_test.update({'name':test[0],'src':[test[1],ROOT]})
                tests.append(copy(default_test))
    test = ExportBuildTest(tests, parser, options)
    test.batch_tests(clean=options.clean)
    print_results(test.successes, test.failures, test.skips)
    sys.exit(len(test.failures))
Exemple #8
0
def parse_args():
    """Parse the arguments passed to the script."""
    official_targets = get_mbed_official_release("5")
    official_target_names = [x[0] for x in official_targets]

    parser = ArgumentParser()
    parser.add_argument("-c", dest="config", default="examples.json")
    parser.add_argument("-e",
                        "--example",
                        help=("filter the examples used in the script"),
                        type=argparse_many(lambda x: x),
                        default=[])
    subparsers = parser.add_subparsers()
    import_cmd = subparsers.add_parser(
        "import", help="import of examples in config file")
    import_cmd.set_defaults(fn=do_import)
    clone_cmd = subparsers.add_parser("clone",
                                      help="clone examples in config file")
    clone_cmd.set_defaults(fn=do_clone)
    list_cmd = subparsers.add_parser(
        "list", help="list examples in config file in a table")
    list_cmd.set_defaults(fn=do_list)
    symlink_cmd = subparsers.add_parser(
        "symlink", help="create symbolic link to given mbed-os PATH")
    symlink_cmd.add_argument("PATH", help=" path of mbed-os to be symlinked")
    symlink_cmd.set_defaults(fn=do_symlink)
    deploy_cmd = subparsers.add_parser(
        "deploy", help="mbed deploy for examples in config file")
    deploy_cmd.set_defaults(fn=do_deploy)
    version_cmd = subparsers.add_parser("update",
                                        help="update mbed-os to sepcific tags")
    version_cmd.add_argument("TAG", help=" tag of mbed-os")
    version_cmd.set_defaults(fn=do_update)
    compile_cmd = subparsers.add_parser("compile", help="compile of examples")
    compile_cmd.set_defaults(fn=do_compile),
    compile_cmd.add_argument("toolchains",
                             nargs="*",
                             default=SUPPORTED_TOOLCHAINS,
                             type=argparse_force_uppercase_type(
                                 SUPPORTED_TOOLCHAINS, "toolchain")),
    compile_cmd.add_argument("-m",
                             "--mcu",
                             help=("build for the given MCU (%s)" %
                                   ', '.join(official_target_names)),
                             metavar="MCU",
                             type=argparse_many(
                                 argparse_force_uppercase_type(
                                     official_target_names, "MCU")),
                             default=official_target_names)

    compile_cmd.add_argument("--profiles",
                             nargs='+',
                             metavar="profile",
                             help="build profile(s)")

    compile_cmd.add_argument(
        "-j",
        "--jobs",
        dest='jobs',
        metavar="NUMBER",
        type=int,
        default=0,
        help=
        "Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)"
    )

    compile_cmd.add_argument("-v",
                             "--verbose",
                             action="store_true",
                             dest="verbose",
                             default=False,
                             help="Verbose diagnostic output")

    export_cmd = subparsers.add_parser("export", help="export of examples")
    export_cmd.set_defaults(fn=do_export)
    export_cmd.add_argument("ide",
                            nargs="*",
                            default=SUPPORTED_IDES,
                            type=argparse_force_uppercase_type(
                                SUPPORTED_IDES, "ide"))
    export_cmd.add_argument("-m",
                            "--mcu",
                            help=("build for the given MCU (%s)" %
                                  ', '.join(official_target_names)),
                            metavar="MCU",
                            type=argparse_many(
                                argparse_force_uppercase_type(
                                    official_target_names, "MCU")),
                            default=official_target_names)
    return parser.parse_args()