diff --git a/Cargo.lock b/Cargo.lock index 4c6dd34fdd..728c3b7b83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1452,6 +1452,14 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316" +[[package]] +name = "rusile" +version = "0.15.3" +dependencies = [ + "mlua", + "sile", +] + [[package]] name = "rust-embed" version = "8.4.0" diff --git a/Cargo.toml b/Cargo.toml index 55dbb2facb..140b7d1963 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 ", @@ -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" diff --git a/Makefile.am b/Makefile.am index 7ea15a56b1..c3de0b6f11 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 @@ -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 @@ -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" diff --git a/rusile/Cargo.toml b/rusile/Cargo.toml new file mode 100644 index 0000000000..564dbe0063 --- /dev/null +++ b/rusile/Cargo.toml @@ -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" ] diff --git a/rusile/src/lib.rs b/rusile/src/lib.rs new file mode 100644 index 0000000000..a4c43901d3 --- /dev/null +++ b/rusile/src/lib.rs @@ -0,0 +1,7 @@ +use mlua::prelude::*; + +#[mlua::lua_module] +fn rusile(lua: &Lua) -> LuaResult { + let exports = lua.create_table().unwrap(); + Ok(exports) +}