diff options
author | Chris Johns <chrisj@rtems.org> | 2013-04-29 09:01:14 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2013-04-29 09:01:14 +1000 |
commit | adf09460a298bf241d7e61bfe620a5e5dd73416d (patch) | |
tree | d0cab182ce84f317c886d58a6478cbe918cc9bed /source-builder/sb/setbuilder.py | |
parent | Add a function to return the config file name. (diff) | |
download | rtems-source-builder-adf09460a298bf241d7e61bfe620a5e5dd73416d.tar.bz2 |
Report from the setbuilder's build config.
Refactor the reporter to allow the setbuilder to use its build config
rather than regenerating the configuration from the configuration file.
Using the config file and the build macros exposed an issue if a
macro was undefined that was defined in a build set above the
config file. Using the build set's configuration as used to build
is a better solution.
The reporter was refactored to allow a config class to be used
to report.
The setbuild can now take a configuration file as an input file.
Diffstat (limited to 'source-builder/sb/setbuilder.py')
-rw-r--r-- | source-builder/sb/setbuilder.py | 78 |
1 files changed, 59 insertions, 19 deletions
diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py index 171f59f..80dc2cd 100644 --- a/source-builder/sb/setbuilder.py +++ b/source-builder/sb/setbuilder.py @@ -59,6 +59,15 @@ class buildset: self.macros = copy.copy(macros) self.bset = bset self.bset_pkg = '%s-%s-set' % (self.macros.expand('%{_target}'), self.bset) + self.email_report = '' + + def write_email_report(self, text, prepend = False): + if len(text) == 0 or text[-1] != '\n' or text[-1] != '\r': + text += os.linesep + if prepend: + self.email_report = text + self.email_report + else: + self.email_report += text def copy(self, src, dst): if not os.path.isdir(path.host(src)): @@ -75,7 +84,7 @@ class buildset: raise error.general('copying tree: %s' % (str(err))) def report(self, _config, _build): - if not _build.opts.get_arg('--no-report'): + if not _build.opts.get_arg('--no-report') and not _build.opts.get_arg('--no-email'): format = _build.opts.get_arg('--report-format') if format is None: format = 'html' @@ -97,13 +106,24 @@ class buildset: buildroot = _build.config.abspath('%{buildroot}') prefix = _build.macros.expand('%{_prefix}') name = _build.main_package().name() + ext - outpath = path.host(path.join(buildroot, prefix, 'share', 'rtems-source-builder')) - outname = path.host(path.join(outpath, name)) log.notice('reporting: %s -> %s' % (_config, name)) - if not _build.opts.dry_run(): - _build.mkdir(outpath) + if not _build.opts.get_arg('--no-report'): + outpath = path.host(path.join(buildroot, prefix, 'share', 'rtems-source-builder')) + outname = path.host(path.join(outpath, name)) r = reports.report(format, self.configs, _build.opts, _build.macros) - r.make(_config, outname) + r.setup() + r.introduction(_build.config.file_name()) + r.config(_build.config, _build.opts, _build.macros) + if not _build.opts.dry_run(): + _build.mkdir(outpath) + r.write(outname) + del r + if not _build.opts.get_arg('--no-email'): + r = reports.report('text', self.configs, _build.opts, _build.macros) + r.setup() + r.introduction(_build.config.file_name()) + r.config(_build.config, _build.opts, _build.macros) + self.email_report += r.out del r def root_copy(self, src, dst): @@ -233,24 +253,32 @@ class buildset: def load(self): - exbset = self.macros.expand(self.bset) - - self.macros['_bset'] = exbset - - root, ext = path.splitext(exbset) - - if exbset.endswith('.bset'): - bset = exbset + # + # If the build set file ends with .cfg the user has passed to the + # buildset builder a configuration so we just return it. + # + if self.bset.endswith('.cfg'): + configs = [self.bset] else: - bset = '%s.bset' % (exbset) - - return self.parse(bset) + exbset = self.macros.expand(self.bset) + self.macros['_bset'] = exbset + root, ext = path.splitext(exbset) + if exbset.endswith('.bset'): + bset = exbset + else: + bset = '%s.bset' % (exbset) + configs = self.parse(bset) + return configs def build(self, deps = None): log.trace('_bset: %s: make' % (self.bset)) log.notice('Build Set: %s' % (self.bset)) + if not self.opts.get_arg('--no-email'): + email_report_header = \ + 'Build Set: %s (%s)' % (self.bset, datetime.datetime.now().ctime()) + configs = self.load() log.trace('_bset: %s: configs: %s' % (self.bset, ','.join(configs))) @@ -271,10 +299,12 @@ class buildset: opts = copy.copy(self.opts) macros = copy.copy(self.macros) if configs[s].endswith('.bset'): + log.trace('_bset: %s' % ('=' * 80)) bs = buildset(configs[s], self.configs, opts, macros) bs.build(deps) del bs elif configs[s].endswith('.cfg'): + log.trace('_bset: %s' % ('-' * 80)) b = build.build(configs[s], self.opts.get_arg('--pkg-tar-files'), opts, macros) if deps is None: @@ -287,6 +317,7 @@ class buildset: else: raise error.general('invalid config type: %s' % (configs[s])) except error.general, gerr: + self.write_email_report(str(gerr)) if self.opts.keep_going(): print gerr if self.opts.always_clean(): @@ -315,6 +346,11 @@ class buildset: log.notice('Build Set: Time %s' % (str(end - start))) + if not self.opts.get_arg('--no-email'): + self.write_email_report('', True) + self.write_email_report(' Build Time %s' % (str(end - start)), True) + self.write_email_report(email_report_header, True) + def list_bset_cfg_files(opts, configs): if opts.get_arg('--list-configs') or opts.get_arg('--list-bsets'): if opts.get_arg('--list-configs'): @@ -335,10 +371,14 @@ def run(): optargs = { '--list-configs': 'List available configurations', '--list-bsets': 'List available build sets', '--list-deps': 'List the dependent files.', + '--bset-tar-file': 'Create a build set tar file', + '--pkg-tar-files': 'Create package tar files', '--no-report': 'Do not create a package report.', '--report-format': 'The report format (text, html, asciidoc).', - '--bset-tar-file': 'Create a build set tar file', - '--pkg-tar-files': 'Create package tar files' } + '--no-email': 'Do not send an email report.', + '--smtp-host': 'SMTP host to send via.', + '--email-to': 'Email address to send the email too.', + '--email-from': 'Email address the report is from.' } opts = options.load(sys.argv, optargs) log.notice('RTEMS Source Builder - Set Builder, v%s' % (version.str())) if not check.host_setup(opts): |