Esempio n. 1
0
    def test_build_library_no_app_config(self, mock_prepare_toolchain,
                                         mock_exists, _, __):
        """
        Test that build_library correctly deals with no app_config

        :param mock_prepare_toolchain: mock of function prepare_toolchain
        :param mock_exists: mock of function os.path.exists
        :param _: mock of function mkdir (not tested)
        :param __: mock of class Resources (not tested)
        :return:
        """
        notify = MockNotifier()
        mock_exists.return_value = False

        build_library(self.src_paths,
                      self.build_path,
                      self.target,
                      self.toolchain_name,
                      notify=notify)

        args = mock_prepare_toolchain.call_args
        self.assertTrue('app_config' in args[1],
                        "prepare_toolchain was not called with app_config")
        self.assertEqual(
            args[1]['app_config'], None,
            "prepare_toolchain was called with an incorrect app_config")
Esempio n. 2
0
    def test_build_library_app_config(self, mock_prepare_toolchain,
                                      mock_exists, _, __):
        """
        Test that build_library uses app_config correctly

        :param mock_prepare_toolchain: mock of function prepare_toolchain
        :param mock_exists: mock of function os.path.exists
        :param _: mock of function mkdir (not tested)
        :param __: mock of function scan_resources (not tested)
        :return:
        """
        app_config = "app_config"
        mock_exists.return_value = False

        build_library(self.src_paths,
                      self.build_path,
                      self.target,
                      self.toolchain_name,
                      app_config=app_config)

        args = mock_prepare_toolchain.call_args
        self.assertTrue('app_config' in args[1],
                        "prepare_toolchain was not called with app_config")
        self.assertEqual(
            args[1]['app_config'], app_config,
            "prepare_toolchain was called with an incorrect app_config")
Esempio n. 3
0
    def test_build_library_no_app_config(self, mock_prepare_toolchain, mock_exists, _, __):
        """
        Test that build_library correctly deals with no app_config

        :param mock_prepare_toolchain: mock of function prepare_toolchain
        :param mock_exists: mock of function os.path.exists
        :param _: mock of function mkdir (not tested)
        :param __: mock of function scan_resources (not tested)
        :return:
        """
        mock_exists.return_value = False

        build_library(self.src_paths, self.build_path, self.target,
                      self.toolchain_name)

        args = mock_prepare_toolchain.call_args
        self.assertTrue('app_config' in args[1],
                        "prepare_toolchain was not called with app_config")
        self.assertEqual(args[1]['app_config'], None,
                         "prepare_toolchain was called with an incorrect app_config")
Esempio n. 4
0
    def test_build_library_app_config(self, mock_prepare_toolchain, mock_exists, _, __):
        """
        Test that build_library uses app_config correctly

        :param mock_prepare_toolchain: mock of function prepare_toolchain
        :param mock_exists: mock of function os.path.exists
        :param _: mock of function mkdir (not tested)
        :param __: mock of function scan_resources (not tested)
        :return:
        """
        notify = MockNotifier()
        app_config = "app_config"
        mock_exists.return_value = False

        build_library(self.src_paths, self.build_path, self.target,
                      self.toolchain_name, app_config=app_config, notify=notify)

        args = mock_prepare_toolchain.call_args
        self.assertTrue('app_config' in args[1],
                        "prepare_toolchain was not called with app_config")
        self.assertEqual(args[1]['app_config'], app_config,
                         "prepare_toolchain was called with an incorrect app_config")
Esempio n. 5
0
        for toolchain in toolchains:
            for target in targets:
                tt_id = "%s::%s" % (toolchain, target)
                if toolchain not in TARGET_MAP[target].supported_toolchains:
                    # Log this later
                    print "%s skipped: toolchain not supported" % tt_id
                    skipped.append(tt_id)
                else:
                    try:
                        mcu = TARGET_MAP[target]
                        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,
                                                        jobs=options.jobs,
                                                        clean=options.clean,
                                                        archive=(not options.no_archive),
                                                        macros=options.macros,
                                                        name=options.artifact_name)
                        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)

                        for lib_id in libraries:
