diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2022-10-04 18:44:36 +0200 | 
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2022-10-26 17:12:34 +0100 | 
| commit | 89cb86aeb0262e17ee39c1d791effe9515bd0dc8 (patch) | |
| tree | a1643fa620a97ffdc2da9442abd7cff29d86e434 /python/xrelfo.py | |
| parent | 695f387ed872c1bc55ad4149ede95465b48697b9 (diff) | |
build, vtysh: extract vtysh commands from .xref
Rather than running selected source files through the preprocessor and a
bunch of perl regex'ing to get the list of all DEFUNs, use the data
collected in frr.xref.
This not only eliminates issues we've been having with preprocessor
failures due to nonexistent header files, but is also much faster.
Where extract.pl would take 5s, this now finishes in 0.2s.  And since
this is a non-parallelizable build step towards the end of the build
(dependent on a lot of other things being done already), the speedup is
actually noticeable.
Also files containing CLI no longer need to be listed in `vtysh_scan`
since the .xref data covers everything.  `#ifndef VTYSH_EXTRACT_PL`
checks are equally obsolete.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'python/xrelfo.py')
| -rw-r--r-- | python/xrelfo.py | 10 | 
1 files changed, 10 insertions, 0 deletions
diff --git a/python/xrelfo.py b/python/xrelfo.py index 09455ea9b4..739becd8ad 100644 --- a/python/xrelfo.py +++ b/python/xrelfo.py @@ -37,6 +37,7 @@ from clippy.uidhash import uidhash  from clippy.elf import *  from clippy import frr_top_src, CmdAttr  from tiabwarfo import FieldApplicator +from xref2vtysh import CommandEntry  try:      with open(os.path.join(frr_top_src, 'python', 'xrefstructs.json'), 'r') as fd: @@ -366,6 +367,7 @@ def main():      argp = argparse.ArgumentParser(description = 'FRR xref ELF extractor')      argp.add_argument('-o', dest='output', type=str, help='write JSON output')      argp.add_argument('--out-by-file',     type=str, help='write by-file JSON output') +    argp.add_argument('-c', dest='vtysh_cmds', type=str, help='write vtysh_cmd.c')      argp.add_argument('-Wlog-format',      action='store_const', const=True)      argp.add_argument('-Wlog-args',        action='store_const', const=True)      argp.add_argument('-Werror',           action='store_const', const=True) @@ -435,5 +437,13 @@ def _main(args):              json.dump(outbyfile, fd, indent=2, sort_keys=True, **json_dump_args)          os.rename(args.out_by_file + '.tmp', args.out_by_file) +    if args.vtysh_cmds: +        with open(args.vtysh_cmds + '.tmp', 'w') as fd: +            CommandEntry.run(out, fd) +        os.rename(args.vtysh_cmds + '.tmp', args.vtysh_cmds) +        if args.Werror and CommandEntry.warn_counter: +            sys.exit(1) + +  if __name__ == '__main__':      main()  | 
