build: HAVE_LUA -> HAVE_SCRIPTING

And also guard all scripting-related stuff with HAVE_SCRIPTING.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
This commit is contained in:
Quentin Young 2020-11-30 17:01:03 -05:00
parent b4becb063f
commit fa22080d22
11 changed files with 58 additions and 27 deletions

View file

@ -507,7 +507,9 @@ int main(int argc, char **argv)
/* Initializations. */ /* Initializations. */
bgp_vrf_init(); bgp_vrf_init();
#ifdef HAVE_SCRIPTING
bgp_script_init(); bgp_script_init();
#endif
hook_register(routing_conf_event, hook_register(routing_conf_event,
routing_control_plane_protocols_name_validate); routing_control_plane_protocols_name_validate);

View file

@ -338,7 +338,7 @@ static const struct route_map_rule_cmd route_match_peer_cmd = {
route_match_peer_free route_match_peer_free
}; };
#if defined(HAVE_LUA) #ifdef HAVE_SCRIPTING
enum frrlua_rm_status { enum frrlua_rm_status {
/* /*
@ -468,7 +468,8 @@ static const struct route_map_rule_cmd route_match_script_cmd = {
route_match_script_compile, route_match_script_compile,
route_match_script_free route_match_script_free
}; };
#endif
#endif /* HAVE_SCRIPTING */
/* `match ip address IP_ACCESS_LIST' */ /* `match ip address IP_ACCESS_LIST' */
@ -4134,7 +4135,7 @@ DEFUN (no_match_peer,
RMAP_EVENT_MATCH_DELETED); RMAP_EVENT_MATCH_DELETED);
} }
#if defined(HAVE_LUA) #ifdef HAVE_SCRIPTING
DEFUN (match_script, DEFUN (match_script,
match_script_cmd, match_script_cmd,
"[no] match script WORD", "[no] match script WORD",
@ -4156,7 +4157,7 @@ DEFUN (match_script,
RMAP_EVENT_FILTER_ADDED); RMAP_EVENT_FILTER_ADDED);
} }
} }
#endif #endif /* HAVE_SCRIPTING */
/* match probability */ /* match probability */
DEFUN (match_probability, DEFUN (match_probability,
@ -5670,7 +5671,7 @@ void bgp_route_map_init(void)
route_map_install_match(&route_match_peer_cmd); route_map_install_match(&route_match_peer_cmd);
route_map_install_match(&route_match_local_pref_cmd); route_map_install_match(&route_match_local_pref_cmd);
#if defined(HAVE_LUA) #ifdef HAVE_SCRIPTING
route_map_install_match(&route_match_script_cmd); route_map_install_match(&route_match_script_cmd);
#endif #endif
route_map_install_match(&route_match_ip_address_cmd); route_map_install_match(&route_match_ip_address_cmd);
@ -5835,7 +5836,7 @@ void bgp_route_map_init(void)
install_element(RMAP_NODE, &no_set_ipv6_nexthop_prefer_global_cmd); install_element(RMAP_NODE, &no_set_ipv6_nexthop_prefer_global_cmd);
install_element(RMAP_NODE, &set_ipv6_nexthop_peer_cmd); install_element(RMAP_NODE, &set_ipv6_nexthop_peer_cmd);
install_element(RMAP_NODE, &no_set_ipv6_nexthop_peer_cmd); install_element(RMAP_NODE, &no_set_ipv6_nexthop_peer_cmd);
#if defined(HAVE_LUA) #ifdef HAVE_SCRIPTING
install_element(RMAP_NODE, &match_script_cmd); install_element(RMAP_NODE, &match_script_cmd);
#endif #endif
} }

View file

