From: Philippe Proulx Date: Thu, 7 Apr 2016 01:37:10 +0000 (-0400) Subject: Make config option "gen-default-stream-def" a boolean X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=b4700284c75350ab58a8b8c041f594192bd18f0c;p=deliverable%2Fbarectf.git Make config option "gen-default-stream-def" a boolean Now that there's a way to specify a default stream, we only need to know if we want or not to generate this definition. Signed-off-by: Philippe Proulx --- diff --git a/barectf/config.py b/barectf/config.py index c4b5069..07f501a 100644 --- a/barectf/config.py +++ b/barectf/config.py @@ -115,11 +115,6 @@ class Config: @options.setter def options(self, options): - if options.gen_default_stream_def: - if options.gen_default_stream_def not in self._metadata.streams.keys(): - fmt = 'invalid configuration option "gen-default-stream-def": stream "{}" does not exist' - raise ConfigError(fmt.format(options.gen_default_stream_def)) - self._options = options @@ -2484,8 +2479,8 @@ class _YamlConfigParser: if 'gen-default-stream-def' in options_node and options_node['gen-default-stream-def'] is not None: gen_default_stream_def_node = options_node['gen-default-stream-def'] - if not _is_str_prop(gen_default_stream_def_node): - raise ConfigError('invalid configuration option "gen-default-stream-def": expecting a string') + if not _is_bool_prop(gen_default_stream_def_node): + raise ConfigError('invalid configuration option "gen-default-stream-def": expecting a boolean') cfg_options.gen_default_stream_def = gen_default_stream_def_node diff --git a/barectf/gen.py b/barectf/gen.py index 4b9bb9d..a4d87ec 100644 --- a/barectf/gen.py +++ b/barectf/gen.py @@ -349,9 +349,8 @@ class CCodeGenerator: if self._cfg.options.gen_prefix_def: prefix_def = '#define _BARECTF_PREFIX {}'.format(self._cfg.prefix) - if self._cfg.options.gen_default_stream_def: - s_name = self._cfg.options.gen_default_stream_def - default_stream_def = '#define _BARECTF_DEFAULT_STREAM {}'.format(s_name) + if self._cfg.options.gen_default_stream_def and self._cfg.metadata.default_stream_name is not None: + default_stream_def = '#define _BARECTF_DEFAULT_STREAM {}'.format(self._cfg.metadata.default_stream_name) default_stream_trace_defs = '' default_stream_name = self._cfg.metadata.default_stream_name diff --git a/barectf/templates.py b/barectf/templates.py index 5229668..cd7899e 100644 --- a/barectf/templates.py +++ b/barectf/templates.py @@ -241,6 +241,7 @@ _HEADER_BEGIN = '''#ifndef _{ucprefix}H {prefix_def} {default_stream_def} + {default_stream_trace_defs} struct {prefix}ctx;