wasmtime update

This commit is contained in:
Christof Petig 2024-05-20 15:56:38 +02:00
parent 5bced33ff6
commit 8502aabe68
3 changed files with 183 additions and 279 deletions

389
Cargo.lock generated
View File

@ -470,7 +470,7 @@ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
"object", "object 0.32.2",
"rustc-demangle", "rustc-demangle",
] ]
@ -504,7 +504,7 @@ dependencies = [
"bitflags 2.5.0", "bitflags 2.5.0",
"cexpr", "cexpr",
"clang-sys", "clang-sys",
"itertools 0.12.1", "itertools 0.10.5",
"lazy_static", "lazy_static",
"lazycell", "lazycell",
"proc-macro2 1.0.82", "proc-macro2 1.0.82",
@ -688,9 +688,9 @@ checksum = "4bdcae87153686017415ce77e48c53e6818a0a058f0e21b56640d1e944967ef8"
[[package]] [[package]]
name = "cap-fs-ext" name = "cap-fs-ext"
version = "2.0.1" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88e341d15ac1029aadce600be764a1a1edafe40e03cde23285bc1d261b3a4866" checksum = "2fc2d2954524be4866aaa720f008fba9995de54784957a1b0e0119992d6d5e52"
dependencies = [ dependencies = [
"cap-primitives", "cap-primitives",
"cap-std", "cap-std",
@ -700,9 +700,9 @@ dependencies = [
[[package]] [[package]]
name = "cap-net-ext" name = "cap-net-ext"
version = "2.0.1" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "434168fe6533055f0f4204039abe3ff6d7db338ef46872a5fa39e9d5ad5ab7a9" checksum = "799c81d79ea9c71a1438efd417c788214bc9e7986046d3710b6bbe60da4d8275"
dependencies = [ dependencies = [
"cap-primitives", "cap-primitives",
"cap-std", "cap-std",
@ -712,9 +712,9 @@ dependencies = [
[[package]] [[package]]
name = "cap-primitives" name = "cap-primitives"
version = "2.0.1" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe16767ed8eee6d3f1f00d6a7576b81c226ab917eb54b96e5f77a5216ef67abb" checksum = "00172660727e2d7f808e7cc2bfffd093fdb3ea2ff2ef819289418a3c3ffab5ac"
dependencies = [ dependencies = [
"ambient-authority", "ambient-authority",
"fs-set-times", "fs-set-times",
@ -729,9 +729,9 @@ dependencies = [
[[package]] [[package]]
name = "cap-rand" name = "cap-rand"
version = "2.0.1" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20e5695565f0cd7106bc3c7170323597540e772bb73e0be2cd2c662a0f8fa4ca" checksum = "270f1d341a2afc62604f8f688bee4e444d052b7a74c1458dd3aa7efb47d4077f"
dependencies = [ dependencies = [
"ambient-authority", "ambient-authority",
"rand 0.8.5", "rand 0.8.5",
@ -739,9 +739,9 @@ dependencies = [
[[package]] [[package]]
name = "cap-std" name = "cap-std"
version = "2.0.1" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "593db20e4c51f62d3284bae7ee718849c3214f93a3b94ea1899ad85ba119d330" checksum = "8cd9187bb3f7478a4c135ea10473a41a5f029d2ac800c1adf64f35ec7d4c8603"
dependencies = [ dependencies = [
"cap-primitives", "cap-primitives",
"io-extras", "io-extras",
@ -751,9 +751,9 @@ dependencies = [
[[package]] [[package]]
name = "cap-time-ext" name = "cap-time-ext"
version = "2.0.1" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03261630f291f425430a36f38c847828265bc928f517cdd2004c56f4b02f002b" checksum = "91666f31e30c85b1d2ee8432c90987f752c45f5821f5638027b41e73e16a395b"
dependencies = [ dependencies = [
"ambient-authority", "ambient-authority",
"cap-primitives", "cap-primitives",
@ -786,9 +786,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.97" version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f"
dependencies = [ dependencies = [
"jobserver", "jobserver",
"libc", "libc",
@ -1270,9 +1270,9 @@ dependencies = [
[[package]] [[package]]
name = "cpp_demangle" name = "cpp_demangle"
version = "0.3.5" version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
] ]
@ -1288,18 +1288,18 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-bforest" name = "cranelift-bforest"
version = "0.104.3" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b85034ffd0efe2f8c0ba73a55a021cd936e3f8526fa24adb50f168874a6b1db7" checksum = "ebf72ceaf38f7d41194d0cf6748214d8ef7389167fe09aad80f87646dbfa325b"
dependencies = [ dependencies = [
"cranelift-entity", "cranelift-entity",
] ]
[[package]] [[package]]
name = "cranelift-codegen" name = "cranelift-codegen"
version = "0.104.3" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc6fc9bfd532123a1778ad154c03741c99028e983c3c053cd6a5d177cab3965e" checksum = "9ee7fde5cd9173f00ce02c491ee9e306d64740f4b1a697946e0474f389999e13"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"cranelift-bforest", "cranelift-bforest",
@ -1318,33 +1318,33 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen-meta" name = "cranelift-codegen-meta"
version = "0.104.3" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea93c920184d2d79555c0dde829717180902f69b9983e30b121bbd88288c5e2f" checksum = "b49bec6a517e78d4067500dc16acb558e772491a2bcb37301127448adfb8413c"
dependencies = [ dependencies = [
"cranelift-codegen-shared", "cranelift-codegen-shared",
] ]
[[package]] [[package]]
name = "cranelift-codegen-shared" name = "cranelift-codegen-shared"
version = "0.104.3" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca5378154333193d6eb859514e0062c0c044f98acf8ff067d43aaaaa4e098ce6" checksum = "ead4ea497b2dc2ac31fcabd6d5d0d5dc25b3964814122e343724bdf65a53c843"
[[package]] [[package]]
name = "cranelift-control" name = "cranelift-control"
version = "0.104.3" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d95f6f71863046b42c2e960b1156c86bae2b13842be90349103959a0db9a3c30" checksum = "f81e8028c8d711ea7592648e70221f2e54acb8665f7ecd49545f021ec14c3341"
dependencies = [ dependencies = [
"arbitrary", "arbitrary",
] ]
[[package]] [[package]]
name = "cranelift-entity" name = "cranelift-entity"
version = "0.104.3" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18e625456002617a44c8fbdf276b624639f75e6d11b83c62e64ab8659e352dd5" checksum = "32acd0632ba65c2566e75f64af9ef094bb8d90e58a9fbd33d920977a9d85c054"
dependencies = [ dependencies = [
"serde", "serde",
"serde_derive", "serde_derive",
@ -1352,9 +1352,9 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-frontend" name = "cranelift-frontend"
version = "0.104.3" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c74dde8da13ac38556bafb9c26c2842ec68964cfbe0d07ae40ef879bab7cbbba" checksum = "a395a704934aa944ba8939cac9001174b9ae5236f48bc091f89e33bb968336f6"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"log", "log",
@ -1364,15 +1364,15 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-isle" name = "cranelift-isle"
version = "0.104.3" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5683957e3c8fe5da47d0f23f185b86fb9826b2a10767a7df4ca1fb1dedf16e5e" checksum = "b325ce81c4ee7082dc894537eb342c37898e14230fe7c02ea945691db3e2dd01"
[[package]] [[package]]
name = "cranelift-native" name = "cranelift-native"
version = "0.104.3" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b90167a436f69c210a68a8244c4078b918f9f01339c3c8a7322e72e5b3632a8" checksum = "ea11f5ac85996fa093075d66397922d4f56085d5d84ec13043d0cd4f159c6818"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"libc", "libc",
@ -1381,17 +1381,17 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-wasm" name = "cranelift-wasm"
version = "0.104.3" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "073fa9fbb4c28804245b9daaa74975d712082deab0deebea1d92c3d43593cc91" checksum = "e4f175d4e299a8edabfbd64fa93c7650836cc8ad7f4879f9bd2632575a1f12d0"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"cranelift-entity", "cranelift-entity",
"cranelift-frontend", "cranelift-frontend",
"itertools 0.10.5", "itertools 0.12.1",
"log", "log",
"smallvec", "smallvec",
"wasmparser 0.118.2", "wasmparser",
"wasmtime-types", "wasmtime-types",
] ]
@ -3015,7 +3015,7 @@ dependencies = [
"iana-time-zone-haiku", "iana-time-zone-haiku",
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
"windows-core 0.52.0", "windows-core 0.51.1",
] ]
[[package]] [[package]]
@ -3644,15 +3644,6 @@ dependencies = [
"twox-hash", "twox-hash",
] ]
[[package]]
name = "mach"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "mach2" name = "mach2"
version = "0.4.2" version = "0.4.2"
@ -4396,6 +4387,15 @@ name = "object"
version = "0.32.2" version = "0.32.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
dependencies = [
"memchr",
]
[[package]]
name = "object"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8dd6c0cdf9429bce006e1362bfce61fa1bfd8c898a643ed8d2b471934701d3d"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"hashbrown 0.14.5", "hashbrown 0.14.5",
@ -6287,9 +6287,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]] [[package]]
name = "system-interface" name = "system-interface"
version = "0.26.1" version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0682e006dd35771e392a6623ac180999a9a854b1d4a6c12fb2e804941c2b1f58" checksum = "b858526d22750088a9b3cf2e3c2aacebd5377f13adeec02860c30d09113010a6"
dependencies = [ dependencies = [
"bitflags 2.5.0", "bitflags 2.5.0",
"cap-fs-ext", "cap-fs-ext",
@ -6770,8 +6770,8 @@ version = "1.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 0.1.10",
"rand 0.8.5", "rand 0.7.3",
"static_assertions", "static_assertions",
] ]
@ -7562,49 +7562,6 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasi-cap-std-sync"
version = "17.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6e83bedd81dd3ef99a42589a8364dc1f6ac03363f10d67c2fc33ad878dd1bec"
dependencies = [
"anyhow",
"async-trait",
"cap-fs-ext",
"cap-rand",
"cap-std",
"cap-time-ext",
"fs-set-times",
"io-extras",
"io-lifetimes",
"once_cell",
"rustix",
"system-interface",
"tracing",
"wasi-common",
"windows-sys 0.52.0",
]
[[package]]
name = "wasi-common"
version = "17.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85972c7523e1ac970c576007ee02b69645c9b6a811276495d4c37908971ff9bb"
dependencies = [
"anyhow",
"bitflags 2.5.0",
"cap-rand",
"cap-std",
"io-extras",
"log",
"rustix",
"thiserror",
"tracing",
"wasmtime",
"wiggle",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.92" version = "0.2.92"
@ -7673,9 +7630,9 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
[[package]] [[package]]
name = "wasm-encoder" name = "wasm-encoder"
version = "0.38.1" version = "0.202.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" checksum = "bfd106365a7f5f7aa3c1916a98cbb3ad477f5ff96ddb130285a91c6e7429e67a"
dependencies = [ dependencies = [
"leb128", "leb128",
] ]
@ -7691,19 +7648,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmparser" name = "wasmparser"
version = "0.118.2" version = "0.202.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77f1154f1ab868e2a01d9834a805faca7bf8b50d041b4ca714d005d0dab1c50c" checksum = "d6998515d3cf3f8b980ef7c11b29a9b1017d4cf86b99ae93b546992df9931413"
dependencies = [
"indexmap",
"semver 1.0.23",
]
[[package]]
name = "wasmparser"
version = "0.121.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab"
dependencies = [ dependencies = [
"bitflags 2.5.0", "bitflags 2.5.0",
"indexmap", "indexmap",
@ -7712,20 +7659,21 @@ dependencies = [
[[package]] [[package]]
name = "wasmprinter" name = "wasmprinter"
version = "0.2.80" version = "0.202.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60e73986a6b7fdfedb7c5bf9e7eb71135486507c8fbc4c0c42cffcb6532988b7" checksum = "ab1cc9508685eef9502e787f4d4123745f5651a1e29aec047645d3cac1e2da7a"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"wasmparser 0.121.2", "wasmparser",
] ]
[[package]] [[package]]
name = "wasmtime" name = "wasmtime"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2788dbd0a2f9786cfae5590d2ca6103c82e0fd6ce0b192107e472bcf367ec180" checksum = "4af5cb32045daee8476711eb12b8b71275c2dd1fc7a58cc2a11b33ce9205f6a2"
dependencies = [ dependencies = [
"addr2line",
"anyhow", "anyhow",
"async-trait", "async-trait",
"bincode", "bincode",
@ -7733,27 +7681,33 @@ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"encoding_rs", "encoding_rs",
"fxprof-processed-profile", "fxprof-processed-profile",
"gimli",
"indexmap", "indexmap",
"ittapi",
"libc", "libc",
"log", "log",
"object", "object 0.33.0",
"once_cell", "once_cell",
"paste", "paste",
"rayon", "rayon",
"rustix",
"semver 1.0.23",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json", "serde_json",
"target-lexicon", "target-lexicon",
"wasm-encoder 0.38.1", "wasm-encoder 0.202.0",
"wasmparser 0.118.2", "wasmparser",
"wasmtime-cache", "wasmtime-cache",
"wasmtime-component-macro", "wasmtime-component-macro",
"wasmtime-component-util", "wasmtime-component-util",
"wasmtime-cranelift", "wasmtime-cranelift",
"wasmtime-environ", "wasmtime-environ",
"wasmtime-fiber", "wasmtime-fiber",
"wasmtime-jit", "wasmtime-jit-debug",
"wasmtime-jit-icache-coherence",
"wasmtime-runtime", "wasmtime-runtime",
"wasmtime-slab",
"wasmtime-winch", "wasmtime-winch",
"wat", "wat",
"windows-sys 0.52.0", "windows-sys 0.52.0",
@ -7761,18 +7715,18 @@ dependencies = [
[[package]] [[package]]
name = "wasmtime-asm-macros" name = "wasmtime-asm-macros"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ced200bb566dd3e3b044bafc837f978233a6f220f627e29605b4b35c222817fd" checksum = "7515c4d24c8b55c0feab67e3d52a42f999fda8b9cfafbd69a82ed6bcf299d26e"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
name = "wasmtime-cache" name = "wasmtime-cache"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e417dc4f46556daa33f47ddbe9f06048194f02d10d07f447cc371657ddfca10" checksum = "c3aa2de7189ea6b3270727d0027790494aec5e7101ca50da3f9549a86628cae4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.21.7", "base64 0.21.7",
@ -7783,16 +7737,16 @@ dependencies = [
"serde", "serde",
"serde_derive", "serde_derive",
"sha2", "sha2",
"toml 0.5.11", "toml 0.8.13",
"windows-sys 0.52.0", "windows-sys 0.52.0",
"zstd", "zstd",
] ]
[[package]] [[package]]
name = "wasmtime-component-macro" name = "wasmtime-component-macro"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b7f911378d94bfed1360d971f084aa73840d0ea26fc892ed4be0b7da278dc15" checksum = "794839a710a39a12677c67ff43fec54ef00d0ca6c6f631209a7c5524522221d3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"proc-macro2 1.0.82", "proc-macro2 1.0.82",
@ -7805,15 +7759,15 @@ dependencies = [
[[package]] [[package]]
name = "wasmtime-component-util" name = "wasmtime-component-util"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05ad8115f66c9f061c79e5d45a26288229749e013630aa32596750ef0f9e9807" checksum = "7839a1b9e15d17be1cb2a105f18be8e0bbf52bdec7a7cd6eb5d80d4c2cdf74f0"
[[package]] [[package]]
name = "wasmtime-cranelift" name = "wasmtime-cranelift"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac4bed315d4299d46db5217509f7a7d6e0313c8c8d06cf76cb4cf0a8ce0fa3ee" checksum = "57ec2d9a4b9990bea53a5dfd689d48663dbd19a46903eaf73e2022b3d1ef20d3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -7825,49 +7779,35 @@ dependencies = [
"cranelift-wasm", "cranelift-wasm",
"gimli", "gimli",
"log", "log",
"object", "object 0.33.0",
"target-lexicon", "target-lexicon",
"thiserror", "thiserror",
"wasmparser 0.118.2", "wasmparser",
"wasmtime-cranelift-shared",
"wasmtime-environ", "wasmtime-environ",
"wasmtime-versioned-export-macros", "wasmtime-versioned-export-macros",
] ]
[[package]]
name = "wasmtime-cranelift-shared"
version = "17.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "473a4abcf1df827f85e150b970c95e2c6c52f5b2fbb967b730eb1d52aac24dfb"
dependencies = [
"anyhow",
"cranelift-codegen",
"cranelift-control",
"cranelift-native",
"gimli",
"object",
"target-lexicon",
"wasmtime-environ",
]
[[package]] [[package]]
name = "wasmtime-environ" name = "wasmtime-environ"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7eacc3e408248e0eb4da5daa60a0948f91432124b494b887557fcafd04fe1f5c" checksum = "ad72e2e3f7ea5b50fedf66dd36ba24634e4f445c370644683b433d45d88f6126"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode",
"cpp_demangle",
"cranelift-entity", "cranelift-entity",
"gimli", "gimli",
"indexmap", "indexmap",
"log", "log",
"object", "object 0.33.0",
"rustc-demangle",
"serde", "serde",
"serde_derive", "serde_derive",
"target-lexicon", "target-lexicon",
"thiserror", "thiserror",
"wasm-encoder 0.38.1", "wasm-encoder 0.202.0",
"wasmparser 0.118.2", "wasmparser",
"wasmprinter", "wasmprinter",
"wasmtime-component-util", "wasmtime-component-util",
"wasmtime-types", "wasmtime-types",
@ -7875,9 +7815,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmtime-fiber" name = "wasmtime-fiber"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b29e67382b0895da410fa2f41cd3466d51d1a04f2b72e6f9a722e3e97d49f6bd" checksum = "4dbdf3053e7e7ced0cd4ed76579995b62169a1a43696890584eae2de2e33bf54"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cc", "cc",
@ -7888,40 +7828,13 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "wasmtime-jit"
version = "17.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167290150d5ed13918ca400bc7e0b9ebb915a1066fb61dd7c1d079e0b22b28c0"
dependencies = [
"addr2line",
"anyhow",
"bincode",
"cfg-if 1.0.0",
"cpp_demangle",
"gimli",
"ittapi",
"log",
"object",
"rustc-demangle",
"rustix",
"serde",
"serde_derive",
"target-lexicon",
"wasmtime-environ",
"wasmtime-jit-debug",
"wasmtime-jit-icache-coherence",
"wasmtime-runtime",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "wasmtime-jit-debug" name = "wasmtime-jit-debug"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "539750fca93bce6f2d5a42d6f22426b518ef7bc17b742d4d813dfe74cca85038" checksum = "983ca409f2cd66385ce49486c022da0128acb7910c055beb5230998b49c6084c"
dependencies = [ dependencies = [
"object", "object 0.33.0",
"once_cell", "once_cell",
"rustix", "rustix",
"wasmtime-versioned-export-macros", "wasmtime-versioned-export-macros",
@ -7929,9 +7842,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmtime-jit-icache-coherence" name = "wasmtime-jit-icache-coherence"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58b8bf27c96c254626746b8f1893819e19d0cd4182041377c783ae62e624d821" checksum = "ede45379f3b4d395d8947006de8043801806099a240a26db553919b68e96ab15"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"libc", "libc",
@ -7940,9 +7853,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmtime-runtime" name = "wasmtime-runtime"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6248d4e41dad5da93c3e7b88878ca98cae3a07397fe19adc23a9a506db007ed" checksum = "65019d29d175c567b84173f2adf3b7a3af6d5592f8fe510dccae55d2569ec0d2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cc", "cc",
@ -7951,41 +7864,47 @@ dependencies = [
"indexmap", "indexmap",
"libc", "libc",
"log", "log",
"mach", "mach2",
"memfd", "memfd",
"memoffset 0.9.1", "memoffset 0.9.1",
"paste", "paste",
"psm", "psm",
"rustix", "rustix",
"sptr", "sptr",
"wasm-encoder 0.38.1", "wasm-encoder 0.202.0",
"wasmtime-asm-macros", "wasmtime-asm-macros",
"wasmtime-environ", "wasmtime-environ",
"wasmtime-fiber", "wasmtime-fiber",
"wasmtime-jit-debug", "wasmtime-jit-debug",
"wasmtime-slab",
"wasmtime-versioned-export-macros", "wasmtime-versioned-export-macros",
"wasmtime-wmemcheck",
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
name = "wasmtime-types" name = "wasmtime-slab"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c47002670e3d0dbfab240a672b8f6890493a9f9a3cd19fa5006fd5e5ede3b0f6" checksum = "ca6585868f5c427c3e9d2a8c0c3354e6d7d4518a0d17723ab25a0c1eebf5d5b4"
[[package]]
name = "wasmtime-types"
version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84d5381ff174faded38c7b2085fbe430dff59489c87a91403354d710075750fb"
dependencies = [ dependencies = [
"cranelift-entity", "cranelift-entity",
"serde", "serde",
"serde_derive", "serde_derive",
"thiserror", "thiserror",
"wasmparser 0.118.2", "wasmparser",
] ]
[[package]] [[package]]
name = "wasmtime-versioned-export-macros" name = "wasmtime-versioned-export-macros"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e04682ce587aa8fa9311d3c95148381f08a1db274ad6bcd3553f7c97c8c2debb" checksum = "0d3b70422fdfa915c903f003b8b42554a8ae1aa0c6208429d8314ebf5721f3ac"
dependencies = [ dependencies = [
"proc-macro2 1.0.82", "proc-macro2 1.0.82",
"quote 1.0.36", "quote 1.0.36",
@ -7994,9 +7913,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmtime-wasi" name = "wasmtime-wasi"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f06353b0c0cbe4f94fbf200e782729b5ae383dd7a112e25d516d535e8dd96ab" checksum = "08dd00241969c3be8c5dfdedbb8d9c5af6783e514ffbf8f7522036561bd1337a"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -8011,8 +7930,6 @@ dependencies = [
"futures", "futures",
"io-extras", "io-extras",
"io-lifetimes", "io-lifetimes",
"libc",
"log",
"once_cell", "once_cell",
"rustix", "rustix",
"system-interface", "system-interface",
@ -8020,8 +7937,6 @@ dependencies = [
"tokio", "tokio",
"tracing", "tracing",
"url", "url",
"wasi-cap-std-sync",
"wasi-common",
"wasmtime", "wasmtime",
"wiggle", "wiggle",
"windows-sys 0.52.0", "windows-sys 0.52.0",
@ -8029,26 +7944,26 @@ dependencies = [
[[package]] [[package]]
name = "wasmtime-winch" name = "wasmtime-winch"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d752d7e08654b106f299e1900fe9ef9fa400138d1e1c7adf848b8fb4f31c5466" checksum = "996360967b5196dec20ddcfce499ce4dc80cc925c088b0f2b376d29b96833a6a"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cranelift-codegen", "cranelift-codegen",
"gimli", "gimli",
"object", "object 0.33.0",
"target-lexicon", "target-lexicon",
"wasmparser 0.118.2", "wasmparser",
"wasmtime-cranelift-shared", "wasmtime-cranelift",
"wasmtime-environ", "wasmtime-environ",
"winch-codegen", "winch-codegen",
] ]
[[package]] [[package]]
name = "wasmtime-wit-bindgen" name = "wasmtime-wit-bindgen"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af5fbb1adaadad70271fe18a3f938741edb2b5178bf2fc164ab20544018626b8" checksum = "01840c0cfbbb01664c796e3f4edbd656e58f9d76db083c7e7c6bba59ea657a96"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"heck 0.4.1", "heck 0.4.1",
@ -8056,12 +7971,6 @@ dependencies = [
"wit-parser", "wit-parser",
] ]
[[package]]
name = "wasmtime-wmemcheck"
version = "17.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8425f923a58d18de2912d569c59bfa94bbd789074a459d018c62531d5111037c"
[[package]] [[package]]
name = "wast" name = "wast"
version = "35.0.2" version = "35.0.2"
@ -8423,9 +8332,9 @@ checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311"
[[package]] [[package]]
name = "wiggle" name = "wiggle"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc07496af9cb4377dabd78ead77564302c8c34c0a75dcd11b02f0ebe11c5fa10" checksum = "f93fc3510978a905f931d74784ed8685bd6453e18ad8f92809e793d48827e3cd"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -8438,9 +8347,9 @@ dependencies = [
[[package]] [[package]]
name = "wiggle-generate" name = "wiggle-generate"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1132a122e3d4c77046c7b92d46150e5ee450f29b37a76d3c586e791d15f6c54e" checksum = "4ec3909e70f36066526ad3b2abb4855ab836f8a6b293449582563ac50d651083"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"heck 0.4.1", "heck 0.4.1",
@ -8453,9 +8362,9 @@ dependencies = [
[[package]] [[package]]
name = "wiggle-macro" name = "wiggle-macro"
version = "17.0.3" version = "20.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a781d29bfd788595f4a392a6f606699e59577b7f4b2858da2ae4068f4d757c8" checksum = "b4c31124572ab16401c491c0d4fb5fe5d17dab65fcfcc56d7d8efb1c1e56a3db"
dependencies = [ dependencies = [
"proc-macro2 1.0.82", "proc-macro2 1.0.82",
"quote 1.0.36", "quote 1.0.36",
@ -8505,9 +8414,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "winch-codegen" name = "winch-codegen"
version = "0.15.3" version = "0.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1744366f80ea8121569f5e9c403beaebabcbfc089a6a3634c048019f8ef425f0" checksum = "cefeb84a0f39227cf2eb665cf348e6150ebf3372d08adff03264064ab590fdf4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cranelift-codegen", "cranelift-codegen",
@ -8515,7 +8424,8 @@ dependencies = [
"regalloc2", "regalloc2",
"smallvec", "smallvec",
"target-lexicon", "target-lexicon",
"wasmparser 0.118.2", "wasmparser",
"wasmtime-cranelift",
"wasmtime-environ", "wasmtime-environ",
] ]
@ -8571,15 +8481,6 @@ dependencies = [
"windows-targets 0.48.5", "windows-targets 0.48.5",
] ]
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets 0.52.5",
]
[[package]] [[package]]
name = "windows-core" name = "windows-core"
version = "0.54.0" version = "0.54.0"
@ -8899,9 +8800,9 @@ dependencies = [
[[package]] [[package]]
name = "wit-parser" name = "wit-parser"
version = "0.13.2" version = "0.202.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "316b36a9f0005f5aa4b03c39bc3728d045df136f8c13a73b7db4510dec725e08" checksum = "744237b488352f4f27bca05a10acb79474415951c450e52ebd0da784c1df2bcc"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"id-arena", "id-arena",
@ -8912,6 +8813,7 @@ dependencies = [
"serde_derive", "serde_derive",
"serde_json", "serde_json",
"unicode-xid 0.2.4", "unicode-xid 0.2.4",
"wasmparser",
] ]
[[package]] [[package]]
@ -9095,20 +8997,19 @@ dependencies = [
[[package]] [[package]]
name = "zstd" name = "zstd"
version = "0.11.2+zstd.1.5.2" version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a"
dependencies = [ dependencies = [
"zstd-safe", "zstd-safe",
] ]
[[package]] [[package]]
name = "zstd-safe" name = "zstd-safe"
version = "5.0.2+zstd.1.5.2" version = "7.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a"
dependencies = [ dependencies = [
"libc",
"zstd-sys", "zstd-sys",
] ]

View File

@ -35,8 +35,8 @@ toml = { version = "0.8", optional = true }
tar = { version = "0.4.37", optional = true } tar = { version = "0.4.37", optional = true }
bincode = { workspace = true, optional = true } bincode = { workspace = true, optional = true }
timer-queue = "0.1.0" timer-queue = "0.1.0"
wasmtime = { version = "17.0.0", optional = true , features = ["component-model", "async"] } wasmtime = { version = "20.0.2", optional = true , features = ["component-model", "async"] }
wasmtime-wasi = { version = "17.0.0", optional = true } wasmtime-wasi = { version = "20.0.2", optional = true }
async-trait = { workspace = true } async-trait = { workspace = true }
bytes = "^1" bytes = "^1"
futures = "0.3.30" futures = "0.3.30"

View File

@ -1,4 +1,4 @@
use std::sync::Arc; use std::sync::{Arc, Mutex};
use super::{ use super::{
errors::{EcsAccessError, PluginModuleError}, errors::{EcsAccessError, PluginModuleError},
@ -10,7 +10,7 @@ use wasmtime::{
component::{Component, Linker}, component::{Component, Linker},
Config, Engine, Store, Config, Engine, Store,
}; };
use wasmtime_wasi::preview2::WasiView; use wasmtime_wasi::WasiView;
wasmtime::component::bindgen!({ wasmtime::component::bindgen!({
path: "../../plugin/wit/veloren.wit", path: "../../plugin/wit/veloren.wit",
@ -30,26 +30,22 @@ use veloren::plugin::{actions, information, types};
pub struct PluginModule { pub struct PluginModule {
ecs: Arc<EcsAccessManager>, ecs: Arc<EcsAccessManager>,
plugin: Plugin, plugin: Plugin,
store: wasmtime::Store<WasiHostCtx>, store: Mutex<wasmtime::Store<WasiHostCtx>>,
#[allow(dead_code)] #[allow(dead_code)]
name: String, name: String,
} }
struct WasiHostCtx { struct WasiHostCtx {
preview2_ctx: wasmtime_wasi::preview2::WasiCtx, preview2_ctx: wasmtime_wasi::WasiCtx,
preview2_table: wasmtime::component::ResourceTable, preview2_table: wasmtime::component::ResourceTable,
ecs: Arc<EcsAccessManager>, ecs: Arc<EcsAccessManager>,
registered_commands: HashSet<String>, registered_commands: HashSet<String>,
} }
impl wasmtime_wasi::preview2::WasiView for WasiHostCtx { impl wasmtime_wasi::WasiView for WasiHostCtx {
fn table(&self) -> &wasmtime::component::ResourceTable { &self.preview2_table } fn table(&mut self) -> &mut wasmtime::component::ResourceTable { &mut self.preview2_table }
fn ctx(&self) -> &wasmtime_wasi::preview2::WasiCtx { &self.preview2_ctx } fn ctx(&mut self) -> &mut wasmtime_wasi::WasiCtx { &mut self.preview2_ctx }
fn table_mut(&mut self) -> &mut wasmtime::component::ResourceTable { &mut self.preview2_table }
fn ctx_mut(&mut self) -> &mut wasmtime_wasi::preview2::WasiCtx { &mut self.preview2_ctx }
} }
impl information::Host for WasiHostCtx {} impl information::Host for WasiHostCtx {}
@ -80,7 +76,7 @@ impl information::HostEntity for WasiHostCtx {
&mut self, &mut self,
uid: actions::Uid, uid: actions::Uid,
) -> wasmtime::Result<Result<wasmtime::component::Resource<information::Entity>, ()>> { ) -> wasmtime::Result<Result<wasmtime::component::Resource<information::Entity>, ()>> {
let entry = self.table_mut().push(Entity { let entry = self.table().push(Entity {
uid: common::uid::Uid(uid), uid: common::uid::Uid(uid),
})?; })?;
Ok(Ok(entry)) Ok(Ok(entry))
@ -139,50 +135,50 @@ impl information::HostEntity for WasiHostCtx {
&mut self, &mut self,
rep: wasmtime::component::Resource<information::Entity>, rep: wasmtime::component::Resource<information::Entity>,
) -> wasmtime::Result<()> { ) -> wasmtime::Result<()> {
Ok(self.table_mut().delete(rep).map(|_entity| ())?) Ok(self.table().delete(rep).map(|_entity| ())?)
} }
} }
struct InfoStream(String); struct InfoStream(String);
impl wasmtime_wasi::preview2::HostOutputStream for InfoStream { impl wasmtime_wasi::HostOutputStream for InfoStream {
fn write(&mut self, bytes: bytes::Bytes) -> wasmtime_wasi::preview2::StreamResult<()> { fn write(&mut self, bytes: bytes::Bytes) -> wasmtime_wasi::StreamResult<()> {
tracing::info!("{}: {}", self.0, String::from_utf8_lossy(bytes.as_ref())); tracing::info!("{}: {}", self.0, String::from_utf8_lossy(bytes.as_ref()));
Ok(()) Ok(())
} }
fn flush(&mut self) -> wasmtime_wasi::preview2::StreamResult<()> { Ok(()) } fn flush(&mut self) -> wasmtime_wasi::StreamResult<()> { Ok(()) }
fn check_write(&mut self) -> wasmtime_wasi::preview2::StreamResult<usize> { Ok(1024) } fn check_write(&mut self) -> wasmtime_wasi::StreamResult<usize> { Ok(1024) }
} }
#[async_trait::async_trait] #[async_trait::async_trait]
impl wasmtime_wasi::preview2::Subscribe for InfoStream { impl wasmtime_wasi::Subscribe for InfoStream {
async fn ready(&mut self) {} async fn ready(&mut self) {}
} }
struct ErrorStream(String); struct ErrorStream(String);
impl wasmtime_wasi::preview2::HostOutputStream for ErrorStream { impl wasmtime_wasi::HostOutputStream for ErrorStream {
fn write(&mut self, bytes: bytes::Bytes) -> wasmtime_wasi::preview2::StreamResult<()> { fn write(&mut self, bytes: bytes::Bytes) -> wasmtime_wasi::StreamResult<()> {
tracing::error!("{}: {}", self.0, String::from_utf8_lossy(bytes.as_ref())); tracing::error!("{}: {}", self.0, String::from_utf8_lossy(bytes.as_ref()));
Ok(()) Ok(())
} }
fn flush(&mut self) -> wasmtime_wasi::preview2::StreamResult<()> { Ok(()) } fn flush(&mut self) -> wasmtime_wasi::StreamResult<()> { Ok(()) }
fn check_write(&mut self) -> wasmtime_wasi::preview2::StreamResult<usize> { Ok(1024) } fn check_write(&mut self) -> wasmtime_wasi::StreamResult<usize> { Ok(1024) }
} }
#[async_trait::async_trait] #[async_trait::async_trait]
impl wasmtime_wasi::preview2::Subscribe for ErrorStream { impl wasmtime_wasi::Subscribe for ErrorStream {
async fn ready(&mut self) {} async fn ready(&mut self) {}
} }
struct LogStream(String, tracing::Level); struct LogStream(String, tracing::Level);
impl wasmtime_wasi::preview2::StdoutStream for LogStream { impl wasmtime_wasi::StdoutStream for LogStream {
fn stream(&self) -> Box<dyn wasmtime_wasi::preview2::HostOutputStream> { fn stream(&self) -> Box<dyn wasmtime_wasi::HostOutputStream> {
if self.1 == tracing::Level::INFO { if self.1 == tracing::Level::INFO {
Box::new(InfoStream(self.0.clone())) Box::new(InfoStream(self.0.clone()))
} else { } else {
@ -204,13 +200,13 @@ impl PluginModule {
let engine = Engine::new(&config).map_err(PluginModuleError::Wasmtime)?; let engine = Engine::new(&config).map_err(PluginModuleError::Wasmtime)?;
// create a WASI environment (std implementing system calls) // create a WASI environment (std implementing system calls)
let wasi = wasmtime_wasi::preview2::WasiCtxBuilder::new() let wasi = wasmtime_wasi::WasiCtxBuilder::new()
.stdout(LogStream(name.clone(), tracing::Level::INFO)) .stdout(LogStream(name.clone(), tracing::Level::INFO))
.stderr(LogStream(name.clone(), tracing::Level::ERROR)) .stderr(LogStream(name.clone(), tracing::Level::ERROR))
.build(); .build();
let host_ctx = WasiHostCtx { let host_ctx = WasiHostCtx {
preview2_ctx: wasi, preview2_ctx: wasi,
preview2_table: wasmtime_wasi::preview2::ResourceTable::new(), preview2_table: wasmtime_wasi::ResourceTable::new(),
ecs: Arc::clone(&ecs), ecs: Arc::clone(&ecs),
registered_commands: HashSet::new(), registered_commands: HashSet::new(),
}; };
@ -223,7 +219,7 @@ impl PluginModule {
// register WASI and Veloren methods with the runtime // register WASI and Veloren methods with the runtime
let mut linker = Linker::new(&engine); let mut linker = Linker::new(&engine);
wasmtime_wasi::preview2::command::add_to_linker(&mut linker) wasmtime_wasi::bindings::Command::add_to_linker(&mut linker, |x| x)
.map_err(PluginModuleError::Wasmtime)?; .map_err(PluginModuleError::Wasmtime)?;
Plugin::add_to_linker(&mut linker, |x| x).map_err(PluginModuleError::Wasmtime)?; Plugin::add_to_linker(&mut linker, |x| x).map_err(PluginModuleError::Wasmtime)?;
@ -234,7 +230,7 @@ impl PluginModule {
Ok(Self { Ok(Self {
plugin, plugin,
ecs, ecs,
store, store: store.into(),
name, name,
}) })
} }
@ -257,7 +253,7 @@ impl PluginModule {
let future = self let future = self
.plugin .plugin
.veloren_plugin_events() .veloren_plugin_events()
.call_load(&mut self.store, mode); .call_load(self.store.get_mut().unwrap(), mode);
futures::executor::block_on(future) futures::executor::block_on(future)
}) })
.map_err(PluginModuleError::Wasmtime) .map_err(PluginModuleError::Wasmtime)
@ -270,12 +266,19 @@ impl PluginModule {
args: &[String], args: &[String],
player: common::uid::Uid, player: common::uid::Uid,
) -> Result<Vec<String>, CommandResults> { ) -> Result<Vec<String>, CommandResults> {
if !self.store.data().registered_commands.contains(name) { if !self
.store
.get_mut()
.unwrap()
.data()
.registered_commands
.contains(name)
{
return Err(CommandResults::UnknownCommand); return Err(CommandResults::UnknownCommand);
} }
self.ecs.execute_with(ecs, || { self.ecs.execute_with(ecs, || {
let future = self.plugin.veloren_plugin_events().call_command( let future = self.plugin.veloren_plugin_events().call_command(
&mut self.store, self.store.get_mut().unwrap(),
name, name,
args, args,
player.0, player.0,
@ -295,7 +298,7 @@ impl PluginModule {
) -> types::JoinResult { ) -> types::JoinResult {
self.ecs.execute_with(ecs, || { self.ecs.execute_with(ecs, || {
let future = self.plugin.veloren_plugin_events().call_join( let future = self.plugin.veloren_plugin_events().call_join(
&mut self.store, self.store.get_mut().unwrap(),
name, name,
uuid.as_u64_pair(), uuid.as_u64_pair(),
); );