From 8dd4aed071da295b159b988db4c303c870433c8c Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 12 Sep 2023 19:05:09 +0300 Subject: [PATCH 1/4] chore(build): Finish up --enable-developer not needing --datarootdir for local hacking --- configure.ac | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index a8556081b..e6de19dba 100644 --- a/configure.ac +++ b/configure.ac @@ -308,16 +308,17 @@ 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(["${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]) 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"]) From 52b567f001f9e310c2d0285a4bb5d8b786fd1670 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 12 Sep 2023 20:31:53 +0300 Subject: [PATCH 2/4] chore(build): Pass build time lua package path to Rust runtime --- .cargo/config.toml | 4 +--- Makefile-luarocks | 4 ++-- configure.ac | 6 ++++++ core/pathsetup.lua.in | 6 ++++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 9037819ed..2d560c29a 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 7ea0dc624..c4ded991d 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 e6de19dba..fec7e61d2 100644 --- a/configure.ac +++ b/configure.ac @@ -310,12 +310,18 @@ AX_SUBST_TRANSFORMED_PACKAGE_NAME 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 b9ef4bc29..413d3ce65 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+") From bec64f4128193b51e07accf57c51fcae6a6270de Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 12 Sep 2023 21:15:31 +0300 Subject: [PATCH 3/4] chore(build): Remove unused msys specific build-time configuration --- configure.ac | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index fec7e61d2..330d6e2fc 100644 --- a/configure.ac +++ b/configure.ac @@ -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 From 8c8f44cd14663719ce16712a30c0d991b3963fbf Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 12 Sep 2023 21:31:40 +0300 Subject: [PATCH 4/4] chore(tooling): Rename clippy lint to follow upstream tooling --- .cargo/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 2d560c29a..96522a110 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -16,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", ]