mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
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.
This commit is contained in:
@@ -154,7 +154,7 @@ class report:
|
|||||||
self.output("'''")
|
self.output("'''")
|
||||||
self.output('')
|
self.output('')
|
||||||
|
|
||||||
def introduction(self, name, intro_text):
|
def introduction(self, name, intro_text = None):
|
||||||
if self.is_asciidoc():
|
if self.is_asciidoc():
|
||||||
h = 'RTEMS Source Builder Report'
|
h = 'RTEMS Source Builder Report'
|
||||||
self.output(h)
|
self.output(h)
|
||||||
@@ -245,21 +245,20 @@ class report:
|
|||||||
if self.is_asciidoc():
|
if self.is_asciidoc():
|
||||||
self.output('--------------------------------------------')
|
self.output('--------------------------------------------')
|
||||||
|
|
||||||
def config(self, configname, opts, macros):
|
def config(self, _config, opts, macros):
|
||||||
|
|
||||||
_config = config.file(configname, opts, macros)
|
|
||||||
packages = _config.packages()
|
packages = _config.packages()
|
||||||
package = packages['main']
|
package = packages['main']
|
||||||
name = package.name()
|
name = package.name()
|
||||||
self.config_start(name)
|
self.config_start(name)
|
||||||
if self.is_asciidoc():
|
if self.is_asciidoc():
|
||||||
self.output('*Package*: _%s_ +' % (name))
|
self.output('*Package*: _%s_ +' % (name))
|
||||||
self.output('*Config*: %s' % (configname))
|
self.output('*Config*: %s' % (_config.file_name()))
|
||||||
self.output('')
|
self.output('')
|
||||||
else:
|
else:
|
||||||
self.output('-' * self.line_len)
|
self.output('-' * self.line_len)
|
||||||
self.output('Package: %s' % (name))
|
self.output('Package: %s' % (name))
|
||||||
self.output(' Config: %s' % (configname))
|
self.output(' Config: %s' % (_config.file_name()))
|
||||||
self.output_info('Summary', package.get_info('summary'), True)
|
self.output_info('Summary', package.get_info('summary'), True)
|
||||||
self.output_info('URL', package.get_info('url'))
|
self.output_info('URL', package.get_info('url'))
|
||||||
self.output_info('Version', package.get_info('version'))
|
self.output_info('Version', package.get_info('version'))
|
||||||
@@ -302,25 +301,7 @@ class report:
|
|||||||
self.output_directive('Clean', package.clean())
|
self.output_directive('Clean', package.clean())
|
||||||
self.config_end(name)
|
self.config_end(name)
|
||||||
|
|
||||||
def buildset(self, name, opts = None, macros = None):
|
def write(self, name):
|
||||||
self.bset_nesting += 1
|
|
||||||
self.buildset_start(name)
|
|
||||||
if opts is None:
|
|
||||||
opts = self.opts
|
|
||||||
if macros is None:
|
|
||||||
macros = self.macros
|
|
||||||
bset = setbuilder.buildset(name, self.configs, opts, macros)
|
|
||||||
for c in bset.load():
|
|
||||||
if c.endswith('.bset'):
|
|
||||||
self.buildset(c, bset.opts, bset.macros)
|
|
||||||
elif c.endswith('.cfg'):
|
|
||||||
self.config(c, bset.opts, bset.macros)
|
|
||||||
else:
|
|
||||||
raise error.general('invalid config type: %s' % (c))
|
|
||||||
self.buildset_end(name)
|
|
||||||
self.bset_nesting -= 1
|
|
||||||
|
|
||||||
def generate(self, name):
|
|
||||||
if self.format == 'html':
|
if self.format == 'html':
|
||||||
if self.asciidoc is None:
|
if self.asciidoc is None:
|
||||||
raise error.general('asciidoc not initialised')
|
raise error.general('asciidoc not initialised')
|
||||||
@@ -340,19 +321,30 @@ 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 make(self, inname, outname = None, intro_text = None):
|
def generate(self, name, opts = None, macros = None):
|
||||||
|
self.bset_nesting += 1
|
||||||
|
self.buildset_start(name)
|
||||||
|
if opts is None:
|
||||||
|
opts = self.opts
|
||||||
|
if macros is None:
|
||||||
|
macros = self.macros
|
||||||
|
bset = setbuilder.buildset(name, self.configs, opts, macros)
|
||||||
|
for c in bset.load():
|
||||||
|
if c.endswith('.bset'):
|
||||||
|
self.buildset(c, bset.opts, bset.macros)
|
||||||
|
elif c.endswith('.cfg'):
|
||||||
|
self.config(config.file(c, bset.opts, bset.macros),
|
||||||
|
bset.opts, bset.macros)
|
||||||
|
else:
|
||||||
|
raise error.general('invalid config type: %s' % (c))
|
||||||
|
self.buildset_end(name)
|
||||||
|
self.bset_nesting -= 1
|
||||||
|
|
||||||
|
def create(self, inname, outname = None, intro_text = None):
|
||||||
self.setup()
|
self.setup()
|
||||||
self.introduction(inname, intro_text)
|
self.introduction(inname, intro_text)
|
||||||
config = build.find_config(inname, self.configs)
|
self.generate(inname)
|
||||||
if config is None:
|
self.write(outname)
|
||||||
raise error.general('config file not found: %s' % (inname))
|
|
||||||
if config.endswith('.bset'):
|
|
||||||
self.buildset(config)
|
|
||||||
elif config.endswith('.cfg'):
|
|
||||||
self.config(config, self.opts, self.macros)
|
|
||||||
else:
|
|
||||||
raise error.general('invalid config type: %s' % (config))
|
|
||||||
self.generate(outname)
|
|
||||||
|
|
||||||
def run(args):
|
def run(args):
|
||||||
try:
|
try:
|
||||||
@@ -394,8 +386,13 @@ def run(args):
|
|||||||
outname = outname.replace('/', '-')
|
outname = outname.replace('/', '-')
|
||||||
else:
|
else:
|
||||||
outname = output
|
outname = output
|
||||||
r.make(_config, outname)
|
config = build.find_config(_config, configs)
|
||||||
|
if config is None:
|
||||||
|
raise error.general('config file not found: %s' % (inname))
|
||||||
|
r.create(config, outname)
|
||||||
del r
|
del r
|
||||||
|
else:
|
||||||
|
raise error.general('invalid config type: %s' % (config))
|
||||||
except error.general, gerr:
|
except error.general, gerr:
|
||||||
print gerr
|
print gerr
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@@ -59,6 +59,15 @@ class buildset:
|
|||||||
self.macros = copy.copy(macros)
|
self.macros = copy.copy(macros)
|
||||||
self.bset = bset
|
self.bset = bset
|
||||||
self.bset_pkg = '%s-%s-set' % (self.macros.expand('%{_target}'), self.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):
|
def copy(self, src, dst):
|
||||||
if not os.path.isdir(path.host(src)):
|
if not os.path.isdir(path.host(src)):
|
||||||
@@ -75,7 +84,7 @@ class buildset:
|
|||||||
raise error.general('copying tree: %s' % (str(err)))
|
raise error.general('copying tree: %s' % (str(err)))
|
||||||
|
|
||||||
def report(self, _config, _build):
|
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')
|
format = _build.opts.get_arg('--report-format')
|
||||||
if format is None:
|
if format is None:
|
||||||
format = 'html'
|
format = 'html'
|
||||||
@@ -97,13 +106,24 @@ class buildset:
|
|||||||
buildroot = _build.config.abspath('%{buildroot}')
|
buildroot = _build.config.abspath('%{buildroot}')
|
||||||
prefix = _build.macros.expand('%{_prefix}')
|
prefix = _build.macros.expand('%{_prefix}')
|
||||||
name = _build.main_package().name() + ext
|
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))
|
log.notice('reporting: %s -> %s' % (_config, name))
|
||||||
if not _build.opts.dry_run():
|
if not _build.opts.get_arg('--no-report'):
|
||||||
_build.mkdir(outpath)
|
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 = 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
|
del r
|
||||||
|
|
||||||
def root_copy(self, src, dst):
|
def root_copy(self, src, dst):
|
||||||
@@ -233,24 +253,32 @@ class buildset:
|
|||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
|
|
||||||
exbset = self.macros.expand(self.bset)
|
#
|
||||||
|
# If the build set file ends with .cfg the user has passed to the
|
||||||
self.macros['_bset'] = exbset
|
# buildset builder a configuration so we just return it.
|
||||||
|
#
|
||||||
root, ext = path.splitext(exbset)
|
if self.bset.endswith('.cfg'):
|
||||||
|
configs = [self.bset]
|
||||||
if exbset.endswith('.bset'):
|
|
||||||
bset = exbset
|
|
||||||
else:
|
else:
|
||||||
bset = '%s.bset' % (exbset)
|
exbset = self.macros.expand(self.bset)
|
||||||
|
self.macros['_bset'] = exbset
|
||||||
return self.parse(bset)
|
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):
|
def build(self, deps = None):
|
||||||
|
|
||||||
log.trace('_bset: %s: make' % (self.bset))
|
log.trace('_bset: %s: make' % (self.bset))
|
||||||
log.notice('Build Set: %s' % (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()
|
configs = self.load()
|
||||||
|
|
||||||
log.trace('_bset: %s: configs: %s' % (self.bset, ','.join(configs)))
|
log.trace('_bset: %s: configs: %s' % (self.bset, ','.join(configs)))
|
||||||
@@ -271,10 +299,12 @@ class buildset:
|
|||||||
opts = copy.copy(self.opts)
|
opts = copy.copy(self.opts)
|
||||||
macros = copy.copy(self.macros)
|
macros = copy.copy(self.macros)
|
||||||
if configs[s].endswith('.bset'):
|
if configs[s].endswith('.bset'):
|
||||||
|
log.trace('_bset: %s' % ('=' * 80))
|
||||||
bs = buildset(configs[s], self.configs, opts, macros)
|
bs = buildset(configs[s], self.configs, opts, macros)
|
||||||
bs.build(deps)
|
bs.build(deps)
|
||||||
del bs
|
del bs
|
||||||
elif configs[s].endswith('.cfg'):
|
elif configs[s].endswith('.cfg'):
|
||||||
|
log.trace('_bset: %s' % ('-' * 80))
|
||||||
b = build.build(configs[s], self.opts.get_arg('--pkg-tar-files'),
|
b = build.build(configs[s], self.opts.get_arg('--pkg-tar-files'),
|
||||||
opts, macros)
|
opts, macros)
|
||||||
if deps is None:
|
if deps is None:
|
||||||
@@ -287,6 +317,7 @@ class buildset:
|
|||||||
else:
|
else:
|
||||||
raise error.general('invalid config type: %s' % (configs[s]))
|
raise error.general('invalid config type: %s' % (configs[s]))
|
||||||
except error.general, gerr:
|
except error.general, gerr:
|
||||||
|
self.write_email_report(str(gerr))
|
||||||
if self.opts.keep_going():
|
if self.opts.keep_going():
|
||||||
print gerr
|
print gerr
|
||||||
if self.opts.always_clean():
|
if self.opts.always_clean():
|
||||||
@@ -315,6 +346,11 @@ class buildset:
|
|||||||
|
|
||||||
log.notice('Build Set: Time %s' % (str(end - start)))
|
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):
|
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') or opts.get_arg('--list-bsets'):
|
||||||
if opts.get_arg('--list-configs'):
|
if opts.get_arg('--list-configs'):
|
||||||
@@ -335,10 +371,14 @@ def run():
|
|||||||
optargs = { '--list-configs': 'List available configurations',
|
optargs = { '--list-configs': 'List available configurations',
|
||||||
'--list-bsets': 'List available build sets',
|
'--list-bsets': 'List available build sets',
|
||||||
'--list-deps': 'List the dependent files.',
|
'--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.',
|
'--no-report': 'Do not create a package report.',
|
||||||
'--report-format': 'The report format (text, html, asciidoc).',
|
'--report-format': 'The report format (text, html, asciidoc).',
|
||||||
'--bset-tar-file': 'Create a build set tar file',
|
'--no-email': 'Do not send an email report.',
|
||||||
'--pkg-tar-files': 'Create package tar files' }
|
'--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)
|
opts = options.load(sys.argv, optargs)
|
||||||
log.notice('RTEMS Source Builder - Set Builder, v%s' % (version.str()))
|
log.notice('RTEMS Source Builder - Set Builder, v%s' % (version.str()))
|
||||||
if not check.host_setup(opts):
|
if not check.host_setup(opts):
|
||||||
|
Reference in New Issue
Block a user