mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
sb: Fix reporting and installing the reports when building.
Switch the default report to text format. Fix the report to support the set builder.
This commit is contained in:
parent
11e1fe1e30
commit
ce60578b8f
@ -247,15 +247,6 @@ class asciidoc_formatter(formatter):
|
|||||||
class html_formatter(asciidoc_formatter):
|
class html_formatter(asciidoc_formatter):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(html_formatter, self).__init__()
|
super(html_formatter, self).__init__()
|
||||||
try:
|
|
||||||
import asciidocapi
|
|
||||||
except:
|
|
||||||
raise error.general('installation error: no asciidocapi found')
|
|
||||||
asciidoc_py = _make_path(self.sbpath, options.basepath, 'asciidoc', 'asciidoc.py')
|
|
||||||
try:
|
|
||||||
self.asciidoc = asciidocapi.AsciiDocAPI(asciidoc_py)
|
|
||||||
except:
|
|
||||||
raise error.general('application error: asciidocapi failed')
|
|
||||||
|
|
||||||
def format(self):
|
def format(self):
|
||||||
return 'html'
|
return 'html'
|
||||||
@ -267,7 +258,16 @@ class html_formatter(asciidoc_formatter):
|
|||||||
import StringIO
|
import StringIO
|
||||||
infile = StringIO.StringIO(self.content)
|
infile = StringIO.StringIO(self.content)
|
||||||
outfile = StringIO.StringIO()
|
outfile = StringIO.StringIO()
|
||||||
self.asciidoc.execute(infile, outfile)
|
try:
|
||||||
|
import asciidocapi
|
||||||
|
except:
|
||||||
|
raise error.general('installation error: no asciidocapi found')
|
||||||
|
asciidoc_py = _make_path(self.sbpath, options.basepath, 'asciidoc', 'asciidoc.py')
|
||||||
|
try:
|
||||||
|
asciidoc = asciidocapi.AsciiDocAPI(asciidoc_py)
|
||||||
|
except:
|
||||||
|
raise error.general('application error: asciidocapi failed')
|
||||||
|
asciidoc.execute(infile, outfile)
|
||||||
out = outfile.getvalue()
|
out = outfile.getvalue()
|
||||||
infile.close()
|
infile.close()
|
||||||
outfile.close()
|
outfile.close()
|
||||||
@ -440,6 +440,20 @@ class report:
|
|||||||
"""Report the build details about a package given a config file."""
|
"""Report the build details about a package given a config file."""
|
||||||
|
|
||||||
def __init__(self, formatter, _configs, opts, macros = None):
|
def __init__(self, formatter, _configs, opts, macros = None):
|
||||||
|
if type(formatter) == str:
|
||||||
|
if formatter == 'text':
|
||||||
|
self.formatter = text_formatter()
|
||||||
|
elif formatter == 'asciidoc':
|
||||||
|
self.formatter = asciidoc_formatter()
|
||||||
|
elif formatter == 'html':
|
||||||
|
self.formatter = html_formatter()
|
||||||
|
elif formatter == 'ini':
|
||||||
|
self.formatter = ini_formatter()
|
||||||
|
elif formatter == 'xml':
|
||||||
|
self.formatter = xml_formatter()
|
||||||
|
else:
|
||||||
|
raise error.general('invalid format: %s' % (formatter))
|
||||||
|
else:
|
||||||
self.formatter = formatter
|
self.formatter = formatter
|
||||||
self.configs = _configs
|
self.configs = _configs
|
||||||
self.opts = opts
|
self.opts = opts
|
||||||
@ -554,9 +568,10 @@ class report:
|
|||||||
name = package.name()
|
name = package.name()
|
||||||
if len(name) == 0:
|
if len(name) == 0:
|
||||||
return
|
return
|
||||||
tree['file'] += [_config.file_name()]
|
|
||||||
sources = self.source(macros)
|
sources = self.source(macros)
|
||||||
patches = self.patch(macros)
|
patches = self.patch(macros)
|
||||||
|
if tree is not None:
|
||||||
|
tree['file'] += [_config.file_name()]
|
||||||
if len(sources):
|
if len(sources):
|
||||||
if 'sources' in tree:
|
if 'sources' in tree:
|
||||||
tree['sources'] = dict(tree['sources'].items() + sources.items())
|
tree['sources'] = dict(tree['sources'].items() + sources.items())
|
||||||
@ -682,14 +697,16 @@ class report:
|
|||||||
except IOError, err:
|
except IOError, err:
|
||||||
raise error.general('writing output file: %s: %s' % (name, err))
|
raise error.general('writing output file: %s: %s' % (name, err))
|
||||||
|
|
||||||
def generate(self, name, tree = None, opts = None, defaults = None):
|
def generate(self, name, tree = None, opts = None, macros = None):
|
||||||
self.bset_nesting += 1
|
self.bset_nesting += 1
|
||||||
self.buildset_start(name)
|
self.buildset_start(name)
|
||||||
if tree is None:
|
if tree is None:
|
||||||
tree = self.tree
|
tree = self.tree
|
||||||
if opts is None:
|
if opts is None:
|
||||||
opts = self.opts
|
opts = self.opts
|
||||||
bset = setbuilder.buildset(name, self.configs, opts, defaults)
|
if macros is None:
|
||||||
|
macros = self.macros
|
||||||
|
bset = setbuilder.buildset(name, self.configs, opts, macros)
|
||||||
if name in tree:
|
if name in tree:
|
||||||
raise error.general('duplicate build set in tree: %s' % (name))
|
raise error.general('duplicate build set in tree: %s' % (name))
|
||||||
tree[name] = { 'bset': { }, 'cfg': { 'file': [] } }
|
tree[name] = { 'bset': { }, 'cfg': { 'file': [] } }
|
||||||
|
@ -90,14 +90,15 @@ class buildset:
|
|||||||
if not self.opts.dry_run():
|
if not self.opts.dry_run():
|
||||||
path.copy_tree(src, dst)
|
path.copy_tree(src, dst)
|
||||||
|
|
||||||
def report(self, _config, _build):
|
def report(self, _config, _build, opts, macros):
|
||||||
if not _build.opts.get_arg('--no-report') \
|
if len(_build.main_package().name()) > 0 \
|
||||||
and not _build.macros.get('%{_disable_reporting}') \
|
and not _build.macros.get('%{_disable_reporting}') \
|
||||||
and _build.opts.get_arg('--mail'):
|
and (not _build.opts.get_arg('--no-report') \
|
||||||
|
or _build.opts.get_arg('--mail')):
|
||||||
format = _build.opts.get_arg('--report-format')
|
format = _build.opts.get_arg('--report-format')
|
||||||
if format is None:
|
if format is None:
|
||||||
format = 'html'
|
format = 'text'
|
||||||
ext = '.html'
|
ext = '.txt'
|
||||||
else:
|
else:
|
||||||
if len(format) != 2:
|
if len(format) != 2:
|
||||||
raise error.general('invalid report format option: %s' % ('='.join(format)))
|
raise error.general('invalid report format option: %s' % ('='.join(format)))
|
||||||
@ -110,6 +111,12 @@ class buildset:
|
|||||||
elif format[1] == 'html':
|
elif format[1] == 'html':
|
||||||
format = 'html'
|
format = 'html'
|
||||||
ext = '.html'
|
ext = '.html'
|
||||||
|
elif format[1] == 'xml':
|
||||||
|
format = 'xml'
|
||||||
|
ext = '.xml'
|
||||||
|
elif format[1] == 'ini':
|
||||||
|
format = 'ini'
|
||||||
|
ext = '.ini'
|
||||||
else:
|
else:
|
||||||
raise error.general('invalid report format: %s' % (format[1]))
|
raise error.general('invalid report format: %s' % (format[1]))
|
||||||
buildroot = _build.config.abspath('%{buildroot}')
|
buildroot = _build.config.abspath('%{buildroot}')
|
||||||
@ -117,22 +124,26 @@ class buildset:
|
|||||||
name = _build.main_package().name() + ext
|
name = _build.main_package().name() + ext
|
||||||
log.notice('reporting: %s -> %s' % (_config, name))
|
log.notice('reporting: %s -> %s' % (_config, name))
|
||||||
if not _build.opts.get_arg('--no-report'):
|
if not _build.opts.get_arg('--no-report'):
|
||||||
outpath = path.host(path.join(buildroot, prefix, 'share', 'rtems-source-builder'))
|
outpath = path.host(path.join(buildroot, prefix, 'share', 'rtems', 'rsb'))
|
||||||
|
if not _build.opts.dry_run():
|
||||||
outname = path.host(path.join(outpath, name))
|
outname = path.host(path.join(outpath, name))
|
||||||
r = reports.report(format, self.configs, _build.opts, _build.macros)
|
else:
|
||||||
r.setup()
|
outname = None
|
||||||
|
r = reports.report(format, self.configs,
|
||||||
|
copy.copy(opts), copy.copy(macros))
|
||||||
r.introduction(_build.config.file_name())
|
r.introduction(_build.config.file_name())
|
||||||
r.config(_build.config, _build.opts, _build.macros)
|
r.generate(_build.config.file_name())
|
||||||
|
r.epilogue(_build.config.file_name())
|
||||||
if not _build.opts.dry_run():
|
if not _build.opts.dry_run():
|
||||||
_build.mkdir(outpath)
|
_build.mkdir(outpath)
|
||||||
r.write(outname)
|
r.write(outname)
|
||||||
del r
|
del r
|
||||||
if not _build.macros.get('%{_disable_reporting}') \
|
if _build.opts.get_arg('--mail'):
|
||||||
and _build.opts.get_arg('--mail'):
|
r = reports.report('text', self.configs,
|
||||||
r = reports.report('text', self.configs, _build.opts, _build.macros)
|
copy.copy(opts), copy.copy(macros))
|
||||||
r.setup()
|
|
||||||
r.introduction(_build.config.file_name())
|
r.introduction(_build.config.file_name())
|
||||||
r.config(_build.config, _build.opts, _build.macros)
|
r.generate(_build.config.file_name())
|
||||||
|
r.epilogue(_build.config.file_name())
|
||||||
self.write_mail_report(r.out)
|
self.write_mail_report(r.out)
|
||||||
del r
|
del r
|
||||||
|
|
||||||
@ -176,7 +187,6 @@ class buildset:
|
|||||||
if _build.canadian_cross():
|
if _build.canadian_cross():
|
||||||
self.canadian_cross(_build)
|
self.canadian_cross(_build)
|
||||||
_build.make()
|
_build.make()
|
||||||
self.report(_config, _build)
|
|
||||||
if not _build.macros.get('%{_disable_collecting}'):
|
if not _build.macros.get('%{_disable_collecting}'):
|
||||||
self.root_copy(_build.config.expand('%{buildroot}'),
|
self.root_copy(_build.config.expand('%{buildroot}'),
|
||||||
_build.config.expand('%{_tmproot}'))
|
_build.config.expand('%{_tmproot}'))
|
||||||
@ -340,6 +350,9 @@ class buildset:
|
|||||||
mail_report = False
|
mail_report = False
|
||||||
if deps is None:
|
if deps is None:
|
||||||
self.build_package(configs[s], b)
|
self.build_package(configs[s], b)
|
||||||
|
self.report(configs[s], b,
|
||||||
|
copy.copy(self.opts),
|
||||||
|
copy.copy(self.macros))
|
||||||
if s == len(configs) - 1 and not have_errors:
|
if s == len(configs) - 1 and not have_errors:
|
||||||
self.bset_tar(b)
|
self.bset_tar(b)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user