@ -19,7 +19,8 @@
*/ */
#include <zebra.h> #include <zebra.h>
#include <lua.h>
#ifdef HAVE_SCRIPTING
#include "bgpd.h" #include "bgpd.h"
#include "bgp_script.h" #include "bgp_script.h"
@ -27,6 +28,7 @@
#include "bgp_aspath.h" #include "bgp_aspath.h"
#include "frratomic.h" #include "frratomic.h"
#include "frrscript.h" #include "frrscript.h"
#include "frrlua.h"
static void lua_pushpeer(lua_State *L, const struct peer *peer) static void lua_pushpeer(lua_State *L, const struct peer *peer)
{ {
@ -186,3 +188,5 @@ void bgp_script_init(void)
{ {
frrscript_register_type_codecs(frrscript_codecs_bgpd); frrscript_register_type_codecs(frrscript_codecs_bgpd);
} }
#endif /* HAVE_SCRIPTING */

View file

@ -17,10 +17,18 @@
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301 USA * MA 02110-1301 USA
*/ */
#ifndef __BGP_SCRIPT__
#define __BGP_SCRIPT__
#include <zebra.h> #include <zebra.h>
#ifdef HAVE_SCRIPTING
/* /*
* Initialize scripting stuff. * Initialize scripting stuff.
*/ */
void bgp_script_init(void); void bgp_script_init(void);
#endif /* HAVE_SCRIPTING */
#endif /* __BGP_SCRIPT__ */

View file

@ -274,24 +274,22 @@ if test "$enable_clang_coverage" = "yes"; then
]) ])
fi fi
if test "$enable_scripting" = "yes"; then
AX_PROG_LUA([5.3])
AX_LUA_HEADERS
AX_LUA_LIBS([
AC_DEFINE([HAVE_SCRIPTING], [1], [Have support for scripting])
LIBS="$LIBS $LUA_LIB"
])
fi
if test "$enable_dev_build" = "yes"; then if test "$enable_dev_build" = "yes"; then
AC_DEFINE([DEV_BUILD], [1], [Build for development]) AC_DEFINE([DEV_BUILD], [1], [Build for development])
if test "$orig_cflags" = ""; then if test "$orig_cflags" = ""; then
AC_C_FLAG([-g3]) AC_C_FLAG([-g3])
AC_C_FLAG([-O0]) AC_C_FLAG([-O0])
fi fi
if test "$enable_lua" = "yes"; then
AX_PROG_LUA([5.3])
AX_LUA_HEADERS
AX_LUA_LIBS([
AC_DEFINE([HAVE_LUA], [1], [Have support for Lua interpreter])
LIBS="$LIBS $LUA_LIB"
])
fi
else else
if test "$enable_lua" = "yes"; then
AC_MSG_ERROR([Lua is not meant to be built/used outside of development at this time])
fi
if test "$orig_cflags" = ""; then if test "$orig_cflags" = ""; then
AC_C_FLAG([-g]) AC_C_FLAG([-g])
AC_C_FLAG([-O2]) AC_C_FLAG([-O2])
@ -693,8 +691,8 @@ fi
AC_ARG_ENABLE([dev_build], AC_ARG_ENABLE([dev_build],
AS_HELP_STRING([--enable-dev-build], [build for development])) AS_HELP_STRING([--enable-dev-build], [build for development]))
AC_ARG_ENABLE([lua], AC_ARG_ENABLE([scripting],
AS_HELP_STRING([--enable-lua], [Build Lua scripting])) AS_HELP_STRING([--enable-scripting], [Build with scripting support]))
if test "$enable_time_check" != "no" ; then if test "$enable_time_check" != "no" ; then
if test "$enable_time_check" = "yes" -o "$enable_time_check" = "" ; then if test "$enable_time_check" = "yes" -o "$enable_time_check" = "" ; then

View file

