Skip to content

Commit 42a879a

Browse files
committed
fix(cli): Correctly output makedeps files from the Rust CLI the same as from Lua
1 parent d65cf1c commit 42a879a

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎core/cli.lua‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ cli.parseArguments = function ()
101101
table.insert(SILE.input.luarocksTrees, tree)
102102
end
103103
if opts.makedeps then
104-
SILE.makeDeps = require("core.makedeps")
105-
SILE.makeDeps.filename = opts.makedeps
104+
SILE.input.makedeps = opts.makedeps
106105
end
107106
if opts.output then
108107
if opts.output == "STDIO" then

‎core/sile.lua‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ end
206206
--
207207
-- Does not move on to processing input document(s).
208208
function SILE.init ()
209+
if SILE.input.makedeps then
210+
SILE.makeDeps = require("core.makedeps")
211+
SILE.makeDeps.filename = SILE.input.makedeps
212+
end
209213
if SILE.backend then
210214
SU.deprecated("SILE.backend", "SILE.input.backend", "0.15.7", "0.17.0")
211215
SILE.input.backend = SILE.backend

‎src/lib.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ pub fn start_luavm() -> crate::Result<Lua> {
4848
}
4949

5050
pub fn inject_paths(lua: Lua) -> crate::Result<Lua> {
51+
// Note set_name() here can't be left blank or it will resolve to src/lib.rs, and it can't be
52+
// something custom that doesn't resolve to an actual file because it will turn up in the
53+
// makedepends list. We use the internal Lua VM's own =[C] syntax which will be relpaced with
54+
// $0 so that the Rust binary becomes the listed dependency.
5155
#[cfg(feature = "static")]
5256
lua.load(r#"require("core.pathsetup")"#)
53-
.set_name("relative pathsetup loader")
57+
.set_name("=[C]")
5458
.exec()?;
5559
#[cfg(not(feature = "static"))]
5660
{
@@ -70,7 +74,7 @@ pub fn inject_paths(lua: Lua) -> crate::Result<Lua> {
7074
dofile("./core/pathsetup.lua")
7175
end
7276
})
73-
.set_name("hard coded pathsetup loader")
77+
.set_name("=[C]")
7478
.exec()?;
7579
}
7680
Ok(lua)

0 commit comments

Comments
 (0)