Skip to content

Commit

Permalink
chore(build): Pass build time lua package path to Rust runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Sep 12, 2023
1 parent b71b886 commit 8b7c68c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 1 addition & 3 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 Down
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
7 changes: 7 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,19 @@ AX_SUBST_TRANSFORMED_PACKAGE_NAME
# tests/manual build when developer mode is enabled
AM_COND_IF([DEVELOPER], [
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_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])
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 8b7c68c

Please sign in to comment.