mirror of
https://github.com/opnsense/src.git
synced 2026-07-15 12:11:48 -04:00
This version builds every module into the flua binary itself, since all of the bootstrap tools are built -DNO_SHARED. As a result, we also cannot dlsym(), so we can't really discover the names of our newly builtin modules. Instead, just build out a linker set with all of our luaopen_*() functions to register everything up-front. Building in all of the modules isn't strictly necessary, but it means that we have an example of how to add a bootstrap module everywhere you go and one doesn't need to consider whether bootstrap flua can use a module when writing scripts. On my build machine, the consequence on our binary size is an increase from around 1.6M -> 1.9M, which isn't really that bad. .lua modules can install into their usual path below $WORLDTMP/legacy and we'll pick them up automagically by way of the ctor that sets up LUA_PATH early on. This re-lands bootstrap module support with a more sensible subset, and after having verified that it cross-builds fine on macOS and Linux -- we cannot do libfreebsd on !FreeBSD because it's more system header dependant. We also need to bootstrap libmd to bring in libhash, and libucl + libyaml. Reviewed by: bapt, emaste (both previous version) (cherry picked from commit 1953a12ee2cde1afacb3e3f7612d89695c96e04f) (cherry picked from commit 80ada959004c4386880e47b11618f8abfc2d80e1) (cherry picked from commit 31320402472394af57eb3a36bee7f944117ca0ed) (cherry picked from commit 981cf36d64c48ebfa22d44ac83b6d448c2974f23) (cherry picked from commit d4c973fa148544a0b949ceb1efb6c68096f02baf) (cherry picked from commit bbef1c72b4873b657fdb0466b48b15d1d4f0a731) (cherry picked from commit 151bd3516b541823b16793460d73916e63d2b9c1) build: don't create duplicate bootstrap-tools targets The general problem is that we might have a somewhat complicated dependency tree depending on bootstrap version requirements. We could document when multiple bootstrap tools might have a shared dependency and be careful to add them only once to the list, but that is a little more fragile- particularly if we purge some bootstrap tools and need to re-work the logic a little bit. Just avoid redefining the build commands as we're iterating over the list so that we can keep the actual requirements intact. Reported by: dhw, others Reviewed by: imp (cherry picked from commit ab492c08fc3cbf4fb5d569663c0751bc2a41cb1f)
32 lines
845 B
C
32 lines
845 B
C
/*-
|
|
* Copyright (c) 2025 Kyle Evans <kevans@FreeBSD.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#ifndef FLUA_BOOTSTRAP_H
|
|
#define FLUA_BOOTSTRAP_H
|
|
|
|
#ifdef BOOTSTRAPPING
|
|
#include <sys/linker_set.h>
|
|
|
|
#include <lauxlib.h>
|
|
|
|
#define FLUA_MODULE_SETNAME flua_modules
|
|
|
|
SET_DECLARE(FLUA_MODULE_SETNAME, const luaL_Reg);
|
|
#define FLUA_MODULE_DEF(ident, modname, openfn) \
|
|
static const luaL_Reg ident = { modname, openfn }; \
|
|
DATA_SET(FLUA_MODULE_SETNAME, ident)
|
|
|
|
#define FLUA_MODULE_NAMED(mod, name) \
|
|
FLUA_MODULE_DEF(module_ ## mod, name, luaopen_ ## mod)
|
|
#define FLUA_MODULE(mod) \
|
|
FLUA_MODULE_DEF(module_ ## mod, #mod, luaopen_ ## mod)
|
|
#else /* !BOOTSTRAPPING */
|
|
#define FLUA_MODULE_DEF(ident, modname, openfn)
|
|
#define FLUA_MODULE_NAMED(mod, name)
|
|
#define FLUA_MODULE(modname)
|
|
#endif /* BOOTSTRAPPING */
|
|
|
|
#endif /* FLUA_BOOTSTRAP_H */
|