From 5d32d5629dc579013f9b3b4e7ad818e5df5b911f Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 15 Jun 2024 22:37:02 +0300 Subject: [PATCH 1/8] chore(deps): Bump pinned versions of patch level crate updates --- Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 010c317c5..4c6dd34fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1216,9 +1216,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" @@ -1328,7 +1328,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.1", + "redox_syscall 0.5.2", "smallvec", "windows-targets 0.52.5", ] @@ -1410,9 +1410,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags 2.5.0", ] From cd135d2fc5e3917985285eb10ed740112aff4bc1 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 15 Jun 2024 17:04:04 +0300 Subject: [PATCH 2/8] refactor(cli): Separate Rust concerns in a workspace --- Cargo.toml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 089786c2d..55dbb2fac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,32 @@ -[package] -name = "sile" -version = "0.15.3" +[workspace] +resolver = "2" +members = [ + ".", +] + +[workspace.package] edition = "2021" -rust-version = "1.71.0" -description = "Simon’s Improved Layout Engine" authors = [ "Simon Cozens", "Caleb Maclennan ", "Olivier Nicole", "Didier Willis" ] -readme = "README.md" homepage = "https://sile-typesetter.org" repository = "https://github.com/sile-typesetter/sile" license = "MIT" + +[package] +name = "sile" +version = "0.15.3" +edition.workspace = true +rust-version = "1.71.0" +description = "Simon’s Improved Layout Engine" +authors.workspace = true +homepage.workspace = true +readme = "README.md" +repository.workspace = true +license.workspace = true build = "build-aux/build.rs" [[bin]] From 4e50cc7be7f42d45703412752ce7a3adecd1a122 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 15 Jun 2024 22:24:38 +0300 Subject: [PATCH 3/8] feat(core): Add separate crate to enable exporting interfaces to Lua --- Cargo.lock | 8 ++++++++ Cargo.toml | 13 ++++++++----- Makefile.am | 24 ++++++++++++++++++++++-- build-aux/build.rs | 2 ++ build-aux/pkg.nix | 3 +++ core/sile.lua | 6 ++++++ rusile/Cargo.toml | 28 ++++++++++++++++++++++++++++ rusile/src/lib.rs | 11 +++++++++++ src/embed.rs.in | 4 ++++ 9 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 rusile/Cargo.toml create mode 100644 rusile/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 4c6dd34fd..728c3b7b8 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 55dbb2fac..140b7d196 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 7ea15a56b..c2ddcb85e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,16 +56,22 @@ endif $(MANUAL): $(FIGURES) BUILT_LUA_SOURCES = core/features.lua core/pathsetup.lua core/version.lua +RUSILE_SOURCES = rusile/Cargo.toml rusile/src/lib.rs 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 EXTRA_sile_SOURCES = -if !EMBEDDED_RESOURCES +if EMBEDDED_RESOURCES +noinst_LIBRARIES = librusile.a +librusile_a_SOURCES = $(RUSILE_SOURCES) +else !EMBEDDED_RESOURCES nobase_dist_pkgdata_DATA = $(SILEDATA) $(LUALIBRARIES) nobase_nodist_pkgdata_DATA = $(BUILT_LUA_SOURCES) $(LUAMODULES) -endif +pkglib_LIBRARIES = rusile.so +rusile_so_SOURCES = $(RUSILE_SOURCES) +endif !EMBEDDED_RESOURCES dist_doc_DATA = README.md CHANGELOG.md dist_pdf_DATA = $(_MANUAL) dist_license_DATA = LICENSE.md @@ -122,6 +128,7 @@ $(CARGO_BIN): justenough/.libs/justenoughicu.a $(CARGO_BIN): justenough/.libs/justenoughlibtexpdf.a $(CARGO_BIN): justenough/.libs/svg.a $(CARGO_BIN): libtexpdf/.libs/libtexpdf.a +$(CARGO_BIN): librusile.a librusile.so src/embed-includes.rs: Makefile-distfiles { @@ -146,6 +153,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 +167,18 @@ if FONT_VARIATIONS CARGO_FEATURE_ARGS += --features variations endif +rusile.so: + $(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) $(RUSILE_FEATURE_ARG) $(CARGO_RELEASE_ARGS) -p rusile + $(INSTALL) @builddir@/target/@RUST_TARGET_SUBDIR@/lib$@ $@ + +librusile.a: + $(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) $(RUSILE_FEATURE_ARG) $(CARGO_RELEASE_ARGS) -p rusile + $(INSTALL) @builddir@/target/@RUST_TARGET_SUBDIR@/$@ $@ + +librusile.so: + $(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) $(RUSILE_FEATURE_ARG) $(CARGO_RELEASE_ARGS) -p rusile + $(INSTALL) @builddir@/target/@RUST_TARGET_SUBDIR@/$@ $@ + DEPDIR := .deps LOCALFONTS := FONTCONFIG_FILE=$(PWD)/fontconfig.conf LOCALPATHS := SILE_PATH="$(PWD);libtexpdf/.libs;justenough/.libs" diff --git a/build-aux/build.rs b/build-aux/build.rs index 2f90b107f..b92f40575 100644 --- a/build-aux/build.rs +++ b/build-aux/build.rs @@ -36,6 +36,8 @@ fn main() { generate_shell_completions(); #[cfg(feature = "static")] { + println!("cargo:rustc-link-arg=-lrusile"); + let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); println!( "cargo:rustc-link-search=native={}", diff --git a/build-aux/pkg.nix b/build-aux/pkg.nix index 1514da569..d1e2939ec 100644 --- a/build-aux/pkg.nix +++ b/build-aux/pkg.nix @@ -115,6 +115,9 @@ in stdenv.mkDerivation (finalAttrs: { # `pdfinfo`, by using `false` we make sure that if it is expected during # build time we would fail to build since we only provide it at test time. "PDFINFO=false" + # We're using Cargo to build a shared library skipping some libtool bits + # and Nix mistakenly assumes are relevant and thinks it needs to cleanup. + "RANLIB=:" #"--with-manual" In Nixpkgs we add this flag, here its not important enough ] ++ lib.optionals (!lua.pkgs.isLuaJIT) [ "--without-luajit" diff --git a/core/sile.lua b/core/sile.lua index 037e96c46..70f8c12ff 100644 --- a/core/sile.lua +++ b/core/sile.lua @@ -16,6 +16,12 @@ SILE = {} --- Fields -- @section fields +--- Load the C module that provides any and all SILE features implemented in Rust. The exports in this module are meant +--- to be moved to approprate places in the Lua API as we load other things and assemble the public facing interface. +--- This location is considered internal and accessing them directly from here is not supported. +-- @table SILE.rusile +SILE._rusile = require("rusile") + --- Machine friendly short-form version. -- Semver, prefixed with "v", possible postfixed with ".r" followed by VCS version information. -- @string version diff --git a/rusile/Cargo.toml b/rusile/Cargo.toml new file mode 100644 index 000000000..ea6afb749 --- /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", "staticlib"] + +[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 000000000..c5bb5e723 --- /dev/null +++ b/rusile/src/lib.rs @@ -0,0 +1,11 @@ +#![crate_type = "cdylib"] +#![crate_type = "rlib"] +#![crate_type = "staticlib"] + +use mlua::prelude::*; + +#[mlua::lua_module] +fn rusile(lua: &Lua) -> LuaResult { + let exports = lua.create_table().unwrap(); + Ok(exports) +} diff --git a/src/embed.rs.in b/src/embed.rs.in index 9d35d32da..1db7e9687 100644 --- a/src/embed.rs.in +++ b/src/embed.rs.in @@ -31,6 +31,7 @@ pub struct SileModules; // Link Lua loader functions from C modules that Lua would otherwise be loading externally that // we've linked into the CLI binary. Linking happens in build-aux/build.rs. extern "C-unwind" { + fn luaopen_rusile(lua: *mut mlua::lua_State) -> i32; fn luaopen_fontmetrics(lua: *mut mlua::lua_State) -> i32; fn luaopen_justenoughfontconfig(lua: *mut mlua::lua_State) -> i32; fn luaopen_justenoughharfbuzz(lua: *mut mlua::lua_State) -> i32; @@ -52,6 +53,9 @@ pub fn inject_embedded_loader(lua: &Lua) { loaders .push(LuaFunction::wrap(|lua, module: String| unsafe { match module.as_str() { + "rusile" => lua + .create_c_function(luaopen_rusile) + .map(LuaValue::Function), "fontmetrics" => lua .create_c_function(luaopen_fontmetrics) .map(LuaValue::Function), From 6b37a744df02f66f8fe7f8774c830fea6f08555f Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 16 Jun 2024 00:50:54 +0300 Subject: [PATCH 4/8] test(api): Mockup how to test a Rust function from Lua --- rusile/src/lib.rs | 6 ++++++ spec/rusile_spec.lua | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 spec/rusile_spec.lua diff --git a/rusile/src/lib.rs b/rusile/src/lib.rs index c5bb5e723..f23720174 100644 --- a/rusile/src/lib.rs +++ b/rusile/src/lib.rs @@ -7,5 +7,11 @@ use mlua::prelude::*; #[mlua::lua_module] fn rusile(lua: &Lua) -> LuaResult { let exports = lua.create_table().unwrap(); + let foo: LuaFunction = lua.create_function(foo).unwrap(); + exports.set("foo", foo)?; Ok(exports) } + +fn foo(lua: &Lua, (): ()) -> LuaResult { + lua.create_string("Hello from rusile") +} diff --git a/spec/rusile_spec.lua b/spec/rusile_spec.lua new file mode 100644 index 000000000..3eed95c27 --- /dev/null +++ b/spec/rusile_spec.lua @@ -0,0 +1,16 @@ +SILE = require("core.sile") + +describe("rusile", function () + + it("should exist", function () + assert.is.truthy(SILE._rusile) + end) + + describe("foo ", function () + it("should return a test string", function () + local str = "Hello from rusile" + assert.is.equal(str, SILE._rusile.foo()) + end) + end) + +end) From b3afb0bab54c88818919ee003ff0364a3de17a59 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 28 Jun 2024 13:42:22 +0300 Subject: [PATCH 5/8] chore(deps): Bump pinned versions of patch level crate updates --- Cargo.lock | 357 ++++++++--------------------------------------------- 1 file changed, 54 insertions(+), 303 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 728c3b7b8..017050471 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,9 +92,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block-buffer" @@ -159,9 +159,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.99" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" +checksum = "ac367972e516d45567c7eafc73d24e1c193dcf200a8d94e9db7b3d38b349572d" [[package]] name = "cfg-if" @@ -194,9 +194,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.5" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2020fa13af48afc65a9a87335bda648309ab3d154cd03c7ff95b378c7ed39c4" +checksum = "fbca90c87c2a04da41e95d1856e8bcd22f159bdbfa147314d2ce5218057b0e58" dependencies = [ "clap", ] @@ -210,7 +210,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -340,17 +340,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "dunce" version = "1.0.4" @@ -359,9 +348,9 @@ checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "errno" @@ -578,7 +567,7 @@ version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbd06203b1a9b33a78c88252a625031b094d9e1b647260070c25b09910c0a804" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "bstr", "gix-path", "libc", @@ -587,9 +576,9 @@ dependencies = [ [[package]] name = "gix-date" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "367ee9093b0c2b04fd04c5c7c8b6a1082713534eab537597ae343663a518fa99" +checksum = "9eed6931f21491ee0aeb922751bd7ec97b4b2fe8fbfedcb678e2a2dce5f3b8c0" dependencies = [ "bstr", "itoa", @@ -657,7 +646,7 @@ version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae6232f18b262770e343dcdd461c0011c9b9ae27f0c805e115012aa2b902c1b8" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "bstr", "gix-features", "gix-path", @@ -690,7 +679,7 @@ version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e50e63df6c8d4137f7fb882f27643b3a9756c468a1a2cdbe1ce443010ca8778" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "bstr", "btoi", "filetime", @@ -728,7 +717,7 @@ checksum = "999ce923619f88194171a67fb3e6d613653b8d4d6078b529b15a765da0edcc17" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -791,9 +780,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23623cf0f475691a6d943f898c4d0b89f5c1a2a64d0f92bce0e0322ee6528783" +checksum = "ca987128ffb056d732bd545db5db3d8b103d252fbf083c2567bb0796876619a4" dependencies = [ "bstr", "gix-trace", @@ -885,7 +874,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fddc27984a643b20dd03e97790555804f98cf07404e0e552c0ad8133266a79a1" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "gix-path", "libc", "windows-sys 0.52.0", @@ -1010,134 +999,14 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "icu_collections" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locid" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" - -[[package]] -name = "icu_normalizer" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" - -[[package]] -name = "icu_properties" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid_transform", - "icu_properties_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" - -[[package]] -name = "icu_provider" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "idna" -version = "1.0.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "icu_normalizer", - "icu_properties", - "smallvec", - "utf8_iter", + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -1173,12 +1042,6 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" -[[package]] -name = "litemap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" - [[package]] name = "lock_api" version = "0.4.12" @@ -1191,9 +1054,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lua-src" @@ -1231,18 +1094,18 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "mlua" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e340c022072f3208a4105458286f4985ba5355bfe243c3073afe45cbe9ecf491" +checksum = "d111deb18a9c9bd33e1541309f4742523bfab01d276bfa9a27519f6de9c11dc7" dependencies = [ "bstr", "mlua-sys", @@ -1254,9 +1117,9 @@ dependencies = [ [[package]] name = "mlua-sys" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5552e7e4e22ada0463dfdeee6caf6dc057a189fdc83136408a8f950a5e5c5540" +checksum = "a088ed0723df7567f569ba018c5d48c23c501f3878b190b04144dfa5ebfa8abc" dependencies = [ "cc", "cfg-if", @@ -1277,7 +1140,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1377,9 +1240,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1414,7 +1277,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -1480,7 +1343,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.66", + "syn 2.0.68", "walkdir", ] @@ -1497,9 +1360,9 @@ dependencies = [ [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustix" @@ -1507,7 +1370,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -1567,14 +1430,14 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" dependencies = [ "itoa", "ryu", @@ -1637,12 +1500,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "strsim" version = "0.11.1" @@ -1661,26 +1518,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "synstructure" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "tempfile" version = "3.10.1" @@ -1720,7 +1566,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1756,21 +1602,11 @@ dependencies = [ "time-core", ] -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" dependencies = [ "tinyvec_macros", ] @@ -1787,6 +1623,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-bom" version = "2.0.3" @@ -1810,27 +1652,15 @@ dependencies = [ [[package]] name = "url" -version = "2.5.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "utf8parse" version = "0.2.2" @@ -2042,82 +1872,3 @@ name = "winsafe" version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" - -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - -[[package]] -name = "yoke" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", -] - -[[package]] -name = "zerofrom" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", -] - -[[package]] -name = "zerovec" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] From 977c33422d30ed72a31c3a0d3692f6181c71fd23 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 2 Jul 2024 14:24:50 +0300 Subject: [PATCH 6/8] chore(tooling): Call out Rusile module as possile commit scope --- .commitlintrc.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.commitlintrc.yml b/.commitlintrc.yml index bcedfff22..4eae08e9c 100644 --- a/.commitlintrc.yml +++ b/.commitlintrc.yml @@ -51,6 +51,7 @@ rules: - pdf - readme - release + - rusile - settings - shapers - tooling From 3d2dc55fc5696c6259bcd8704dc044d148f51d27 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 2 Jul 2024 14:18:38 +0300 Subject: [PATCH 7/8] refactor(rusile): Move function into sile, keep rusile as just bindings --- rusile/src/lib.rs | 4 +++- src/lib.rs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rusile/src/lib.rs b/rusile/src/lib.rs index f23720174..ed664d41c 100644 --- a/rusile/src/lib.rs +++ b/rusile/src/lib.rs @@ -3,6 +3,7 @@ #![crate_type = "staticlib"] use mlua::prelude::*; +use sile::rusile_demo; #[mlua::lua_module] fn rusile(lua: &Lua) -> LuaResult { @@ -13,5 +14,6 @@ fn rusile(lua: &Lua) -> LuaResult { } fn foo(lua: &Lua, (): ()) -> LuaResult { - lua.create_string("Hello from rusile") + let s = rusile_demo(); + lua.create_string(s) } diff --git a/src/lib.rs b/src/lib.rs index 801344833..11fb2dfa2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -200,3 +200,7 @@ fn path_to_string(path: &PathBuf) -> String { fn paths_to_strings(paths: Vec) -> Vec { paths.iter().map(path_to_string).collect() } + +pub fn rusile_demo() -> String { + "Hello from rusile".to_string() +} From 5c1e88a4537e31d54a2e0a0fef73d69d39d69fe9 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 2 Jul 2024 17:10:33 +0300 Subject: [PATCH 8/8] fixup! test(api): Mockup how to test a Rust function from Lua --- rusile/src/lib.rs | 10 +++++----- spec/rusile_spec.lua | 4 ++-- src/lib.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rusile/src/lib.rs b/rusile/src/lib.rs index ed664d41c..9516dfea8 100644 --- a/rusile/src/lib.rs +++ b/rusile/src/lib.rs @@ -8,12 +8,12 @@ use sile::rusile_demo; #[mlua::lua_module] fn rusile(lua: &Lua) -> LuaResult { let exports = lua.create_table().unwrap(); - let foo: LuaFunction = lua.create_function(foo).unwrap(); - exports.set("foo", foo)?; + let demo: LuaFunction = lua.create_function(demo).unwrap(); + exports.set("demo", demo)?; Ok(exports) } -fn foo(lua: &Lua, (): ()) -> LuaResult { - let s = rusile_demo(); - lua.create_string(s) +fn demo(lua: &Lua, (): ()) -> LuaResult { + let res = rusile_demo().unwrap(); + lua.create_string(res) } diff --git a/spec/rusile_spec.lua b/spec/rusile_spec.lua index 3eed95c27..30cbb1117 100644 --- a/spec/rusile_spec.lua +++ b/spec/rusile_spec.lua @@ -6,10 +6,10 @@ describe("rusile", function () assert.is.truthy(SILE._rusile) end) - describe("foo ", function () + describe("demo ", function () it("should return a test string", function () local str = "Hello from rusile" - assert.is.equal(str, SILE._rusile.foo()) + assert.is.equal(str, SILE._rusile.demo()) end) end) diff --git a/src/lib.rs b/src/lib.rs index 11fb2dfa2..3745574fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -201,6 +201,6 @@ fn paths_to_strings(paths: Vec) -> Vec { paths.iter().map(path_to_string).collect() } -pub fn rusile_demo() -> String { - "Hello from rusile".to_string() +pub fn rusile_demo() -> Result { + Ok("Hello from rusile".to_string()) }