summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2022-10-04 18:44:36 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2022-10-26 17:12:34 +0100
commit89cb86aeb0262e17ee39c1d791effe9515bd0dc8 (patch)
treea1643fa620a97ffdc2da9442abd7cff29d86e434 /lib
parent695f387ed872c1bc55ad4149ede95465b48697b9 (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 'lib')
-rw-r--r--lib/command.h7
-rw-r--r--lib/filter_cli.c2
-rw-r--r--lib/if.c2
-rw-r--r--lib/log_vty.c2
-rw-r--r--lib/nexthop_group.c2
-rw-r--r--lib/northbound_cli.c2
-rw-r--r--lib/plist.c2
-rw-r--r--lib/routemap_cli.c2
-rw-r--r--lib/subdir.am29
-rw-r--r--lib/thread.c2
-rw-r--r--lib/vty.c2
-rw-r--r--lib/zebra.h4
-rw-r--r--lib/zlog_5424_cli.c2
13 files changed, 8 insertions, 52 deletions
diff --git a/lib/command.h b/lib/command.h
index f4168dedd7..31e5cad23f 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -251,9 +251,6 @@ struct cmd_node {
/* Argc max counts. */
#define CMD_ARGC_MAX 256
-/* Turn off these macros when using cpp with extract.pl */
-#ifndef VTYSH_EXTRACT_PL
-
/* helper defines for end-user DEFUN* macros */
#define DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attrs, dnum) \
static const struct cmd_element cmdname = { \
@@ -370,8 +367,6 @@ struct cmd_node {
#define ALIAS_YANG(funcname, cmdname, cmdstr, helpstr) \
ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_YANG)
-#endif /* VTYSH_EXTRACT_PL */
-
/* Some macroes */
/*
@@ -511,7 +506,6 @@ struct xref_install_element {
enum node_type node_type;
};
-#ifndef VTYSH_EXTRACT_PL
#define install_element(node_type_, cmd_element_) do { \
static const struct xref_install_element _xref \
__attribute__((used)) = { \
@@ -523,7 +517,6 @@ struct xref_install_element {
XREF_LINK(_xref.xref); \
_install_element(node_type_, cmd_element_); \
} while (0)
-#endif
extern void _install_element(enum node_type, const struct cmd_element *);
diff --git a/lib/filter_cli.c b/lib/filter_cli.c
index 9a877a5704..e0f0f177e5 100644
--- a/lib/filter_cli.c
+++ b/lib/filter_cli.c
@@ -31,9 +31,7 @@
#include "lib/plist_int.h"
#include "lib/printfrr.h"
-#ifndef VTYSH_EXTRACT_PL
#include "lib/filter_cli_clippy.c"
-#endif /* VTYSH_EXTRACT_PL */
#define ACCESS_LIST_STR "Access list entry\n"
#define ACCESS_LIST_ZEBRA_STR "Access list name\n"
diff --git a/lib/if.c b/lib/if.c
index fa4fdb82d3..e7ff0c49b0 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -35,9 +35,7 @@
#include "buffer.h"
#include "log.h"
#include "northbound_cli.h"
-#ifndef VTYSH_EXTRACT_PL
#include "lib/if_clippy.c"
-#endif
DEFINE_MTYPE_STATIC(LIB, IF, "Interface");
DEFINE_MTYPE_STATIC(LIB, CONNECTED, "Connected");
diff --git a/lib/log_vty.c b/lib/log_vty.c
index c9268734c4..4091c92c73 100644
--- a/lib/log_vty.c
+++ b/lib/log_vty.c
@@ -29,9 +29,7 @@
#include "lib/printfrr.h"
#include "lib/systemd.h"
-#ifndef VTYSH_EXTRACT_PL
#include "lib/log_vty_clippy.c"
-#endif
#define ZLOG_MAXLVL(a, b) MAX(a, b)
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
index 7284d6cea6..f342f50e8f 100644
--- a/lib/nexthop_group.c
+++ b/lib/nexthop_group.c
@@ -28,9 +28,7 @@
#include <command.h>
#include <jhash.h>
-#ifndef VTYSH_EXTRACT_PL
#include "lib/nexthop_group_clippy.c"
-#endif
DEFINE_MTYPE_STATIC(LIB, NEXTHOP_GROUP, "Nexthop Group");
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c
index 56eac9dc32..e0dcdb490f 100644
--- a/lib/northbound_cli.c
+++ b/lib/northbound_cli.c
@@ -32,9 +32,7 @@
#include "northbound.h"
#include "northbound_cli.h"
#include "northbound_db.h"
-#ifndef VTYSH_EXTRACT_PL
#include "lib/northbound_cli_clippy.c"
-#endif
struct debug nb_dbg_cbs_config = {0, "Northbound callbacks: configuration"};
struct debug nb_dbg_cbs_state = {0, "Northbound callbacks: state"};
diff --git a/lib/plist.c b/lib/plist.c
index ff2a59ba2d..17e692d139 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -1193,9 +1193,7 @@ static int vty_clear_prefix_list(struct vty *vty, afi_t afi, const char *name,
return CMD_SUCCESS;
}
-#ifndef VTYSH_EXTRACT_PL
#include "lib/plist_clippy.c"
-#endif
DEFPY (show_ip_prefix_list,
show_ip_prefix_list_cmd,
diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c
index 6be5d15ec4..9adaed91ed 100644
--- a/lib/routemap_cli.c
+++ b/lib/routemap_cli.c
@@ -26,9 +26,7 @@
#include "lib/northbound_cli.h"
#include "lib/routemap.h"
-#ifndef VTYSH_EXTRACT_PL
#include "lib/routemap_cli_clippy.c"
-#endif /* VTYSH_EXTRACT_PL */
#define ROUTE_MAP_CMD_STR \
"Create route-map or enter route-map command mode\n" \
diff --git a/lib/subdir.am b/lib/subdir.am
index e04e700eb6..ea6cb9339a 100644
--- a/lib/subdir.am
+++ b/lib/subdir.am
@@ -139,27 +139,6 @@ nodist_lib_libfrr_la_SOURCES = \
yang/frr-module-translator.yang.c \
# end
-vtysh_scan += \
- lib/distribute.c \
- lib/filter.c \
- lib/filter_cli.c \
- lib/if.c \
- lib/if_rmap.c \
- lib/keychain.c \
- lib/lib_vty.c \
- lib/log_vty.c \
- lib/nexthop_group.c \
- lib/plist.c \
- lib/routemap.c \
- lib/routemap_cli.c \
- lib/spf_backoff.c \
- lib/thread.c \
- lib/vrf.c \
- lib/vty.c \
- # end
-# can be loaded as DSO - always include for vtysh
-vtysh_scan += lib/agentx.c
-
if SQLITE3
lib_libfrr_la_LIBADD += $(SQLITE3_LIBS)
lib_libfrr_la_SOURCES += lib/db.c
@@ -347,7 +326,6 @@ lib_libfrrsnmp_la_SOURCES = \
if CARES
lib_LTLIBRARIES += lib/libfrrcares.la
pkginclude_HEADERS += lib/resolver.h
-vtysh_scan += lib/resolver.c
endif
lib_libfrrcares_la_CFLAGS = $(AM_CFLAGS) $(CARES_CFLAGS)
@@ -478,13 +456,18 @@ SUFFIXES += .xref
# dependencies added in python/makefile.py
frr.xref:
- $(AM_V_XRELFO) $(CLIPPY) $(top_srcdir)/python/xrelfo.py -o $@ $^
+ $(AM_V_XRELFO) $(CLIPPY) $(top_srcdir)/python/xrelfo.py -o $@ -c vtysh/vtysh_cmd.c $^
all-am: frr.xref
clean-xref:
-rm -rf $(xrefs) frr.xref
clean-local: clean-xref
+CLEANFILES += vtysh/vtysh_cmd.c
+vtysh/vtysh_cmd.c: frr.xref
+ @test -f $@ || rm -f frr.xref || true
+ @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) frr.xref
+
## automake's "ylwrap" is a great piece of GNU software... not.
.l.c:
$(AM_V_LEX)$(am__skiplex) $(LEXCOMPILE) $<
diff --git a/lib/thread.c b/lib/thread.c
index 9eac9b410a..4078634f75 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -102,9 +102,7 @@ unsigned long cputime_threshold = CONSUMED_TIME_CHECK;
unsigned long walltime_threshold = CONSUMED_TIME_CHECK;
/* CLI start ---------------------------------------------------------------- */
-#ifndef VTYSH_EXTRACT_PL
#include "lib/thread_clippy.c"
-#endif
static unsigned int cpu_record_hash_key(const struct cpu_thread_history *a)
{
diff --git a/lib/vty.c b/lib/vty.c
index 92db07677a..d524ae53cb 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -53,9 +53,7 @@
#include <arpa/telnet.h>
#include <termios.h>
-#ifndef VTYSH_EXTRACT_PL
#include "lib/vty_clippy.c"
-#endif
DEFINE_MTYPE_STATIC(LIB, VTY, "VTY");
DEFINE_MTYPE_STATIC(LIB, VTY_SERV, "VTY server");
diff --git a/lib/zebra.h b/lib/zebra.h
index 53ae5b4e9e..b2f5e5a848 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -202,9 +202,9 @@
#endif /* HAVE_GLIBC_BACKTRACE */
/* Local includes: */
-#if !(defined(__GNUC__) || defined(VTYSH_EXTRACT_PL))
+#if !defined(__GNUC__)
#define __attribute__(x)
-#endif /* !__GNUC__ || VTYSH_EXTRACT_PL */
+#endif /* !__GNUC__ */
#include <assert.h>
diff --git a/lib/zlog_5424_cli.c b/lib/zlog_5424_cli.c
index dd8dbfaffd..5eebda9deb 100644
--- a/lib/zlog_5424_cli.c
+++ b/lib/zlog_5424_cli.c
@@ -158,9 +158,7 @@ static int reconf_clear_dst(struct zlog_cfg_5424_user *cfg, struct vty *vty)
return reconf_dst(cfg, vty);
}
-#ifndef VTYSH_EXTRACT_PL
#include "lib/zlog_5424_cli_clippy.c"
-#endif
DEFPY_NOSH(log_5424_target,
log_5424_target_cmd,