]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: lua: Add HLUA_PREPEND_C?PATH build option
authorTim Duesterhus <tim@bastelstu.be>
Sun, 12 Jan 2020 12:55:41 +0000 (13:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 24 Jan 2020 08:22:03 +0000 (09:22 +0100)
This complements the lua-prepend-path configuration option to allow
distro maintainers to add a default path for HAProxy specific Lua
libraries.

Makefile
src/hlua.c

index 8399f6ca3585029520b06761a4e742057b3e9444..bb494fac3011831b90c991ef2b7488be1aec96da 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -88,6 +88,8 @@
 #           installation only.
 #   DOCDIR  is set to "$(PREFIX)/doc/haproxy" by default and is used for
 #           installation only.
+#   HLUA_PREPEND_PATH may be used to prepend a folder to Lua's default package.path.
+#   HLUA_PREPEND_CPATH may be used to prepend a folder to Lua's default package.cpath.
 #
 # Other variables :
 #   PCRE_CONFIG    : force the binary path to get pcre config (by default
@@ -546,6 +548,14 @@ LUA_INC := $(firstword $(foreach lib,lua5.3 lua53 lua,$(call check_lua_inc,$(lib
 ifneq ($(LUA_INC),)
 OPTIONS_CFLAGS  += -I$(LUA_INC)
 endif
+ifneq ($(HLUA_PREPEND_PATH),)
+OPTIONS_CFLAGS  += -DHLUA_PREPEND_PATH=$(HLUA_PREPEND_PATH)
+BUILD_OPTIONS += HLUA_PREPEND_PATH=$(HLUA_PREPEND_PATH)
+endif
+ifneq ($(HLUA_PREPEND_CPATH),)
+OPTIONS_CFLAGS  += -DHLUA_PREPEND_CPATH=$(HLUA_PREPEND_CPATH)
+BUILD_OPTIONS += HLUA_PREPEND_CPATH=$(HLUA_PREPEND_CPATH)
+endif
 endif
 
 OPTIONS_LDFLAGS += $(LUA_LD_FLAGS) -l$(LUA_LIB_NAME) -lm
index bcc1d2ff8c7e8b5702328b7aeda32d347a311749..f1a234ad5c23f3a91d96749fe311ff2cfa0f21fe 100644 (file)
@@ -7651,6 +7651,16 @@ void hlua_init(void)
 
        /* Initialise lua. */
        luaL_openlibs(gL.T);
+#define HLUA_PREPEND_PATH_TOSTRING1(x) #x
+#define HLUA_PREPEND_PATH_TOSTRING(x) HLUA_PREPEND_PATH_TOSTRING1(x)
+#ifdef HLUA_PREPEND_PATH
+       hlua_prepend_path(gL, "path", HLUA_PREPEND_PATH_TOSTRING(HLUA_PREPEND_PATH));
+#endif
+#ifdef HLUA_PREPEND_CPATH
+       hlua_prepend_path(gL, "cpath", HLUA_PREPEND_PATH_TOSTRING(HLUA_PREPEND_CPATH));
+#endif
+#undef HLUA_PREPEND_PATH_TOSTRING
+#undef HLUA_PREPEND_PATH_TOSTRING1
 
        /* Set safe environment for the initialisation. */
        if (!SET_SAFE_LJMP(gL.T)) {