From e93f0722344a89e6fc09de681afa055a3925fdb3 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 4 Nov 2024 15:17:35 +0300 Subject: [PATCH] feat(build): Add --with-vendored-luarocks=dir for use in distros with pseudo-system path handling --- configure.ac | 22 +++++++++++++++++----- core/pathsetup.lua.in | 4 ++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 34aac5680..85eb203bc 100644 --- a/configure.ac +++ b/configure.ac @@ -79,6 +79,14 @@ AC_ARG_WITH([system-luarocks], AM_CONDITIONAL([SYSTEM_LUAROCKS], [test "x$with_system_luarocks" = "xyes"]) AC_SUBST([SYSTEM_LUAROCKS]) +AC_ARG_WITH([vendored-luarocks-dir], + AS_HELP_STRING([--with-vendored-luarocks-dir=PATH], + [Specify a custom vendored location from which to load ‘system’ luarocks]), + [], + [with_vendored_luarocks_dir=no]) +AM_CONDITIONAL([VENDORED_LUAROCKS], [test "x$with_vendored_luarocks_dir" != "xno"]) +AC_SUBST([VENDORED_LUAROCKS]) + AC_ARG_WITH([system-lua-sources], AS_HELP_STRING([--with-system-lua-sources], [Don’t compile against vendored Lua sources, use system headers])) @@ -266,16 +274,20 @@ AM_COND_IF([DEVELOPER_MODE], [ AC_DEFINE_UNQUOTED([SILE_PATH], ["${SILE_PATH}"], [Path for SILE packages and classes]) AC_SUBST([SILE_PATH]) -# In order for our Rust CLI binary to use the same default package.path as the system Lua, -# we test the system Lua (required only at build not run time) for its current package.path. +# In order for our Rust CLI binary to use the same default package.(c)path as the system Lua, +# we test the system Lua (required only at build not run time) for its current package.(c)path. adl_RECURSIVE_EVAL(["$(${LUA} -e 'print(package.path)')"], [SYSTEM_LUA_PATH]) -AC_DEFINE_UNQUOTED([SYSTEM_LUA_PATH], ["${SYSTEM_LUA_PATH}"],[System Lua package path]) -AC_SUBST([SYSTEM_LUA_PATH]) - adl_RECURSIVE_EVAL(["$(${LUA} -e 'print(package.cpath)')"], [SYSTEM_LUA_CPATH]) +AC_DEFINE_UNQUOTED([SYSTEM_LUA_PATH], ["${SYSTEM_LUA_PATH}"],[System Lua package path]) AC_DEFINE_UNQUOTED([SYSTEM_LUA_CPATH], ["${SYSTEM_LUA_CPATH}"], [System Lua package cpath]) +AC_SUBST([SYSTEM_LUA_PATH]) AC_SUBST([SYSTEM_LUA_CPATH]) +# Accommodate Homebrew and/or other distros that pretend a vendored location is the system. +AM_COND_IF([VENDORED_LUAROCKS], + [VENDORED_LUAROCKS_DIR="$with_vendored_luarocks_dir"]) +AC_SUBST([VENDORED_LUAROCKS_DIR]) + adl_RECURSIVE_EVAL(["${libdir}/${TRANSFORMED_PACKAGE_NAME}"], [SILE_LIB_PATH]) AC_DEFINE_UNQUOTED([SILE_LIB_PATH],["${SILE_LIB_PATH}"], [Path for SILE libraries]) AC_SUBST([SILE_LIB_PATH]) diff --git a/core/pathsetup.lua.in b/core/pathsetup.lua.in index ac31c3b03..d7556f58d 100644 --- a/core/pathsetup.lua.in +++ b/core/pathsetup.lua.in @@ -93,6 +93,10 @@ extendPaths("@SILE_LIB_PATH@", true) -- development mode source directory or expected system installation location). if "@SYSTEM_LUAROCKS_FALSE@" == "" then -- see ./configure --with[out]-system-luarocks extendPathsRocks("@SILE_PATH@/lua_modules") +elseif "@VENDORED_LUAROCKS_TRUE@" == "" then -- see ./configure --with-vendored-luarocks=DIR + -- Accommodate Homebrew (and any other distros that pretend a vendored location is the system) in handling their + -- preferred location without clobbering users’ ability to setup 3rd party packages using `luarocks path`. + extendPathsRocks("@VENDORED_LUAROCKS_DIR@") end -- Stuff the variants of system Lua Rocks paths with sile suffixes added back at higher priority that regular paths.