Skip to content

Commit e93f072

Browse files
committed
feat(build): Add --with-vendored-luarocks=dir for use in distros with pseudo-system path handling
1 parent bb47f21 commit e93f072

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

configure.ac

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ AC_ARG_WITH([system-luarocks],
7979
AM_CONDITIONAL([SYSTEM_LUAROCKS], [test "x$with_system_luarocks" = "xyes"])
8080
AC_SUBST([SYSTEM_LUAROCKS])
8181

82+
AC_ARG_WITH([vendored-luarocks-dir],
83+
AS_HELP_STRING([--with-vendored-luarocks-dir=PATH],
84+
[Specify a custom vendored location from which to load ‘system’ luarocks]),
85+
[],
86+
[with_vendored_luarocks_dir=no])
87+
AM_CONDITIONAL([VENDORED_LUAROCKS], [test "x$with_vendored_luarocks_dir" != "xno"])
88+
AC_SUBST([VENDORED_LUAROCKS])
89+
8290
AC_ARG_WITH([system-lua-sources],
8391
AS_HELP_STRING([--with-system-lua-sources],
8492
[Don’t compile against vendored Lua sources, use system headers]))
@@ -266,16 +274,20 @@ AM_COND_IF([DEVELOPER_MODE], [
266274
AC_DEFINE_UNQUOTED([SILE_PATH], ["${SILE_PATH}"], [Path for SILE packages and classes])
267275
AC_SUBST([SILE_PATH])
268276

269-
# In order for our Rust CLI binary to use the same default package.path as the system Lua,
270-
# we test the system Lua (required only at build not run time) for its current package.path.
277+
# In order for our Rust CLI binary to use the same default package.(c)path as the system Lua,
278+
# we test the system Lua (required only at build not run time) for its current package.(c)path.
271279
adl_RECURSIVE_EVAL(["$(${LUA} -e 'print(package.path)')"], [SYSTEM_LUA_PATH])
272-
AC_DEFINE_UNQUOTED([SYSTEM_LUA_PATH], ["${SYSTEM_LUA_PATH}"],[System Lua package path])
273-
AC_SUBST([SYSTEM_LUA_PATH])
274-
275280
adl_RECURSIVE_EVAL(["$(${LUA} -e 'print(package.cpath)')"], [SYSTEM_LUA_CPATH])
281+
AC_DEFINE_UNQUOTED([SYSTEM_LUA_PATH], ["${SYSTEM_LUA_PATH}"],[System Lua package path])
276282
AC_DEFINE_UNQUOTED([SYSTEM_LUA_CPATH], ["${SYSTEM_LUA_CPATH}"], [System Lua package cpath])
283+
AC_SUBST([SYSTEM_LUA_PATH])
277284
AC_SUBST([SYSTEM_LUA_CPATH])
278285

286+
# Accommodate Homebrew and/or other distros that pretend a vendored location is the system.
287+
AM_COND_IF([VENDORED_LUAROCKS],
288+
[VENDORED_LUAROCKS_DIR="$with_vendored_luarocks_dir"])
289+
AC_SUBST([VENDORED_LUAROCKS_DIR])
290+
279291
adl_RECURSIVE_EVAL(["${libdir}/${TRANSFORMED_PACKAGE_NAME}"], [SILE_LIB_PATH])
280292
AC_DEFINE_UNQUOTED([SILE_LIB_PATH],["${SILE_LIB_PATH}"], [Path for SILE libraries])
281293
AC_SUBST([SILE_LIB_PATH])

core/pathsetup.lua.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ extendPaths("@SILE_LIB_PATH@", true)
9393
-- development mode source directory or expected system installation location).
9494
if "@SYSTEM_LUAROCKS_FALSE@" == "" then -- see ./configure --with[out]-system-luarocks
9595
extendPathsRocks("@SILE_PATH@/lua_modules")
96+
elseif "@VENDORED_LUAROCKS_TRUE@" == "" then -- see ./configure --with-vendored-luarocks=DIR
97+
-- Accommodate Homebrew (and any other distros that pretend a vendored location is the system) in handling their
98+
-- preferred location without clobbering users’ ability to setup 3rd party packages using `luarocks path`.
99+
extendPathsRocks("@VENDORED_LUAROCKS_DIR@")
96100
end
97101

98102
-- Stuff the variants of system Lua Rocks paths with sile suffixes added back at higher priority that regular paths.

0 commit comments

Comments
 (0)