@ -2281,7 +2281,7 @@ done:
return CMD_SUCCESS; return CMD_SUCCESS;
} }
#ifdef DEV_BUILD #if defined(DEV_BUILD) && defined(HAVE_SCRIPTING)
DEFUN(script, DEFUN(script,
script_cmd, script_cmd,
"script SCRIPT", "script SCRIPT",
@ -2399,7 +2399,7 @@ void cmd_init(int terminal)
install_element(VIEW_NODE, &echo_cmd); install_element(VIEW_NODE, &echo_cmd);
install_element(VIEW_NODE, &autocomplete_cmd); install_element(VIEW_NODE, &autocomplete_cmd);
install_element(VIEW_NODE, &find_cmd); install_element(VIEW_NODE, &find_cmd);
#ifdef DEV_BUILD #if defined(DEV_BUILD) && defined(HAVE_SCRIPTING)
install_element(VIEW_NODE, &script_cmd); install_element(VIEW_NODE, &script_cmd);
#endif #endif

View file

@ -19,9 +19,11 @@
* with this program; see the file COPYING; if not, write to the Free Software * with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <zebra.h> #include <zebra.h>
#if defined(HAVE_LUA) #ifdef HAVE_SCRIPTING
#include "prefix.h" #include "prefix.h"
#include "frrlua.h" #include "frrlua.h"
#include "log.h" #include "log.h"
@ -371,4 +373,4 @@ char *frrlua_stackdump(lua_State *L)
return result; return result;
} }
#endif #endif /* HAVE_SCRIPTING */

View file

@ -19,7 +19,9 @@
#ifndef __FRRLUA_H__ #ifndef __FRRLUA_H__
#define __FRRLUA_H__ #define __FRRLUA_H__
#if defined(HAVE_LUA) #include <zebra.h>
#ifdef HAVE_SCRIPTING
#include <lua.h> #include <lua.h>
#include <lualib.h> #include <lualib.h>
@ -166,5 +168,6 @@ char *frrlua_stackdump(lua_State *L);
} }
#endif #endif
#endif /* HAVE_LUA */ #endif /* HAVE_SCRIPTING */
#endif /* __FRRLUA_H__ */ #endif /* __FRRLUA_H__ */

View file

@ -16,8 +16,10 @@
* with this program; see the file COPYING; if not, write to the Free Software * with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <zebra.h> #include <zebra.h>
#ifdef HAVE_SCRIPTING
#include <stdarg.h> #include <stdarg.h>
#include <lua.h> #include <lua.h>
@ -27,6 +29,7 @@
#include "hash.h" #include "hash.h"
#include "log.h" #include "log.h"
DEFINE_MTYPE_STATIC(LIB, SCRIPT, "Scripting"); DEFINE_MTYPE_STATIC(LIB, SCRIPT, "Scripting");
/* Codecs */ /* Codecs */
@ -267,3 +270,5 @@ void frrscript_init()
/* Register core library types */ /* Register core library types */
frrscript_register_type_codecs(frrscript_codecs_lib); frrscript_register_type_codecs(frrscript_codecs_lib);
} }
#endif /* HAVE_SCRIPTING */

View file

@ -19,6 +19,10 @@
#ifndef __FRRSCRIPT_H__ #ifndef __FRRSCRIPT_H__
#define __FRRSCRIPT_H__ #define __FRRSCRIPT_H__
#include <zebra.h>
#ifdef HAVE_SCRIPTING
#include <lua.h> #include <lua.h>
#include "frrlua.h" #include "frrlua.h"
@ -128,4 +132,6 @@ void *frrscript_get_result(struct frrscript *fs,
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* HAVE_SCRIPTING */
#endif /* __FRRSCRIPT_H__ */ #endif /* __FRRSCRIPT_H__ */

View file

@ -718,7 +718,9 @@ struct thread_master *frr_init(void)
lib_cmd_init(); lib_cmd_init();
frr_pthread_init(); frr_pthread_init();
#ifdef HAVE_SCRIPTING
frrscript_init(); frrscript_init();
#endif
log_ref_init(); log_ref_init();
log_ref_vty_init(); log_ref_vty_init();