Esempio n. 6
0
            target = TARGET_MAP[options.mcu]

            build_report = {}
            build_properties = {}

            library_build_success = False
            try:
                # Build sources
                build_library(base_source_paths,
                              options.build_dir,
                              target,
                              options.tool,
                              options=options.options,
                              jobs=options.jobs,
                              clean=options.clean,
                              report=build_report,
                              properties=build_properties,
                              name="mbed-build",
                              macros=options.macros,
                              verbose=options.verbose,
                              archive=False)

                library_build_success = True
            except ToolException, e:
                # ToolException output is handled by the build log
                pass
            except NotSupportedException, e:
                # NotSupportedException is handled by the build log
                pass
            except Exception, e:
Esempio n. 7
0
def main():
    start = time()

    # Parse Options
    parser = get_default_options_parser()

    parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type,
                        default=None, help="The source (input) directory", action="append")

    parser.add_argument("--build", dest="build_dir", type=argparse_dir_not_parent(ROOT),
                      default=None, help="The build (output) directory")

    parser.add_argument("--no-archive", dest="no_archive", action="store_true",
                      default=False, help="Do not produce archive (.ar) file, but rather .o")

    # Extra libraries
    parser.add_argument("-r", "--rtos",
                      action="store_true",
                      dest="rtos",
                      default=False,
                      help="Compile the rtos")

    parser.add_argument("--rpc",
                      action="store_true",
                      dest="rpc",
                      default=False,
                      help="Compile the rpc library")

    parser.add_argument("-u", "--usb",
                      action="store_true",
                      dest="usb",
                      default=False,
                      help="Compile the USB Device library")

    parser.add_argument("-d", "--dsp",
                      action="store_true",
                      dest="dsp",
                      default=False,
                      help="Compile the DSP library")

    parser.add_argument( "--cpputest",
                      action="store_true",
                      dest="cpputest_lib",
                      default=False,
                      help="Compiles 'cpputest' unit test library (library should be on the same directory level as mbed repository)")

    parser.add_argument("-D",
                      action="append",
                      dest="macros",
                      help="Add a macro definition")

    parser.add_argument("-S", "--supported-toolchains",
                      action="store_true",
                      dest="supported_toolchains",
                      default=False,
                      help="Displays supported matrix of MCUs and toolchains")

    parser.add_argument('-f', '--filter',
                      dest='general_filter_regex',
                      default=None,
                      help='For some commands you can use filter to filter out results')

    parser.add_argument("-j", "--jobs", type=int, dest="jobs",
                      default=0, help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")
    parser.add_argument("-N", "--artifact-name", dest="artifact_name",
                      default=None, help="The built project's name")

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

    parser.add_argument("--silent",
                      action="store_true",
                      dest="silent",
                      default=False,
                      help="Silent diagnostic output (no copy, compile notification)")

    parser.add_argument("-x", "--extra-verbose-notifications",
                      action="store_true",
                      dest="extra_verbose_notify",
                      default=False,
                      help="Makes compiler more verbose, CI friendly.")

    parser.add_argument("--ignore", dest="ignore", type=argparse_many(str),
                        default=None, help="Comma separated list of patterns to add to mbedignore (eg. ./main.cpp)")

    options = parser.parse_args()

    # Only prints matrix of supported toolchains
    if options.supported_toolchains:
        print(mcu_toolchain_matrix(platform_filter=options.general_filter_regex))
        exit(0)


    # Get target list
    targets = extract_mcus(parser, options) 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")


    # Get libraries list
    libraries = []

    # Additional Libraries
    if options.rpc:
        libraries.extend(["rpc"])
    if options.usb:
        libraries.append("usb")
    if options.dsp:
        libraries.extend(["dsp"])
    if options.cpputest_lib:
        libraries.extend(["cpputest"])

    # Build results
    failures = []
    successes = []
    skipped = []
    end_warnings = []

    if options.clean:
        clean_psa_autogen()

    for toolchain in toolchains:
        for target_name in targets:
            target = Target.get_target(target_name)

            try:
                toolchain_name, internal_tc_name, end_warnings = find_valid_toolchain(
                    target, toolchain
                )
            except NoValidToolchainException as e:
                print_end_warnings(e.end_warnings)
                args_error(parser, str(e))
            tt_id = "%s::%s" % (internal_tc_name, target_name)
            if not target_supports_toolchain(target, toolchain_name):
                # Log this later
                print("%s skipped: toolchain not supported" % tt_id)
                skipped.append(tt_id)
            else:
                try:
                    notifier = TerminalNotifier(options.verbose, options.silent)
                    profile = extract_profile(parser, options, internal_tc_name)

                    if options.source_dir:
                        if target.is_PSA_target:
                            generate_psa_sources(
                                source_dirs=options.source_dir,
                                ignore_paths=[options.build_dir]
                            )

                        resource_filter = None
                        if target.is_PSA_secure_target:
                            resource_filter = OsAndSpeResourceFilter()

                        lib_build_res = build_library(
                            options.source_dir, options.build_dir, target, toolchain_name,
                            jobs=options.jobs,
                            clean=options.clean,
                            archive=(not options.no_archive),
                            macros=options.macros,
                            name=options.artifact_name,
                            build_profile=profile,
                            ignore=options.ignore,
                            notify=notifier,
                            resource_filter=resource_filter
                        )
                    else:
                        lib_build_res = build_mbed_libs(
                            target, toolchain_name,
                            jobs=options.jobs,
                            clean=options.clean,
                            macros=options.macros,
                            build_profile=profile,
                            ignore=options.ignore,
                            notify=notifier,
                        )

                    for lib_id in libraries:
                        build_lib(
                            lib_id, target, toolchain_name,
                            clean=options.clean,
                            macros=options.macros,
                            jobs=options.jobs,
                            build_profile=profile,
                            ignore=options.ignore,
                        )
                    if lib_build_res:
                        successes.append(tt_id)
                    else:
                        skipped.append(tt_id)
                except KeyboardInterrupt as e:
                    print("\n[CTRL+c] exit")
                    print_end_warnings(end_warnings)
                    sys.exit(0)
                except Exception as e:
                    if options.verbose:
                        import traceback
                        traceback.print_exc(file=sys.stdout)
                        print_end_warnings(end_warnings)
                        sys.exit(1)
                    failures.append(tt_id)
                    print(e)

    # Write summary of the builds
    print("\nCompleted in: (%.2f)s\n" % (time() - start))

    for report, report_name in [(successes, "Build successes:"),
                                (skipped, "Build skipped:"),
                                (failures, "Build failures:"),
                               ]:
        if report:
            print(print_build_results(report, report_name))

    print_end_warnings(end_warnings)
    if failures:
        sys.exit(1)
Esempio n. 8
0
File: build.py Progetto: sg-/mbed-os
 if toolchain not in TARGET_MAP[target].supported_toolchains:
     # Log this later
     print("%s skipped: toolchain not supported" % tt_id)
     skipped.append(tt_id)
 else:
     try:
         notifier = TerminalNotifier(options.verbose, options.silent)
         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,
                 jobs=options.jobs,
                 clean=options.clean,
                 archive=(not options.no_archive),
                 macros=options.macros,
                 name=options.artifact_name,
                 build_profile=profile,
                 ignore=options.ignore,
                 notify = notifier,
             )
         else:
             lib_build_res = build_mbed_libs(
                 mcu, toolchain,
                 jobs=options.jobs,
                 clean=options.clean,
                 macros=options.macros,
                 build_profile=profile,
                 ignore=options.ignore,
                 notify=notifier,
             )
