Changeset b1c2cb4 in rtems-source-builder


Ignore:
Timestamp:
07/14/19 04:03:06 (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
5, master
Children:
831ae05
Parents:
f68f0d9
git-author:
Chris Johns <chrisj@…> (07/14/19 04:03:06)
git-committer:
Chris Johns <chrisj@…> (07/21/19 11:09:34)
Message:

sb/setbuilder: Support staging of build set build before installing.

  • Staging lets build sets use previously built build sets.
  • Fix the rtems-bsp builds to support staging.
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • rtems/config/5/rtems-libbsd.bset

    rf68f0d9 rb1c2cb4  
    44
    55#
    6 # Build the kernel.
     6# Build the BSD library for RTEMS.
    77#
    88tools/rtems-libbsd-5
  • rtems/config/rtems-bsp.cfg

    rf68f0d9 rb1c2cb4  
    2525# and BSPs. Only after the source to download.
    2626#
    27 %if %{_dry_run} && %{defined with_download}
     27%if %{_dry_run}
    2828 %log BSP configuration errors ignored
    2929 %define rtems_bsp_error 0
     
    3737#
    3838%if %{defined rtems_host}
    39  %define _host %{rtems_host}
     39 %{triplet _host %{rtems_host}}
    4040%endif
    4141%if %{rtems_bsp_error}
     
    5656
    5757#
    58 # If no tools or RTEMS provided use the prefix.
     58# If no tools or RTEMS provided use the prefix. If staging use the staging
     59# root.
    5960#
    6061%ifn %{defined with_tools}
    61  %define with_tools %{_prefix}
    62  %define rtems_waf_tools %{nil}
     62 %if %{install_mode} == staging
     63  %define with_tools %{stagingroot}
     64  %define rtems_waf_tools --rtems-tools=%{with_tools}
     65 %else
     66  %define with_tools %{_prefix}
     67  %define rtems_waf_tools %{nil}
     68 %endif
    6369%else
    6470 %define rtems_waf_tools --rtems-tools=%{with_tools}
     
    6672
    6773%ifn %{defined with_rtems}
    68  %define with_rtems %{_prefix}
    69  %define rtems_waf_rtems %{nil}
     74 %if %{install_mode} == staging
     75  %define with_rtems %{stagingroot}
     76  %define rtems_waf_rtems --rtems=%{with_rtems}
     77 %else
     78  %define with_rtems %{_prefix}
     79  %define rtems_waf_rtems %{nil}
     80 %endif
    7081%else
    7182 %define rtems_waf_rtems --rtems=%{with_rtems}
     
    112123#
    113124%define rtems_bsp_cc      %{_host}-gcc
     125%define rtems_bsp_cxx     %{_host}-g++
    114126%define rtems_bsp_incpath %{with_rtems}/%{_host}/%{rtems_bsp}/include
    115127%define rtems_bsp_libpath %{with_rtems}/%{_host}/%{rtems_bsp}/lib
     
    161173# Map to names used for cross compiling.
    162174#
     175%define host_cc       %{rtems_bsp_cc}
     176%define host_cxx      %{rtems_bsp_cxx}
    163177%define host_includes -I%{_includedir}
    164178%define host_cflags   %{rtems_bsp_cflags}
  • rtems/config/tools/rtems-libbsd-common.cfg

    rf68f0d9 rb1c2cb4  
    6363    --prefix=%{_prefix} \
    6464    %{rtems_waf_tools} \
    65     %{rtems_waf_rtems}
     65    %{rtems_waf_rtems} \
    6666    --rtems-bsp=%{rtems_bsp_arch_bsp}
    6767
  • source-builder/defaults.mc

    rf68f0d9 rb1c2cb4  
    7575build_includes:      none,    convert,  ''
    7676build_libs:          none,    convert,  ''
     77
     78#
     79# Build and staging paths.
     80#
     81buildroot:           dir,     none,     '%{_tmppath}/%{buildname}-%{_uid}'
     82buildcxcroot:        dir,     none,     '%{_tmppath}/%{buildname}-%{_uid}-cxc'
     83buildxcroot:         dir,     none,     '%{_tmppath}/%{buildname}-%{_uid}-xx'
     84stagingroot:         dir,     none,     '%{_tmppath}/sb-%{_uid}-staging'
     85
     86#
     87# Install mode can be installing or staging. Defaults to installing.
     88#
     89install_mode:        none,    none,     'installing'
    7790
    7891# Extra path a platform can override.
     
    97110_tmproot:            dir,     none,     '%{_tmppath}/sb-%{_uid}/%{_bset_tmp}'
    98111_tmpcxcroot:         dir,     none,     '%{_tmppath}/sb-%{_uid}-cxc/%{_bset_tmp}'
    99 buildroot:           dir,     none,     '%{_tmppath}/%{buildname}-%{_uid}'
    100 buildcxcroot:        dir,     none,     '%{_tmppath}/%{buildname}-%{_uid}-cxc'
    101 buildxcroot:         dir,     none,     '%{_tmppath}/%{buildname}-%{_uid}-xx'
    102112_datadir:            dir,     none,     '%{_prefix}/share'
    103113_defaultdocdir:      dir,     none,     '%{_prefix}/share/doc'
  • source-builder/sb/setbuilder.py

    rf68f0d9 rb1c2cb4  
    4242    import path
    4343    import reports
     44    import shell
    4445    import sources
    4546    import version
     
    5152    sys.exit(1)
    5253
     54def macro_expand(macros, _str):
     55    cstr = None
     56    while cstr != _str:
     57        cstr = _str
     58        _str = macros.expand(_str)
     59        _str = shell.expand(macros, _str)
     60    return _str
     61
    5362class log_capture(object):
    5463    def __init__(self):
     
    7281
    7382    def __init__(self, bset, _configs, opts, macros = None):
    74         log.trace('_bset: %s: init' % (bset))
     83        log.trace('_bset:   : %s: init' % (bset))
    7584        self.configs = _configs
    7685        self.opts = opts
     
    7988        else:
    8089            self.macros = copy.copy(macros)
    81         log.trace('_bset: %s: macro defaults' % (bset))
     90        log.trace('_bset:   : %s: macro defaults' % (bset))
    8291        log.trace(str(self.macros))
    8392        self.bset = bset
    84         _target = self.macros.expand('%{_target}')
     93        _target = macro_expand(self.macros, '%{_target}')
    8594        if len(_target):
    8695            pkg_prefix = _target
    8796        else:
    88             pkg_prefix = self.macros.expand('%{_host}')
     97            pkg_prefix = macro_expand(self.macros, '%{_host}')
    8998        self.bset_pkg = '%s-%s-set' % (pkg_prefix, self.bset)
    9099        self.mail_header = ''
     
    153162                raise error.general('invalid report format: %s' % (format))
    154163            buildroot = _build.config.abspath('%{buildroot}')
    155             prefix = _build.macros.expand('%{_prefix}')
     164            prefix = macro_expand(_build.macros, '%{_prefix}')
    156165            name = _build.main_package().name() + ext
    157166            log.notice('reporting: %s -> %s' % (_config, name))
     
    183192        what = '%s -> %s' % \
    184193            (os.path.relpath(path.host(src)), os.path.relpath(path.host(dst)))
    185         log.trace('_bset: %s: collecting: %s' % (self.bset, what))
     194        log.trace('_bset:   : %s: collecting: %s' % (self.bset, what))
    186195        self.copy(src, dst)
    187196
    188     def install(self, name, buildroot, prefix):
    189         dst = prefix
    190         src = path.join(buildroot, prefix)
    191         log.notice('installing: %s -> %s' % (name, path.host(dst)))
     197    def install(self, mode, name, src, dst):
     198        log.notice('%s: %s -> %s' % (mode, name, path.host(dst)))
    192199        self.copy(src, dst)
    193200
     201    def install_mode(self):
     202        return macro_expand(self.macros, '%{install_mode}')
     203
     204    def installing(self):
     205        return self.install_mode() == 'installing'
     206
     207    def staging(self):
     208        return not self.installing()
     209
    194210    def canadian_cross(self, _build):
    195         log.trace('_bset: Cxc for build machine: _build => _host')
     211        log.trace('_bset:   : Cxc for build machine: _build => _host')
    196212        macros_to_copy = [('%{_host}',        '%{_build}'),
    197213                          ('%{_host_alias}',  '%{_build_alias}'),
     
    205221        cxc_macros = _build.copy_init_macros()
    206222        for m in macros_to_copy:
    207             log.trace('_bset: Cxc: %s <= %s' % (m[0], cxc_macros[m[1]]))
     223            log.trace('_bset:   : Cxc: %s <= %s' % (m[0], cxc_macros[m[1]]))
    208224            cxc_macros[m[0]] = cxc_macros[m[1]]
    209225        _build.set_macros(cxc_macros)
     
    230246           and not _build.macros.get('%{_disable_packaging}'):
    231247            path.mkdir(tardir)
    232             tar = path.join(tardir, _build.config.expand('%s.tar.bz2' % (_build.main_package().name())))
     248            tar = path.join(tardir,
     249                            _build.config.expand('%s.tar.bz2' % \
     250                                                 (_build.main_package().name())))
    233251            log.notice('tarball: %s' % (os.path.relpath(path.host(tar))))
    234252            if not self.opts.dry_run():
    235253                tmproot = _build.config.expand('%{_tmproot}')
    236254                cmd = _build.config.expand('"cd ' + tmproot + \
    237                                                ' && %{__tar} -cf - . | %{__bzip2} > ' + tar + '"')
     255                                           ' && %{__tar} -cf - . | %{__bzip2} > ' + \
     256                                           tar + '"')
    238257                _build.run(cmd, shell_opts = '-c', cwd = tmproot)
    239258
     
    250269
    251270        if not path.exists(bsetname):
    252             for cp in self.macros.expand('%{_configdir}').split(':'):
     271            for cp in macro_expand(self.macros, '%{_configdir}').split(':'):
    253272                configdir = path.abspath(cp)
    254273                bsetname = path.join(configdir, bset)
     
    259278                raise error.general('no build set file found: %s' % (bset))
    260279        try:
    261             log.trace('_bset: %s: open: %s' % (self.bset, bsetname))
     280            log.trace('_bset:   : %s: open: %s' % (self.bset, bsetname))
    262281            bset = open(path.host(bsetname), 'r')
    263282        except IOError as err:
     
    273292                if len(l) == 0:
    274293                    continue
    275                 log.trace('_bset: %s: %03d: %s' % (self.bset, lc, l))
     294                log.trace('_bset:   : %s: %03d: %s' % (self.bset, lc, l))
    276295                ls = l.split()
    277296                if ls[0][-1] == ':' and ls[0][:-1] == 'package':
     
    289308                    elif ls[0] == '%undefine':
    290309                        if len(ls) > 2:
    291                             raise error.general('%s:%d: %undefine requires just the name' % \
    292                                                     (self.bset, lc))
     310                            raise error.general('%s:%d: %undefine requires ' \
     311                                                'just the name' % (self.bset, lc))
    293312                        self.macros.undefine(ls[1].strip())
    294313                    elif ls[0] == '%include':
     
    302321                    c = build.find_config(l, self.configs)
    303322                    if c is None:
    304                         raise error.general('%s:%d: cannot find file: %s' % (self.bset, lc, l))
     323                        raise error.general('%s:%d: cannot find file: %s' % (self.bset,
     324                                                                             lc, l))
    305325                    configs += [c]
    306326        except:
     
    321341            configs = [self.bset]
    322342        else:
    323             exbset = self.macros.expand(self.bset)
     343            exbset = macro_expand(self.macros, self.bset)
    324344            self.macros['_bset'] = exbset
    325             self.macros['_bset_tmp'] = build.short_name(exbset)
     345            bset_tmp = build.short_name(exbset)
     346            if bset_tmp.endswith('.bset'):
     347                bset_tmp = bset_tmp[:-5]
     348            self.macros['_bset_tmp'] = bset_tmp
    326349            root, ext = path.splitext(exbset)
    327350            if exbset.endswith('.bset'):
     
    341364            mail['output'].clear()
    342365
    343         log.trace('_bset: %s: make' % (self.bset))
     366        log.trace('_bset: %2d: %s: make' % (nesting_count, self.bset))
    344367        log.notice('Build Set: %s' % (self.bset))
    345368
     
    351374        start = datetime.datetime.now()
    352375
    353         mail_report = False
    354         have_errors = False
     376        mail_report  = False
     377        have_errors  = False
    355378
    356379        if mail:
    357380            mail['output'].clear()
    358381
     382        #
     383        # If this is the outter most buildset it's files installed. Nested
     384        # build sets staged their installed file. The staged files are install
     385        # when the outtter most build finishes.
     386        #
     387        if nesting_count != 1:
     388            if self.installing():
     389                self.macros['install_mode'] = 'staging'
     390                #
     391                # Prepend staging areas, bin directory tothe
     392                # path. Lets the later package depend on the eailier
     393                # ones.
     394                #
     395                pathprepend = ['%{stagingroot}/bin'] + \
     396                    macro_expand(self.macros, '%{_pathprepend}').split(':')
     397                pathprepend = [pp for pp in pathprepend if len(pp)]
     398                if len(pathprepend) == 1:
     399                    self.macros['_pathprepend'] = pathprepend[0]
     400                else:
     401                    self.macros['_pathprepend'] = ':'.join(pathprepend)
     402
     403        #
     404        # Only the outter build set can have staging to install. Get the staging
     405        # root via the config because it could require a valid config.
     406        #
     407        have_staging = False
     408
    359409        try:
    360410            configs = self.load()
    361411
    362             log.trace('_bset: %s: configs: %s'  % (self.bset, ','.join(configs)))
     412            log.trace('_bset: %2d: %s: configs: %s'  % (nesting_count,
     413                                                        self.bset, ', '.join(configs)))
    363414
    364415            sizes_valid = False
     
    375426                    macros = copy.copy(self.macros)
    376427                    if configs[s].endswith('.bset'):
    377                         log.trace('_bset: == %2d %s' % (nesting_count + 1, '=' * 75))
     428                        log.trace('_bset: %2d: %s %s' % (nesting_count,
     429                                                         configs[s],
     430                                                         '=' * (74 - len(configs[s]))))
    378431                        bs = buildset(configs[s], self.configs, opts, macros)
    379432                        bs.build(deps, nesting_count, mail)
     433                        if self.installing():
     434                            have_staging = True
    380435                        del bs
    381436                    elif configs[s].endswith('.cfg'):
    382437                        if mail:
    383438                            mail_report = True
    384                         log.trace('_bset: -- %2d %s' % (nesting_count + 1, '-' * 75))
     439                        log.trace('_bset: %2d: %s %s' % (nesting_count,
     440                                                         configs[s],
     441                                                         '=' * (74 - len(configs[s]))))
    385442                        try:
    386443                            b = build.build(configs[s],
     
    413470                        # Dump post build macros.
    414471                        #
    415                         log.trace('_bset: macros post-build')
     472                        log.trace('_bset:   : macros post-build')
    416473                        log.trace(str(b.macros))
    417474                    else:
     
    437494                        raise
    438495            #
    439             # Installing ...
    440             #
    441             log.trace('_bset: installing: deps:%r no-install:%r' % \
    442                       (deps is None, self.opts.no_install()))
    443             if deps is None \
    444                and not self.opts.no_install() \
    445                and not have_errors:
     496            # Installing or staging ...
     497            #
     498            log.trace('_bset: %2d: %s: deps:%r no-install:%r' % \
     499                      (nesting_count, self.install_mode(),
     500                       deps is None, self.opts.no_install()))
     501            log.trace('_bset: %2d: %s: builds: %s' % \
     502                      (nesting_count, self.install_mode(),
     503                       ', '.join([b.name() for b in builds])))
     504            if deps is None and not have_errors:
    446505                for b in builds:
    447                     log.trace('_bset: installing: %r' % b.installable())
     506                    log.trace('_bset:   : %s: %r' % (self.install_mode(),
     507                                                     b.installable()))
    448508                    if b.installable():
    449                         self.install(b.name(),
    450                                      b.config.expand('%{buildroot}'),
    451                                      b.config.expand('%{_prefix}'))
     509                        prefix = b.config.expand('%{_prefix}')
     510                        buildroot = path.join(b.config.expand('%{buildroot}'), prefix)
     511                        if self.staging():
     512                            prefix = b.config.expand('%{stagingroot}')
     513                        self.install(self.install_mode(), b.name(), buildroot, prefix)
     514
    452515            #
    453516            # Sizes ...
     
    470533                    size_patches += path.get_size(p)
    471534                size_total = size_sources + size_patches + size_installed
    472                 build_max_size_human = build.humanize_number(size_build_max + size_installed, 'B')
     535                build_max_size_human = build.humanize_number(size_build_max +
     536                                                             size_installed, 'B')
    473537                build_total_size_human = build.humanize_number(size_total, 'B')
    474538                build_sources_size_human = build.humanize_number(size_sources, 'B')
     
    500564            for b in builds:
    501565                del b
     566
     567            #
     568            # If builds have been staged install into the finaly prefix.
     569            #
     570            if have_staging and not self.opts.no_install() and not have_errors:
     571                log.trace('_bset: %2d: install staging' % (nesting_count))
     572                stagingroot = macro_expand(self.macros, '%{stagingroot}')
     573                prefix = macro_expand(self.macros, '%{_prefix}')
     574                self.install(self.install_mode(), self.bset, stagingroot, prefix)
     575                staging_size = path.get_size(stagingroot)
     576                if not self.opts.no_clean() or self.opts.always_clean():
     577                    log.notice('clean staging: %s' % (self.bset))
     578                    log.trace('cleanup: %s' % (stagingroot))
     579                    self.rmdir(stagingroot)
     580                log.notice('Staging Size: %s' % (build.humanize_number(staging_size)))
    502581        except error.general as gerr:
    503582            if not build_error:
     
    587666                mail['to'] = to_addr[1]
    588667            else:
    589                 mail['to'] = opts.defaults.expand('%{_mail_tools_to}')
     668                mail['to'] = macro_expand(opts.defaults, '%{_mail_tools_to}')
    590669            mail['from'] = mail['mail'].from_address()
    591670        log.notice('RTEMS Source Builder - Set Builder, %s' % (version.str()))
     
    607686            deps = None
    608687        if not list_bset_cfg_files(opts, configs):
    609             prefix = opts.defaults.expand('%{_prefix}')
     688            prefix = macro_expand(opts.defaults, '%{_prefix}')
    610689            if opts.canadian_cross():
    611690                opts.disable_install()
Note: See TracChangeset for help on using the changeset viewer.