[PATCH] Spec hierarchy dumping for a config
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed May 3 09:12:53 UTC 2023
Hello Philip,
On 28.04.23 11:27, Philip Kirkpatrick wrote:
> I don't know if anyone else will find this useful or if it already
> exists and I duplicated some effort, but I find it difficult to just
> read the files in the spec folder and understand how they are connected
> and what files are used in BSPs I'm interested in. I looked through the
> wscript and didn't see an existing way to dump the item tree for a given
> configuration, so I added it. The patch is as follows:
this looks like a useful addition. I would make it a new command, for
example "./waf viewspec".
>
> ---
> diff --git a/wscript b/wscript
> index 567f42db2f..4e59188188 100755
> --- a/wscript
> +++ b/wscript
> @@ -151,6 +151,61 @@ def _is_enabled(enabled, enabled_by):
> return _IS_ENABLED_OP[key](enabled, value)
> return enabled_by in enabled
>
> +color_true = '\x1b[32m'
> +color_false = '\x1b[31m'
> +color_clear = '\x1b[0m'
> +
> +def _get_enabler_op_and(enabled, enabled_by):
> + and_str = "{ "
> + first = True
> + for next_enabled_by in enabled_by:
> + if first:
> + first = False
> + else:
> + and_str = and_str + " and "
> + and_str = and_str + _get_enabler(enabled, next_enabled_by)
> + return and_str + " }"
Can this be simplified to
" and ".join(_get_enabler(enabled, next_enabled_by) for next_enabled_by
in enabled_by)
?
> +
> +
> +def _get_enabler_op_not(enabled, enabled_by):
> + return "{ " + color_true + "not " + color_false +
> _get_enabler(enabled, enabled_by) + color_clear + " }"
> +
> +
> +def _get_enabler_op_or(enabled, enabled_by):
> + or_str = "{ "
> + first = True
> + for next_enabled_by in enabled_by:
> + if first:
> + first = False
> + else:
> + or_str = or_str + " or "
> + if _is_enabled(enabled, next_enabled_by):
> + color_start = color_true
> + color_end = color_clear
> + else:
> + color_start = color_false
> + color_end = color_clear
> + or_str = or_str + color_start + _get_enabler(enabled,
> next_enabled_by) + color_end
> + return or_str + " }"
> +
> +
> +_GET_ENABLER_OP = {
> + "and": _get_enabler_op_and,
> + "not": _get_enabler_op_not,
> + "or": _get_enabler_op_or,
> +}
> +
> +
> +def _get_enabler(enabled, enabled_by):
> + if isinstance(enabled_by, bool):
> + return color_true + str(enabled_by) + color_clear
> + if isinstance(enabled_by, list):
> + return _get_enabler_op_or(enabled, enabled_by)
> + if isinstance(enabled_by, dict):
> + key, value = next(iter(enabled_by.items()))
> + return _GET_ENABLER_OP[key](enabled, value)
> + return enabled_by
> +
>
> def _asm_explicit_target(self, node):
> task = self.create_task("asm", node,
> @@ -233,6 +288,14 @@ class Item(object):
> "Build error related to item spec:{}: {}".format(
> self.uid, str(e)))
>
> +
> + def dump_spec(self, bld, bic, depth):
> + if _is_enabled(bld.env.ENABLE, self.get_enabled_by()):
> + enabler = _get_enabler(bld.env.ENABLE, self.get_enabled_by())
> + print("│ " * depth + "├──" + self.uid + " # enabled-by: "
> + enabler)
> + for p in self.links():
> + p.dump_spec(bld, bic, depth + 1)
> +
> def do_defaults(self, enabled):
> return
>
> @@ -1320,6 +1383,14 @@ def options(ctx):
> help=
> "sets the option identified by KEY to the VALUE in the build
> specification; it is intended for RTEMS maintainers and may be used in
> the bspdefaults and configure commands",
> )
> + rg.add_option(
> + "--rtems-dumpspec",
> + action="store_true",
> + dest="rtems_dump_spec",
> + default=False,
> + help=
> + "dumps the currently enable spec yaml files and the links tree;
> it is intended for RTEMS maintainers and may be used in the build commands",
> + )
>
>
> def check_environment(conf):
> @@ -1587,8 +1658,14 @@ def build(bld):
> long_command_line_workaround(bld)
> bic = BuildItemContext(bld.env.ARCH_INCLUDES.split(), [], [], [],
> [], [],
> [])
> - bsps[bld.env.ARCH][bld.env.BSP_BASE].build(bld, bic)
> - items[bld.env.TOPGROUP].build(bld, bic)
> + if(bld.options.rtems_dump_spec):
> + print("BSPS:")
> + bsps[bld.env.ARCH][bld.env.BSP_BASE].dump_spec(bld, bic, 0)
> + print("items:")
> + items[bld.env.TOPGROUP].dump_spec(bld, bic, 0)
> + else:
> + bsps[bld.env.ARCH][bld.env.BSP_BASE].build(bld, bic)
> + items[bld.env.TOPGROUP].build(bld, bic)
>
>
> def add_log_filter(name):
> ---
>
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber at embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
More information about the devel
mailing list