Skip to content

Commit

Permalink
Merge pull request #1872 from sile-typesetter/lua-path
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque authored Sep 12, 2023
2 parents 00a7ba5 + 8c8f44c commit 6f980b8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
6 changes: 2 additions & 4 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ rustflags = ["-C", "link-args=-rdynamic"]
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "link-args=-rdynamic"]

# Since autotools sets this and we are *not* forcing it here, this will not
# Since autotools sets these and we are *not* forcing them here, this will not
# affect release builds. It will affect `cargo run` and make it easier to test
# locally since the Lua loader path will be relative to the current sources.
# For debug builds it is assumed you configured `--without-system-luarocks`,
# this convenience won't enable you to use system packages in debug builds.
[env]
SILE_PATH = { value = "", relative = true }

Expand All @@ -18,6 +16,6 @@ rustflags = [
# This is a workaround to configure lints for the entire workspace, pending the ability to configure this via TOML.
# See: `https://github.com/rust-lang/cargo/issues/5034`
# `https://github.com/EmbarkStudios/rust-ecosystem/issues/22#issuecomment-947011395`
"-Aclippy::clone_double_ref",
"-Asuspicious_double_ref_op",
"-Aclippy::ptr_arg",
]
4 changes: 2 additions & 2 deletions Makefile-luarocks
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $(LUAMODLOCK): lua_modules $(LUAMODSPEC)
$(genrockslock) > $@
else
LUAMODLOCK :=
LUA_PATH := $(shell lua$(LUA_VERSION) -e 'print(package.path)')
LUA_CPATH := $(shell lua$(LUA_VERSION) -e 'print(package.cpath)')
LUA_PATH := $(shell $(LUA) -e 'print(package.path)')
LUA_CPATH := $(shell $(LUA) -e 'print(package.cpath)')
export LUA_PATH LUA_CPATH
endif
23 changes: 11 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,7 @@ AM_COND_IF([DEPENDENCY_CHECKS], [
fi
])
case $host_os in
msys)
LUA_VERSION=5.3 # By fiat. This is obviously not good.
;;
*)
AX_PROG_LUA([5.1])
;;
esac
AX_PROG_LUA([5.1])
AX_LUA_HEADERS
AX_LUA_LIBS
Expand Down Expand Up @@ -308,16 +300,23 @@ AX_SUBST_TRANSFORMED_PACKAGE_NAME
# Avoid need for `--datarootdir=$(cd ..; pwd)` hack to run locally for
# tests/manual build when developer mode is enabled
AM_COND_IF([DEVELOPER], [
AC_DEFINE_UNQUOTED([SILE_PATH],["$(pwd)"],[Path for SILE packages and classes])
adl_RECURSIVE_EVAL(["$(pwd)"], [SILE_PATH])
AC_DEFINE_UNQUOTED([SILE_PATH], ["${SILE_PATH}"], [Path for SILE packages and classes])
adl_RECURSIVE_EVAL(["$(${LUA} -e 'print(package.path)')"], [LUA_PATH])
AC_DEFINE_UNQUOTED([LUA_PATH], ["${LUA_PATH}"],[System Lua package path])
adl_RECURSIVE_EVAL(["$(${LUA} -e 'print(package.cpath)')"], [LUA_CPATH])
AC_DEFINE_UNQUOTED([LUA_CPATH], ["${LUA_CPATH}"], [System Lua package cpath])
],[
adl_RECURSIVE_EVAL(["${datadir}/${TRANSFORMED_PACKAGE_NAME}"], [SILE_PATH])
AC_DEFINE_UNQUOTED([SILE_PATH],["${SILE_PATH}"],[Path for SILE packages and classes])
AC_DEFINE_UNQUOTED([SILE_PATH], ["${SILE_PATH}"], [Path for SILE packages and classes])
])

AC_SUBST([SILE_PATH])
AC_SUBST([LUA_PATH])
AC_SUBST([LUA_CPATH])

adl_RECURSIVE_EVAL(["${libdir}/${TRANSFORMED_PACKAGE_NAME}"], [SILE_LIB_PATH])
AC_DEFINE_UNQUOTED([SILE_LIB_PATH],["${SILE_LIB_PATH}"],[Path for SILE libraries])
AC_DEFINE_UNQUOTED([SILE_LIB_PATH],["${SILE_LIB_PATH}"], [Path for SILE libraries])
AC_SUBST([SILE_LIB_PATH])

AC_SUBST([ROCKSPECWARNING], ["DO NOT EDIT! Modify template sile.rockspec.in"])
Expand Down
6 changes: 6 additions & 0 deletions core/pathsetup.lua.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-- Allow autoconf to setup system lua paths at compile time, not run time (only used in developer mode)
if "@LUA_PATH@" ~= "" then
package.path = "@LUA_PATH@"
package.cpath = "@LUA_CPATH@"
end

local executable = debug.getinfo(3, "S").source
local luaversion = _VERSION:match("%d+%.%d+")

Expand Down

0 comments on commit 6f980b8

Please sign in to comment.