Ejemplo n.º 1
0
def run(args):
    b = None
    ec = 0
    try:
        rtems.clean_windows_path()

        start = _now()
        prefix = '/opt/rtems/%s' % (rtems_version())
        tools = prefix
        build_dir = 'bsp-builds'
        logf = 'bsp-build-%s.txt' % (_now().strftime('%Y%m%d-%H%M%S'))
        config_file = rtems.bsp_configuration_file(prog=args[0])

        description = 'RTEMS BSP Builder is a BSP build tester. It builds BSPs '
        description += 'in various ways to test build regressions in the kernel. You '
        description += 'can build based on tier, architecture, or BSP. You can control '
        description += 'the profile of build with various build configuration settings.'

        argsp = argparse.ArgumentParser(prog='rtems-bsp-builder',
                                        description=description)
        argsp.add_argument('--prefix',
                           help='Prefix to build the BSP.',
                           type=str)
        argsp.add_argument('--rtems-tools',
                           help='The RTEMS tools directory.',
                           type=str)
        argsp.add_argument('--rtems', help='The RTEMS source tree.', type=str)
        argsp.add_argument('--build-path', help='Path to build in.', type=str)
        argsp.add_argument('--log', help='Log file.', type=str)
        argsp.add_argument('--config-report',
                           help='Report the configuration.',
                           type=str,
                           default=None,
                           choices=['all', 'profiles', 'builds', 'archs'])
        argsp.add_argument('--warnings-report',
                           help='Report the warnings to a file.',
                           type=str,
                           default=None)
        argsp.add_argument('--failures-report',
                           help='Report the failures to a file.',
                           type=str,
                           default=None)
        argsp.add_argument('--stop-on-error',
                           help='Stop on an error.',
                           action='store_true')
        argsp.add_argument('--no-clean',
                           help='Do not clean the build output.',
                           action='store_true')
        argsp.add_argument(
            '--profiles',
            help='Build the listed profiles (profile,profile,..).',
            type=str,
            default='tier-1')
        argsp.add_argument('--arch',
                           help='Build the architectures (arch,arch,..).',
                           type=str)
        argsp.add_argument('--bsp',
                           help='Build the BSPs (arch/bsp,arch/bsp,..).',
                           type=str)
        argsp.add_argument('--build',
                           help='Build name to build (see --config-report).',
                           type=str,
                           default='all')
        argsp.add_argument('--jobs',
                           help='Number of jobs to run.',
                           type=str,
                           default='1/%d' % (host.cpus()))
        argsp.add_argument('--dry-run',
                           help='Do not run the actual builds.',
                           action='store_true')
        mailer.add_arguments(argsp)

        opts = argsp.parse_args(args[1:])
        mail = None
        if opts.mail:
            mail = mailer.mail(opts)
            # Request these now to generate any errors.
            from_addr = mail.from_address()
            smtp_host = mail.smtp_host()
            if 'mail_to' in opts and opts.mail_to is not None:
                to_addr = opts.mail_to
            else:
                to_addr = '*****@*****.**'
        if opts.log is not None:
            logf = opts.log
        log.default = log.log([logf])
        log.notice(title())
        log.output(command_line())
        if mail:
            log.notice('Mail: from:%s to:%s smtp:%s' %
                       (from_addr, to_addr, smtp_host))

        config = rtems.configuration()
        config.load(config_file, opts.build)

        if opts.config_report:
            log.notice('Configuration Report: %s' % (opts.config_report))
            c_profiles = False
            c_builds = False
            c_archs = False
            if opts.config_report == 'all':
                c_profiles = True
                c_builds = True
                c_archs = True
            elif opts.config_report == 'profiles':
                c_profiles = True
            elif opts.config_report == 'builds':
                c_builds = True
            elif opts.config_report == 'archs':
                c_archs = True
            log.notice(config.report(c_profiles, c_builds, c_archs))
            sys.exit(0)

        if opts.rtems is None:
            raise error.general('No RTEMS source provided on the command line')
        if opts.prefix is not None:
            prefix = path.shell(opts.prefix)
        if opts.rtems_tools is not None:
            tools = path.shell(opts.rtems_tools)
        if opts.build_path is not None:
            build_dir = path.shell(opts.build_path)

        options = {
            'stop-on-error': opts.stop_on_error,
            'no-clean': opts.no_clean,
            'dry-run': opts.dry_run,
            'jobs': opts.jobs,
            'warnings-report': opts.warnings_report,
            'failures-report': opts.failures_report
        }

        b = builder(config, rtems_version(), prefix, tools,
                    path.shell(opts.rtems), build_dir, options)

        profiles = comma_split(opts.profiles)
        archs = comma_split(opts.arch)
        bsps = comma_split(opts.bsp)

        #
        # The default is build a profile.
        #
        if bsps is not None:
            if archs is not None:
                raise error.general('--arch supplied with --bsp;' \
                                    ' use --bsp=arch/bsp,arch/bsp,..')
            what = 'BSPs: %s' % (' '.join(bsps))
            b.build_bsps(bsps)
        elif archs is not None:
            what = 'Archs: %s' % (' '.join(archs))
            b.build_archs(archs)
        else:
            what = 'Profile(s): %s' % (' '.join(profiles))
            b.build_profiles(profiles)
        end = _now()

        #
        # Email the results of the build.
        #
        if mail is not None:
            subject = '[rtems-bsp-builder] %s: %s' % (str(start).split('.')[0],
                                                      what)
            t = title()
            body = t + os.linesep
            body += '=' * len(t) + os.linesep
            body += os.linesep
            body += 'Host: %s' % (os.uname()[3]) + os.linesep
            body += os.linesep
            body += command_line()
            body += os.linesep
            body += 'Total Time            : %s for %d completed job(s)' % \
                    (str(b.duration), b.jobs_completed)
            body += os.linesep
            body += 'Average BSP Build Time: %s' % (str(b.average))
            body += os.linesep + os.linesep
            body += 'Builds' + os.linesep
            body += '======' + os.linesep
            body += os.linesep.join([' ' + cb for cb in config.builds()])
            body += os.linesep + os.linesep
            body += 'Failures Report' + os.linesep
            body += '===============' + os.linesep
            body += b.results.failures_report()
            body += os.linesep
            body += 'Warnings Report' + os.linesep
            body += '===============' + os.linesep
            body += b.results.warnings_report(summary=True)
            mail.send(to_addr, subject, body)

    except error.general as gerr:
        print(gerr)
        print('BSP Build FAILED', file=sys.stderr)
        ec = 1
    except error.internal as ierr:
        print(ierr)
        print('BSP Build FAILED', file=sys.stderr)
        ec = 1
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        ec = 1
    if b is not None:
        b.results.report()
    sys.exit(ec)
