From 742feb4de69ab709d55edc112d088473d33494a4 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sat, 16 Nov 2024 16:58:57 +0800 Subject: [PATCH] build: rust lib crate --- src/core_ffi/rust_ffi/Cargo.lock | 71 +++++++++++-------- src/core_ffi/rust_ffi/Cargo.toml | 4 +- .../src/{main.rs => bin/klotski_cli.rs} | 6 +- src/core_ffi/rust_ffi/src/lib.rs | 4 ++ 4 files changed, 48 insertions(+), 37 deletions(-) rename src/core_ffi/rust_ffi/src/{main.rs => bin/klotski_cli.rs} (96%) create mode 100644 src/core_ffi/rust_ffi/src/lib.rs diff --git a/src/core_ffi/rust_ffi/Cargo.lock b/src/core_ffi/rust_ffi/Cargo.lock index 5478db0..50e45cf 100644 --- a/src/core_ffi/rust_ffi/Cargo.lock +++ b/src/core_ffi/rust_ffi/Cargo.lock @@ -4,9 +4,12 @@ version = 3 [[package]] name = "cc" -version = "1.1.1" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "907d8581360765417f8f2e0e7d602733bbed60156b4465b7617243689ef9b83d" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +dependencies = [ + "shlex", +] [[package]] name = "cmake" @@ -29,9 +32,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.124" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "273dcfd3acd4e1e276af13ed2a43eea7001318823e7a726a6b3ed39b4acc0b82" +checksum = "23c042a0ba58aaff55299632834d1ea53ceff73d62373f62c9ae60890ad1b942" dependencies = [ "cc", "cxxbridge-flags", @@ -41,13 +44,12 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.124" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b2766fbd92be34e9ed143898fce6c572dc009de39506ed6903e5a05b68914e" +checksum = "45dc1c88d0fdac57518a9b1f6c4f4fb2aca8f3c30c0d03d7d8518b47ca0bcea6" dependencies = [ "cc", "codespan-reporting", - "once_cell", "proc-macro2", "quote", "scratch", @@ -56,18 +58,19 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.124" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "839fcd5e43464614ffaa989eaf1c139ef1f0c51672a1ed08023307fa1b909ccd" +checksum = "aa7ed7d30b289e2592cc55bc2ccd89803a63c913e008e6eb59f06cddf45bb52f" [[package]] name = "cxxbridge-macro" -version = "1.0.124" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2c1c1776b986979be68bb2285da855f8d8a35851a769fca8740df7c3d07877" +checksum = "0b8c465d22de46b851c04630a5fc749a26005b263632ed2e0d9cc81518ead78d" dependencies = [ "proc-macro2", "quote", + "rustversion", "syn", ] @@ -89,41 +92,47 @@ dependencies = [ "cc", ] -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] +[[package]] +name = "rustversion" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + [[package]] name = "scratch" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "syn" -version = "2.0.71" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -141,30 +150,30 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ "windows-sys", ] [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] diff --git a/src/core_ffi/rust_ffi/Cargo.toml b/src/core_ffi/rust_ffi/Cargo.toml index 4f647d6..afac3ef 100644 --- a/src/core_ffi/rust_ffi/Cargo.toml +++ b/src/core_ffi/rust_ffi/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cxx = "1.0.124" +cxx = "1.0" [build-dependencies] cmake = "0.1" -cxx-build = "1.0.124" +cxx-build = "1.0" diff --git a/src/core_ffi/rust_ffi/src/main.rs b/src/core_ffi/rust_ffi/src/bin/klotski_cli.rs similarity index 96% rename from src/core_ffi/rust_ffi/src/main.rs rename to src/core_ffi/rust_ffi/src/bin/klotski_cli.rs index c5cc900..645fbfc 100644 --- a/src/core_ffi/rust_ffi/src/main.rs +++ b/src/core_ffi/rust_ffi/src/bin/klotski_cli.rs @@ -1,7 +1,5 @@ -mod bridge; - -use bridge::ShortCode; -use bridge::CommonCode; +use klotski::ShortCode; +use klotski::CommonCode; fn short_code_demo() { ShortCode::speed_up(false); diff --git a/src/core_ffi/rust_ffi/src/lib.rs b/src/core_ffi/rust_ffi/src/lib.rs new file mode 100644 index 0000000..9a4a73b --- /dev/null +++ b/src/core_ffi/rust_ffi/src/lib.rs @@ -0,0 +1,4 @@ +mod bridge; + +pub use bridge::ShortCode; +pub use bridge::CommonCode;