Esempio n. 9
0
File: test.py Progetto: akselsm/mbed
            if not base_source_paths:
                base_source_paths = ['.']
            
            build_report = {}
            build_properties = {}

            library_build_success = False
            profile = extract_profile(parser, options, toolchain)
            try:
                # Build sources
                build_library(base_source_paths, options.build_dir, mcu, toolchain,
                                                jobs=options.jobs,
                                                clean=options.clean,
                                                report=build_report,
                                                properties=build_properties,
                                                name="mbed-build",
                                                macros=options.macros,
                                                verbose=options.verbose,
                                                notify=notify,
                                                archive=False,
                                                app_config=options.app_config,
                              build_profile=profile)

                library_build_success = True
            except ToolException, e:
                # ToolException output is handled by the build log
                pass
            except NotSupportedException, e:
                # NotSupportedException is handled by the build log
                pass
            except Exception, e:
                # Some other exception occurred, print the error message
Esempio n. 10
0
            build_report = {}
            build_properties = {}

            library_build_success = False
            profile = extract_profile(parser, options, toolchain)
            try:
                # Build sources
                notify = TerminalNotifier(options.verbose)
                build_library(base_source_paths,
                              options.build_dir,
                              mcu,
                              toolchain,
                              jobs=options.jobs,
                              clean=options.clean,
                              report=build_report,
                              properties=build_properties,
                              name="mbed-build",
                              macros=options.macros,
                              notify=notify,
                              archive=False,
                              app_config=config,
                              build_profile=profile,
                              ignore=options.ignore)

                library_build_success = True
            except ToolException as e:
                # ToolException output is handled by the build log
                pass
            except NotSupportedException as e:
                # NotSupportedException is handled by the build log
                pass
