Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Lua module for exporting Rust functions to Lua #2072

Merged
merged 39 commits into from
Nov 2, 2024

Conversation

alerque
Copy link
Member

@alerque alerque commented Jun 15, 2024

To date we've only had a Rust wrapper with a few strings stuffed in then running an almost entirely Lua code base. An obvious benefit of having Rust at our finger tips is going to be access to different libraries and bindings and speed and type checking and such. But there hasn't been an ergonomic way to start reaching into that toolbox yet. I did some POC work several times before I went down the Rust road so I know it would be possible, but v0.15.0 just had the CLI wrapper.

The current draft of #2064 is the first real function from the Rust side being passed over to Lua. But that approach isn't very sustainable, and it completely breaks compatibility with Lua. We're closer than ever to being able to easily be used as a library from Lua (and with just a little more futzing, also Python, Node, and others). So I don't actually want to go down that road.

Instead I want to make all the Rust API surface we wast to use available on the Lua side via a module that can be built and installed on it's own.

Unfortunately the mlua library can't use the vendored feature at the same time as the module feature, so we have to split out a separate crate for it. This PR does that.

We'll probably want to keep all the code and logic in the sile create's lib and just use the rusile crate to export modules to Lua/Python/whatever. And we'll probably want proc macros to wrap the functions with the right bindings, but that can come later.

As of posting the Lua module builds and runs code, but isn't loaded back into the SILE runtime namespace.

@alerque alerque added this to the v0.15.x milestone Jun 15, 2024
@alerque alerque force-pushed the cargo-workspace-inplace branch 2 times, most recently from e4e8c33 to 0310afb Compare June 24, 2024 22:43
@sile-typesetter sile-typesetter deleted a comment from coveralls Jun 24, 2024
@sile-typesetter sile-typesetter deleted a comment from coveralls Jun 24, 2024
@alerque alerque modified the milestones: v0.15.x, v0.15.5 Jun 27, 2024
@sile-typesetter sile-typesetter deleted a comment from coveralls Jun 28, 2024
@sile-typesetter sile-typesetter deleted a comment from coveralls Jul 2, 2024
@sile-typesetter sile-typesetter deleted a comment from coveralls Jul 2, 2024
@alerque alerque modified the milestones: v0.15.5, v0.15.6 Aug 29, 2024
@alerque
Copy link
Member Author

alerque commented Oct 1, 2024

Just a brainstorm for future self:, I've been wondering how to setup Cargo to build two different variants of the same crate with different features. Maybe we don't need that for a regular SILE build, and the LuaRocks library version could inject it's own feature flag as part of the build. Just an idea to try — I don't know why I was fixated on needing to build a Lua module to load in Rust. As long as we feed the same functions in Rust (and inject in the CLI) the same functions that go into the module, there is no reason to load the module at all on the Rust side.

@alerque alerque marked this pull request as ready for review November 2, 2024 12:38
@alerque alerque added enhancement Software improvement or feature request tooling Build tooling, release management, and packaging processes labels Nov 2, 2024
@alerque alerque force-pushed the cargo-workspace-inplace branch 3 times, most recently from c89830c to c30e111 Compare November 2, 2024 13:06
@coveralls
Copy link

coveralls commented Nov 2, 2024

Coverage Status

coverage: 60.38% (-9.0%) from 69.34%
when pulling 155dc89 on cargo-workspace-inplace
into f864fa1 on master.

@alerque alerque merged commit da1829c into master Nov 2, 2024
40 of 42 checks passed
@alerque alerque deleted the cargo-workspace-inplace branch November 2, 2024 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Software improvement or feature request tooling Build tooling, release management, and packaging processes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants