diff --git a/.cargo/config.toml b/.cargo/config.toml index 9037819ed4..2d560c29a3 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -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 } diff --git a/Makefile-luarocks b/Makefile-luarocks index 7ea0dc624c..c4ded991dc 100644 --- a/Makefile-luarocks +++ b/Makefile-luarocks @@ -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 diff --git a/configure.ac b/configure.ac index d7662649c8..fec7e61d29 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/core/pathsetup.lua.in b/core/pathsetup.lua.in index b9ef4bc29c..413d3ce65f 100644 --- a/core/pathsetup.lua.in +++ b/core/pathsetup.lua.in @@ -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+")