Esempio n. 11
0
        total_build_success = True

        for target_name, target_toolchains in build_config.iteritems():
            target = TARGET_MAP[target_name]
            
            for target_toolchain in target_toolchains:
                library_build_success = True
                
                try:
                    build_directory = join(options.build_dir, target_name, target_toolchain)
                    # Build sources
                    build_library(base_source_paths, build_directory, target, target_toolchain,
                                                    jobs=options.jobs,
                                                    clean=options.clean,
                                                    report=build_report,
                                                    properties=build_properties,
                                                    name="mbed-os",
                                                    macros=options.macros,
                                                    verbose=options.verbose,
                                                    archive=False)
                except Exception, e:
                    library_build_success = False
                    print "Failed to build library"
                    print e
                    
                if options.continue_on_build_fail or library_build_success:
                    # Build all the tests
                    all_tests = find_tests(base_source_paths[0], target_name, toolchain_name)
                    test_build_success, test_build = build_tests(all_tests, [build_directory], build_directory, target, target_toolchain,
                            clean=options.clean,
                            report=build_report,
Esempio n. 12
0
 if toolchain not in TARGET_MAP[target].supported_toolchains:
     # Log this later
     print "%s skipped: toolchain not supported" % tt_id
     skipped.append(tt_id)
 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,
                 extra_verbose=options.extra_verbose_notify,
                 verbose=options.verbose,
                 silent=options.silent,
                 jobs=options.jobs,
                 clean=options.clean,
                 archive=(not options.no_archive),
                 macros=options.macros,
                 name=options.artifact_name,
                 build_profile=profile)
         else:
             lib_build_res = build_mbed_libs(
                 mcu,
                 toolchain,
                 extra_verbose=options.extra_verbose_notify,
                 verbose=options.verbose,
                 silent=options.silent,
                 jobs=options.jobs,
                 clean=options.clean,
Esempio n. 13
0
                base_source_paths = ['.']

            build_report = {}
            build_properties = {}

            library_build_success = False
            try:
                # Build sources
                build_library(base_source_paths,
                              options.build_dir,
                              mcu,
                              toolchain,
                              options=options.options,
                              jobs=options.jobs,
                              clean=options.clean,
                              report=build_report,
                              properties=build_properties,
                              name="mbed-build",
                              macros=options.macros,
                              verbose=options.verbose,
                              notify=notify,
                              archive=False,
                              app_config=options.app_config)

                library_build_success = True
            except ToolException, e:
                # ToolException output is handled by the build log
                pass
            except NotSupportedException, e:
                # NotSupportedException is handled by the build log
                pass
Esempio n. 14
0
                # Log this later
                print("%s skipped: toolchain not supported" % tt_id)
                skipped.append(tt_id)
            else:
                try:
                    notifier = TerminalNotifier(options.verbose, options.silent)
                    mcu = TARGET_MAP[target]
                    profile = extract_profile(parser, options, toolchain)

                    if mcu.is_PSA_secure_target:
                        lib_build_res = build_library(
                            ROOT, options.build_dir, mcu, toolchain,
                            jobs=options.jobs,
                            clean=options.clean,
                            archive=(not options.no_archive),
                            macros=options.macros,
                            name=options.artifact_name,
                            build_profile=profile,
                            ignore=options.ignore,
                            notify=notifier,
                        )
                    elif options.source_dir:
                        lib_build_res = build_library(
                            options.source_dir, options.build_dir, mcu, toolchain,
                            jobs=options.jobs,
                            clean=options.clean,
                            archive=(not options.no_archive),
                            macros=options.macros,
                            name=options.artifact_name,
                            build_profile=profile,
                            ignore=options.ignore,
Esempio n. 15
0
def main():
    error = False
    try:
        # Parse Options
        parser = get_default_options_parser(add_app_config=True)

        parser.add_argument("-D",
                            action="append",
                            dest="macros",
                            help="Add a macro definition")

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

        parser.add_argument(
            "--source",
            dest="source_dir",
            type=argparse_filestring_type,
            default=None,
            help=
            "The source (input) directory (for sources other than tests). Defaults to current directory.",
            action="append")

        parser.add_argument("--build",
                            dest="build_dir",
                            type=argparse_dir_not_parent(ROOT),
                            default=None,
                            help="The build (output) directory")

        parser.add_argument(
            "-l",
            "--list",
            action="store_true",
            dest="list",
            default=False,
            help="List (recursively) available tests in order and exit")

        parser.add_argument(
            "-p",
            "--paths",
            dest="paths",
            type=argparse_many(argparse_filestring_type),
            default=None,
            help=
            "Limit the tests to those within the specified comma separated list of paths"
        )

        format_choices = ["list", "json"]
        format_default_choice = "list"
        format_help = "Change the format in which tests are listed. Choices include: %s. Default: %s" % (
            ", ".join(format_choices), format_default_choice)
        parser.add_argument("-f",
                            "--format",
                            dest="format",
                            type=argparse_lowercase_type(
                                format_choices, "format"),
                            default=format_default_choice,
                            help=format_help)

        parser.add_argument(
            "--continue-on-build-fail",
            action="store_true",
            dest="continue_on_build_fail",
            default=None,
            help="Continue trying to build all tests if a build failure occurs"
        )

        #TODO validate the names instead of just passing through str
        parser.add_argument(
            "-n",
            "--names",
            dest="names",
            type=argparse_many(str),
            default=None,
            help="Limit the tests to a comma separated list of names")

        parser.add_argument("--test-config",
                            dest="test_config",
                            type=str,
                            default=None,
                            help="Test config for a module")

        parser.add_argument(
            "--test-spec",
            dest="test_spec",
            default=None,
            help=
            "Destination path for a test spec file that can be used by the Greentea automated test tool"
        )

        parser.add_argument(
            "--build-report-junit",
            dest="build_report_junit",
            default=None,
            help="Destination path for a build report in the JUnit xml format")
        parser.add_argument("--build-data",
                            dest="build_data",
                            default=None,
                            help="Dump build_data to this file")

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

        parser.add_argument(
            "--silent",
            action="store_true",
            dest="silent",
            default=False,
            help="Silent diagnostic output (no copy, compile notification)")

        parser.add_argument("--stats-depth",
                            type=int,
                            dest="stats_depth",
                            default=2,
                            help="Depth level for static memory report")

        parser.add_argument(
            "--ignore",
            dest="ignore",
            type=argparse_many(str),
            default=None,
            help=
            "Comma separated list of patterns to add to mbedignore (eg. ./main.cpp)"
        )

        parser.add_argument("--icetea",
                            action="store_true",
                            dest="icetea",
                            default=False,
                            help="Only icetea tests")

        parser.add_argument("--greentea",
                            action="store_true",
                            dest="greentea",
                            default=False,
                            help="Only greentea tests")

        options = parser.parse_args()

        # Filter tests by path if specified
        if options.paths:
            all_paths = options.paths
        else:
            all_paths = ["."]

        all_tests = {}
        tests = {}
        end_warnings = []

        # As default both test tools are enabled
        if not (options.greentea or options.icetea):
            options.greentea = True
            options.icetea = True

        # Target
        if options.mcu is None:
            args_error(parser, "argument -m/--mcu is required")
        mcu = extract_mcus(parser, options)[0]
        target = Target.get_target(mcu)

        # Toolchain
        if options.tool is None:
            args_error(parser, "argument -t/--tool is required")
        toolchain = options.tool[0]

        try:
            toolchain_name, internal_tc_name, end_warnings = find_valid_toolchain(
                target, toolchain)
        except NoValidToolchainException as e:
            print_end_warnings(e.end_warnings)
            args_error(parser, str(e))

        # Assign config file. Precedence: test_config>app_config
        # TODO: merge configs if both given
        if options.test_config:
            config = get_test_config(options.test_config, mcu)
            if not config:
                args_error(
                    parser,
                    "argument --test-config contains invalid path or identifier"
                )
        elif options.app_config:
            config = options.app_config
        else:
            config = Config.find_app_config(options.source_dir)

        if not config:
            config = get_default_config(options.source_dir or ['.'], mcu)

        # Find all tests in the relevant paths
        for path in all_paths:
            all_tests.update(
                find_tests(base_dir=path,
                           target_name=mcu,
                           toolchain_name=toolchain_name,
                           icetea=options.icetea,
                           greentea=options.greentea,
                           app_config=config))

        # Filter tests by name if specified
        if options.names:
            all_names = options.names
            all_names = [x.lower() for x in all_names]

            for name in all_names:
                if any(
                        fnmatch.fnmatch(testname, name)
                        for testname in all_tests):
                    for testname, test in all_tests.items():
                        if fnmatch.fnmatch(testname, name):
                            tests[testname] = test
                else:
                    print("[Warning] Test with name '%s' was not found in the "
                          "available tests" % (name))
        else:
            tests = all_tests

        if options.list:
            # Print available tests in order and exit
            print_tests(tests, options.format)
            sys.exit(0)
        else:
            # Build all tests
            if not options.build_dir:
                args_error(parser, "argument --build is required")

            base_source_paths = options.source_dir

            # Default base source path is the current directory
            if not base_source_paths:
                base_source_paths = ['.']

            build_report = {}
            build_properties = {}

            library_build_success = False
            profile = extract_profile(parser, options, internal_tc_name)
            try:
                resource_filter = None
                if target.is_PSA_secure_target:
                    resource_filter = OsAndSpeResourceFilter()
                    generate_psa_sources(source_dirs=base_source_paths,
                                         ignore_paths=[options.build_dir])

                # Build sources
                notify = TerminalNotifier(options.verbose, options.silent)
                build_library(base_source_paths,
                              options.build_dir,
                              mcu,
                              toolchain_name,
                              jobs=options.jobs,
                              clean=options.clean,
                              report=build_report,
                              properties=build_properties,
                              name="mbed-build",
                              macros=options.macros,
                              notify=notify,
                              archive=False,
                              app_config=config,
                              build_profile=profile,
                              ignore=options.ignore,
                              resource_filter=resource_filter)

                library_build_success = True
            except ToolException as e:
                # ToolException output is handled by the build log
                print("[ERROR] " + str(e))
                pass
            except NotSupportedException as e:
                # NotSupportedException is handled by the build log
                print("[ERROR] " + str(e))
                pass
            except Exception as e:
                if options.verbose:
                    import traceback
                    traceback.print_exc()
                # Some other exception occurred, print the error message
                print(e)

            if not library_build_success:
                print("Failed to build library")
            else:
                if target.is_PSA_secure_target:
                    resource_filter = SpeOnlyResourceFilter()
                else:
                    resource_filter = None

                # Build all the tests
                notify = TerminalNotifier(options.verbose, options.silent)
                test_build_success, test_build = build_tests(
                    tests, [os.path.relpath(options.build_dir)],
                    options.build_dir,
                    mcu,
                    toolchain_name,
                    clean=options.clean,
                    report=build_report,
                    properties=build_properties,
                    macros=options.macros,
                    notify=notify,
                    jobs=options.jobs,
                    continue_on_build_fail=options.continue_on_build_fail,
                    app_config=config,
                    build_profile=profile,
                    stats_depth=options.stats_depth,
                    ignore=options.ignore,
                    resource_filter=resource_filter)

                # If a path to a test spec is provided, write it to a file
                if options.test_spec:
                    write_json_to_file(test_spec_from_test_builds(test_build),
                                       options.test_spec)

            # If a path to a JUnit build report spec is provided, write it to a file
            if options.build_report_junit:
                report_exporter = ReportExporter(ResultExporterType.JUNIT,
                                                 package="build")
                report_exporter.report_to_file(
                    build_report,
                    options.build_report_junit,
                    test_suite_properties=build_properties)

            # Print memory map summary on screen
            if build_report:
                print()
                print(print_build_memory_usage(build_report))

            print_report_exporter = ReportExporter(ResultExporterType.PRINT,
                                                   package="build")
            status = print_report_exporter.report(build_report)
            if options.build_data:
                merge_build_data(options.build_data, build_report, "test")

            if status:
                sys.exit(0)
            else:
                sys.exit(1)

    except KeyboardInterrupt as e:
        print("\n[CTRL+c] exit")
    except ConfigException as e:
        # Catching ConfigException here to prevent a traceback
        print("[ERROR] %s" % str(e))
        error = True
    except Exception as e:
        import traceback
        traceback.print_exc(file=sys.stdout)
        print("[ERROR] %s" % str(e))
        error = True

    print_end_warnings(end_warnings)
    if error:
        sys.exit(1)
Esempio n. 16
0
                base_source_paths = ['.']
            
            
            target = TARGET_MAP[options.mcu]
            
            build_report = {}
            build_properties = {}

            library_build_success = False
            try:
                # Build sources
                build_library(base_source_paths, options.build_dir, target, options.tool,
                                                options=options.options,
                                                jobs=options.jobs,
                                                clean=options.clean,
                                                report=build_report,
                                                properties=build_properties,
                                                name="mbed-build",
                                                macros=options.macros,
                                                verbose=options.verbose,
                                                archive=False)
                
                library_build_success = True
            except ToolException, e:
                # ToolException output is handled by the build log
                pass
            except NotSupportedException, e:
                # NotSupportedException is handled by the build log
                pass
            except Exception, e:
                # Some other exception occurred, print the error message
                print e
Esempio n. 17
0
        for target_name, target_toolchains in build_config.items():
            target = TARGET_MAP[target_name]

            for target_toolchain in target_toolchains:
                library_build_success = True

                try:
                    build_directory = join(options.build_dir, target_name,
                                           target_toolchain)
                    # Build sources
                    build_library(base_source_paths,
                                  build_directory,
                                  target,
                                  target_toolchain,
                                  jobs=options.jobs,
                                  clean=options.clean,
                                  report=build_report,
                                  properties=build_properties,
                                  name="mbed-os",
                                  macros=options.macros,
                                  verbose=options.verbose,
                                  archive=False)
                except Exception, e:
                    library_build_success = False
                    print "Failed to build library"
                    print e

                if options.continue_on_build_fail or library_build_success:
                    # Build all the tests
                    all_tests = find_tests(base_source_paths[0], target_name,
                                           toolchain_name)
                    test_build_success, test_build = build_tests(
Esempio n. 18
0
                 print e
 else:
     # Build
     for toolchain in toolchains:
         for target in targets:
             tt_id = "%s::%s" % (toolchain, target)
             try:
                 mcu = TARGET_MAP[target]
                 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,
                         jobs=options.jobs,
                         clean=options.clean,
                         archive=(not options.no_archive),
                         macros=options.macros)
                 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,
Esempio n. 19
0
            # Default base source path is the current directory
            if not base_source_paths:
                base_source_paths = ['.']
            
            build_report = {}
            build_properties = {}

            library_build_success = False
            try:
                # Build sources
                build_library(base_source_paths, options.build_dir, mcu, toolchain,
                                                options=options.options,
                                                jobs=options.jobs,
                                                clean=options.clean,
                                                report=build_report,
                                                properties=build_properties,
                                                name="mbed-build",
                                                macros=options.macros,
                                                verbose=options.verbose,
                                                notify=notify,
                                                archive=False,
                                                remove_config_header_file=True)

                library_build_success = True
            except ToolException, e:
                # ToolException output is handled by the build log
                pass
            except NotSupportedException, e:
                # NotSupportedException is handled by the build log
                pass
            except Exception, e:
                # Some other exception occurred, print the error message