Ejemplo n.º 2
0
def run_args(args):
    b = None
    ec = 0
    try:
        #
        # On Windows MSYS2 prepends a path to itself to the environment
        # path. This means the RTEMS specific automake is not found and which
        # breaks the bootstrap. We need to remove the prepended path. Also
        # remove any ACLOCAL paths from the environment.
        #
        if os.name == 'nt':
            cspath = os.environ['PATH'].split(os.pathsep)
            if 'msys' in cspath[0] and cspath[0].endswith('bin'):
                os.environ['PATH'] = os.pathsep.join(cspath[1:])

        top = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
        prefix = '/opt/rtems/%s' % (rtems_version())
        tools = prefix
        build_dir = 'bsp-builds'
        logf = 'bsp-build-%s.txt' % (datetime.datetime.now().strftime('%Y%m%d-%H%M%S'))
        config_file = path.join(top, 'share', 'rtems', 'tester', 'rtems', 'rtems-bsps.ini')
        if not path.exists(config_file):
            config_file = path.join(top, 'tester', 'rtems', 'rtems-bsps.ini')

        argsp = argparse.ArgumentParser()
        argsp.add_argument('--prefix', help = 'Prefix to build the BSP.', type = str)
        argsp.add_argument('--rtems-tools', help = 'The RTEMS tools directory.', type = str)
        argsp.add_argument('--rtems', help = 'The RTEMS source tree.', type = str)
        argsp.add_argument('--build-path', help = 'Path to build in.', type = str)
        argsp.add_argument('--log', help = 'Log file.', type = str)
        argsp.add_argument('--stop-on-error', help = 'Stop on an error.',
                           action = 'store_true')
        argsp.add_argument('--no-clean', help = 'Do not clean the build output.',
                           action = 'store_true')
        argsp.add_argument('--profiles', help = 'Build the listed profiles.',
                           type = str, default = 'tier-1')
        argsp.add_argument('--build', help = 'Build variation.', type = str)
        argsp.add_argument('--arch', help = 'Build the specific architecture.', type = str)
        argsp.add_argument('--bsp', help = 'Build the specific BSP.', type = str)
        argsp.add_argument('--dry-run', help = 'Do not run the actual builds.',
                           action = 'store_true')

        opts = argsp.parse_args(args[1:])
        if opts.log is not None:
            logf = opts.log
        log.default = log.log([logf])
        log.notice('RTEMS Tools Project - RTEMS Kernel BSP Builder, %s' % (version.str()))
        if opts.rtems is None:
            raise error.general('No RTEMS source provided on the command line')
        if opts.prefix is not None:
            prefix = path.shell(opts.prefix)
        if opts.rtems_tools is not None:
            tools = path.shell(opts.rtems_tools)
        if opts.build_path is not None:
            build_dir = path.shell(opts.build_path)
        if opts.bsp is not None and opts.arch is None:
            raise error.general('BSP provided but no architecture')

        config = configuration()
        config.load(config_file, opts.build)

        options = { 'stop-on-error' : opts.stop_on_error,
                    'no-clean'      : opts.no_clean,
                    'dry-run'       : opts.dry_run,
                    'jobs'          : 8 }

        b = build(config, rtems_version(), prefix, tools,
                  path.shell(opts.rtems), build_dir, options)
        if opts.arch is not None:
            if opts.bsp is not None:
                b.build_arch_bsp(opts.arch, opts.bsp)
            else:
                b.build_arch(opts.arch)
        else:
            for profile in opts.profiles.split(','):
                b.build_profile(profile.strip())

    except error.general as gerr:
        print(gerr)
        print('BSP Build FAILED', file = sys.stderr)
        ec = 1
    except error.internal as ierr:
        print(ierr)
        print('BSP Build FAILED', file = sys.stderr)
        ec = 1
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        ec = 1
    if b is not None:
        b.results.report()
    sys.exit(ec)
