Skip to content

Commit

Permalink
feat(core): Add separate crate to enable exporting interfaces to Lua
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jun 24, 2024
1 parent cd135d2 commit 448dbf4
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 6 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
resolver = "2"
members = [
".",
"rusile",
]

[workspace.package]
version = "0.15.3"
edition = "2021"
rust-version = "1.71.0"
authors = [
"Simon Cozens",
"Caleb Maclennan <caleb@alerque.com>",
Expand All @@ -18,16 +21,16 @@ license = "MIT"

[package]
name = "sile"
version = "0.15.3"
edition.workspace = true
rust-version = "1.71.0"
description = "Simon’s Improved Layout Engine"
readme = "README.md"
build = "build-aux/build.rs"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
authors.workspace = true
homepage.workspace = true
readme = "README.md"
repository.workspace = true
license.workspace = true
build = "build-aux/build.rs"

[[bin]]
name = "sile"
Expand Down
11 changes: 10 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,20 @@ endif
$(MANUAL): $(FIGURES)

BUILT_LUA_SOURCES = core/features.lua core/pathsetup.lua core/version.lua
RUSILE_SOURCES = rusile/Cargo.toml rusile/src/lib.rs
RUSILE_MODULE = rusile.so

bin_PROGRAMS = sile
bin_SCRIPTS = sile-lua
dist_man_MANS = sile-lua.1
sile_SOURCES = src/bin/sile.rs src/lib.rs src/cli.rs
sile_SOURCES = src/bin/sile.rs src/lib.rs src/cli.rs $(RUSILE_SOURCES)
EXTRA_sile_SOURCES =
if !EMBEDDED_RESOURCES
nobase_dist_pkgdata_DATA = $(SILEDATA) $(LUALIBRARIES)
nobase_nodist_pkgdata_DATA = $(BUILT_LUA_SOURCES) $(LUAMODULES)
endif
pkglib_LIBRARIES = $(RUSILE_MODULE)
rusile_so_SOURCES = $(RUSILE_SOURCES)
dist_doc_DATA = README.md CHANGELOG.md
dist_pdf_DATA = $(_MANUAL)
dist_license_DATA = LICENSE.md
Expand Down Expand Up @@ -146,6 +150,7 @@ else
MLUAVER = lua$(LUA_SHORT_VERSION)
endif
CARGO_FEATURE_ARGS = --features $(MLUAVER)
RUSILE_FEATURE_ARG = --features $(MLUAVER)

if !SYSTEM_LUA_SOURCES
CARGO_FEATURE_ARGS += --features vendored
Expand All @@ -159,6 +164,10 @@ if FONT_VARIATIONS
CARGO_FEATURE_ARGS += --features variations
endif

$(RUSILE_MODULE):
$(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) $(RUSILE_FEATURE_ARG) $(CARGO_RELEASE_ARGS) -p rusile
$(INSTALL) @builddir@/target/@RUST_TARGET_SUBDIR@/lib$@ $@

DEPDIR := .deps
LOCALFONTS := FONTCONFIG_FILE=$(PWD)/fontconfig.conf
LOCALPATHS := SILE_PATH="$(PWD);libtexpdf/.libs;justenough/.libs"
Expand Down
28 changes: 28 additions & 0 deletions rusile/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "rusile"
description = "Rusty components for the SILE typesetter"
readme = "README.md"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true

[lib]
crate_type = ["rlib", "cdylib"]

[dependencies.sile]
path = ".."

[features]
lua54 = [ "mlua/lua54" ]
lua53 = [ "mlua/lua53" ]
lua52 = [ "mlua/lua52" ]
lua51 = [ "mlua/lua51" ]
luajit = [ "mlua/luajit" ]

[dependencies.mlua]
version = "0.9"
features = [ "module" ]
7 changes: 7 additions & 0 deletions rusile/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use mlua::prelude::*;

#[mlua::lua_module]
fn rusile(lua: &Lua) -> LuaResult<LuaTable> {
let exports = lua.create_table().unwrap();
Ok(exports)
}

0 comments on commit 448dbf4

Please sign in to comment.