Ejemplo n.º 3
0
def run_args(args):
    b = None
    ec = 0
    try:
        #
        # On Windows MSYS2 prepends a path to itself to the environment
        # path. This means the RTEMS specific automake is not found and which
        # breaks the bootstrap. We need to remove the prepended path. Also
        # remove any ACLOCAL paths from the environment.
        #
        if os.name == 'nt':
            cspath = os.environ['PATH'].split(os.pathsep)
            if 'msys' in cspath[0] and cspath[0].endswith('bin'):
                os.environ['PATH'] = os.pathsep.join(cspath[1:])

        top = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
        prefix = '/opt/rtems/%s' % (rtems_version())
        tools = prefix
        build_dir = 'bsp-builds'
        logf = 'bsp-build-%s.txt' % (
            datetime.datetime.now().strftime('%Y%m%d-%H%M%S'))
        config_file = path.join(top, 'share', 'rtems', 'tester', 'rtems',
                                'rtems-bsps.ini')
        if not path.exists(config_file):
            config_file = path.join(top, 'tester', 'rtems', 'rtems-bsps.ini')

        argsp = argparse.ArgumentParser()
        argsp.add_argument('--prefix',
                           help='Prefix to build the BSP.',
                           type=str)
        argsp.add_argument('--rtems-tools',
                           help='The RTEMS tools directory.',
                           type=str)
        argsp.add_argument('--rtems', help='The RTEMS source tree.', type=str)
        argsp.add_argument('--build-path', help='Path to build in.', type=str)
        argsp.add_argument('--log', help='Log file.', type=str)
        argsp.add_argument('--stop-on-error',
                           help='Stop on an error.',
                           action='store_true')
        argsp.add_argument('--no-clean',
                           help='Do not clean the build output.',
                           action='store_true')
        argsp.add_argument('--profiles',
                           help='Build the listed profiles.',
                           type=str,
                           default='tier-1')
        argsp.add_argument('--build', help='Build variation.', type=str)
        argsp.add_argument('--arch',
                           help='Build the specific architecture.',
                           type=str)
        argsp.add_argument('--bsp', help='Build the specific BSP.', type=str)
        argsp.add_argument('--dry-run',
                           help='Do not run the actual builds.',
                           action='store_true')

        opts = argsp.parse_args(args[1:])
        if opts.log is not None:
            logf = opts.log
        log.default = log.log([logf])
        log.notice('RTEMS Tools Project - RTEMS Kernel BSP Builder, %s' %
                   (version.str()))
        if opts.rtems is None:
            raise error.general('No RTEMS source provided on the command line')
        if opts.prefix is not None:
            prefix = path.shell(opts.prefix)
        if opts.rtems_tools is not None:
            tools = path.shell(opts.rtems_tools)
        if opts.build_path is not None:
            build_dir = path.shell(opts.build_path)
        if opts.bsp is not None and opts.arch is None:
            raise error.general('BSP provided but no architecture')

        config = configuration()
        config.load(config_file, opts.build)

        options = {
            'stop-on-error': opts.stop_on_error,
            'no-clean': opts.no_clean,
            'dry-run': opts.dry_run,
            'jobs': 8
        }

        b = build(config, rtems_version(), prefix, tools,
                  path.shell(opts.rtems), build_dir, options)
        if opts.arch is not None:
            if opts.bsp is not None:
                b.build_arch_bsp(opts.arch, opts.bsp)
            else:
                b.build_arch(opts.arch)
        else:
            for profile in opts.profiles.split(','):
                b.build_profile(profile.strip())

    except error.general as gerr:
        print(gerr)
        print('BSP Build FAILED', file=sys.stderr)
        ec = 1
    except error.internal as ierr:
        print(ierr)
        print('BSP Build FAILED', file=sys.stderr)
        ec = 1
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        ec = 1
    if b is not None:
        b.results.report()
    sys.exit(ec)