diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 478b8373f1..5df5de54c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -450,8 +450,6 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust Stable uses: dtolnay/rust-toolchain@stable - - name: install wasm target - run: rustup target add wasm32-unknown-unknown - name: Build Regex SmartModule run: make -C smartmodule/regex-filter diff --git a/crates/cargo-builder/src/package.rs b/crates/cargo-builder/src/package.rs index 307958e640..0a3018c9f7 100644 --- a/crates/cargo-builder/src/package.rs +++ b/crates/cargo-builder/src/package.rs @@ -121,7 +121,7 @@ impl PackageInfo { Ok(path) } - /// path to package's wasm32 target + /// path to package's wasm32-wasi target pub fn target_wasm32_wasi_path(&self) -> anyhow::Result { let mut path = self.target_dir.clone(); path.push("wasm32-wasi"); diff --git a/crates/smartmodule-development-kit/src/build.rs b/crates/smartmodule-development-kit/src/build.rs index 19328ac657..6f248818cd 100644 --- a/crates/smartmodule-development-kit/src/build.rs +++ b/crates/smartmodule-development-kit/src/build.rs @@ -8,7 +8,7 @@ use cargo_builder::package::PackageInfo; use cargo_builder::cargo::Cargo; use crate::cmd::PackageCmd; -use crate::ENV_SMDK_WASI; +use crate::ENV_SMDK_NOWASI; pub(crate) const BUILD_TARGET: &str = "wasm32-unknown-unknown"; pub(crate) const BUILD_TARGET_WASI: &str = "wasm32-wasi"; @@ -23,9 +23,9 @@ pub struct BuildCmd { #[arg(raw = true)] extra_arguments: Vec, - /// Build wasi target - #[arg(long, env = ENV_SMDK_WASI)] - wasi: bool, + /// Build a non wasi target (only use if needed for backward compatiblity) + #[arg(long, env = ENV_SMDK_NOWASI, hide_short_help = true)] + nowasi: bool, } impl BuildCmd { @@ -33,10 +33,10 @@ impl BuildCmd { let opt = self.package.as_opt(); let p = PackageInfo::from_options(&opt)?; - let build_target = if self.wasi { - BUILD_TARGET_WASI - } else { + let build_target = if self.nowasi { BUILD_TARGET + } else { + BUILD_TARGET_WASI }; let cargo = Cargo::build() .profile(opt.release) diff --git a/crates/smartmodule-development-kit/src/load.rs b/crates/smartmodule-development-kit/src/load.rs index 81e6645298..004b81fbfa 100644 --- a/crates/smartmodule-development-kit/src/load.rs +++ b/crates/smartmodule-development-kit/src/load.rs @@ -10,7 +10,7 @@ use fluvio_future::task::run_block_on; use cargo_builder::package::PackageInfo; use crate::cmd::PackageCmd; -use crate::ENV_SMDK_WASI; +use crate::ENV_SMDK_NOWASI; pub const DEFAULT_META_LOCATION: &str = "SmartModule.toml"; @@ -40,8 +40,8 @@ pub struct LoadCmd { dry_run: bool, /// Build wasi target - #[arg(long, env = ENV_SMDK_WASI)] - wasi: bool, + #[arg(long, env = ENV_SMDK_NOWASI, hide_short_help = true)] + nowasi: bool, } impl LoadCmd { pub(crate) fn process(self) -> Result<()> { @@ -70,10 +70,10 @@ impl LoadCmd { let raw_bytes = match &self.wasm_file { Some(wasm_file) => crate::read_bytes_from_path(wasm_file)?, None => { - let tgtpath = if self.wasi { - package_info.target_wasm32_wasi_path()? - } else { + let tgtpath = if self.nowasi { package_info.target_wasm32_path()? + } else { + package_info.target_wasm32_wasi_path()? }; crate::read_bytes_from_path(&tgtpath)? } diff --git a/crates/smartmodule-development-kit/src/main.rs b/crates/smartmodule-development-kit/src/main.rs index 3e765f049b..e2ca13a599 100644 --- a/crates/smartmodule-development-kit/src/main.rs +++ b/crates/smartmodule-development-kit/src/main.rs @@ -15,7 +15,7 @@ use tracing::debug; use cmd::SmdkCommand; -pub const ENV_SMDK_WASI: &str = "SMDK_WASI"; +pub const ENV_SMDK_NOWASI: &str = "SMDK_NOWASI"; fn main() -> Result<()> { fluvio_future::subscriber::init_tracer(None); diff --git a/crates/smartmodule-development-kit/src/publish.rs b/crates/smartmodule-development-kit/src/publish.rs index 1b6609d901..a52e1a00b4 100644 --- a/crates/smartmodule-development-kit/src/publish.rs +++ b/crates/smartmodule-development-kit/src/publish.rs @@ -14,7 +14,7 @@ use hubutil::{ use tracing::debug; use crate::cmd::PackageCmd; -use crate::ENV_SMDK_WASI; +use crate::ENV_SMDK_NOWASI; pub const SMARTMODULE_TOML: &str = "SmartModule.toml"; @@ -45,8 +45,8 @@ pub struct PublishCmd { #[arg(long, hide_short_help = true)] remote: Option, - #[arg(long, env=ENV_SMDK_WASI)] - wasi: bool, + #[arg(long, env=ENV_SMDK_NOWASI, hide_short_help = true)] + nowasi: bool, } impl PublishCmd { @@ -101,7 +101,7 @@ impl PublishCmd { Self::cleanup(&hubdir)?; - init_package_template(&package_info, self.wasi)?; + init_package_template(&package_info, self.nowasi)?; check_package_meta_visiblity(&package_info)?; Ok(hubdir) @@ -170,7 +170,7 @@ pub fn package_push(opts: &PublishCmd, pkgpath: &str, access: &HubAccess) -> Res Ok(()) } -pub fn init_package_template(package_info: &PackageInfo, wasi: bool) -> Result<()> { +pub fn init_package_template(package_info: &PackageInfo, nowasi: bool) -> Result<()> { let sm_toml_path = find_smartmodule_toml(package_info)?; let sm_metadata = SmartModuleMetadata::from_toml(&sm_toml_path)?; @@ -202,10 +202,10 @@ pub fn init_package_template(package_info: &PackageInfo, wasi: bool) -> Result<( })?, ); - let wasmpath = if wasi { - package_info.target_wasm32_wasi_path()? - } else { + let wasmpath = if nowasi { package_info.target_wasm32_path()? + } else { + package_info.target_wasm32_wasi_path()? }; pm.manifest.push( package_meta_relative_path(&package_meta_path, &wasmpath).ok_or_else(|| { diff --git a/crates/smartmodule-development-kit/src/test.rs b/crates/smartmodule-development-kit/src/test.rs index 7d97cc75cc..1d92e5b13c 100644 --- a/crates/smartmodule-development-kit/src/test.rs +++ b/crates/smartmodule-development-kit/src/test.rs @@ -7,7 +7,7 @@ use clap::Parser; use fluvio_future::task::run_block_on; use fluvio_smartengine::{SmartModuleChainBuilder, SmartModuleConfig, Lookback}; use crate::cmd::PackageCmd; -use crate::ENV_SMDK_WASI; +use crate::ENV_SMDK_NOWASI; use fluvio_cli_common::smartmodule::{BaseTestCmd, WithChainBuilder}; #[derive(Debug, Parser)] @@ -19,8 +19,8 @@ pub struct TestCmd { package: PackageCmd, #[arg(long, group = "TestSmartModule")] wasm_file: Option, - #[arg(long, env=ENV_SMDK_WASI)] - wasi: bool, + #[arg(long, env=ENV_SMDK_NOWASI, hide_short_help = true)] + nowasi: bool, } impl TestCmd { @@ -35,10 +35,10 @@ impl TestCmd { wasm_file } else { let package_info = PackageInfo::from_options(&self.package.as_opt())?; - if self.wasi { - package_info.target_wasm32_wasi_path()? - } else { + if self.nowasi { package_info.target_wasm32_path()? + } else { + package_info.target_wasm32_wasi_path()? } }; build_chain_ad_hoc(crate::read_bytes_from_path(&wasm_file)?, params, lookback) diff --git a/dev-tools/smartmodule.Dockerfile b/dev-tools/smartmodule.Dockerfile index 02cffafa18..ddd96922bd 100644 --- a/dev-tools/smartmodule.Dockerfile +++ b/dev-tools/smartmodule.Dockerfile @@ -48,6 +48,7 @@ RUN curl -fsS https://hub.infinyon.cloud/install/install.sh?ctx=ci | bash # add Fluvio smartmodule deps # source cargo/env is a little bit of a workaround RUN source "$HOME/.cargo/env" && rustup target install wasm32-unknown-unknown +RUN source "$HOME/.cargo/env" && rustup target install wasm32-wasi RUN source "$HOME/.cargo/env" && cargo install cargo-generate # create example-sm dir with a template project in it diff --git a/smartmodule/cargo_template/README.md b/smartmodule/cargo_template/README.md index 9d4b207bfd..d3b16acb62 100644 --- a/smartmodule/cargo_template/README.md +++ b/smartmodule/cargo_template/README.md @@ -8,8 +8,8 @@ $ cargo install cargo-generate $ cargo generate --git https://github.com/infinyon/fluvio-smartmodule-template ``` -> **Note**: To compile a SmartModule, you will need to install the `wasm32-unknown-unknown` -> target by running `rustup target add wasm32-unknown-unknown`. +> **Note**: To compile a SmartModule, you will need to install the `wasm32-wasi` +> target by running `rustup target add wasm32-wasi`, or `rustup target add wasm32-unknown-unknown` if using the --nowasi flags ## About SmartModules diff --git a/smartmodule/cargo_template/rust-toolchain.toml b/smartmodule/cargo_template/rust-toolchain.toml index e918eb3dbf..688bd594c6 100644 --- a/smartmodule/cargo_template/rust-toolchain.toml +++ b/smartmodule/cargo_template/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] channel = "stable" -targets = ["wasm32-unknown-unknown"] +targets = ["wasm32-unknown-unknown", "wasm32-wasi"] diff --git a/smartmodule/examples/Cargo.lock b/smartmodule/examples/Cargo.lock index 91e013e98d..bbfb8c1ec3 100644 --- a/smartmodule/examples/Cargo.lock +++ b/smartmodule/examples/Cargo.lock @@ -198,7 +198,7 @@ dependencies = [ [[package]] name = "fluvio-protocol" -version = "0.10.11" +version = "0.10.13" dependencies = [ "bytes", "content_inspector", @@ -252,7 +252,7 @@ name = "fluvio-smartmodule" version = "0.7.3" dependencies = [ "eyre", - "fluvio-protocol 0.10.11", + "fluvio-protocol 0.10.13", "fluvio-smartmodule-derive 0.6.2", "thiserror", "tracing", diff --git a/smartmodule/examples/Makefile b/smartmodule/examples/Makefile index b1d7b734ba..5a8a2b60f4 100644 --- a/smartmodule/examples/Makefile +++ b/smartmodule/examples/Makefile @@ -2,6 +2,7 @@ default: build build: rustup target add wasm32-unknown-unknown + rustup target add wasm32-wasi cargo build --release clean: diff --git a/smartmodule/regex-filter/Cargo.lock b/smartmodule/regex-filter/Cargo.lock index 8ec5e267e9..d048b40ca3 100644 --- a/smartmodule/regex-filter/Cargo.lock +++ b/smartmodule/regex-filter/Cargo.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "aho-corasick" version = "0.7.19" @@ -48,13 +42,10 @@ dependencies = [ ] [[package]] -name = "crc32fast" -version = "1.3.2" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "eyre" @@ -66,31 +57,17 @@ dependencies = [ "once_cell", ] -[[package]] -name = "flate2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - [[package]] name = "fluvio-compression" -version = "0.2.1" +version = "0.3.2" dependencies = [ - "bytes", - "flate2", - "lz4_flex", "serde", - "snap", "thiserror", ] [[package]] name = "fluvio-protocol" -version = "0.8.1" +version = "0.10.13" dependencies = [ "bytes", "content_inspector", @@ -108,17 +85,17 @@ dependencies = [ [[package]] name = "fluvio-protocol-derive" -version = "0.4.4" +version = "0.5.4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.101", "tracing", ] [[package]] name = "fluvio-smartmodule" -version = "0.3.1" +version = "0.7.3" dependencies = [ "eyre", "fluvio-protocol", @@ -129,18 +106,20 @@ dependencies = [ [[package]] name = "fluvio-smartmodule-derive" -version = "0.3.0" +version = "0.6.2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] [[package]] name = "fluvio-types" -version = "0.4.0" +version = "0.4.6" dependencies = [ + "serde", "thiserror", + "toml", "tracing", ] @@ -154,6 +133,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "indenter" version = "0.3.3" @@ -161,21 +146,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] -name = "log" -version = "0.4.17" +name = "indexmap" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ - "cfg-if", + "equivalent", + "hashbrown", ] [[package]] -name = "lz4_flex" -version = "0.9.5" +name = "log" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a8cbbb2831780bc3b9c15a41f5b49222ef756b6730a95f3decfdd15903eb5a3" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "twox-hash", + "cfg-if", ] [[package]] @@ -184,15 +170,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "miniz_oxide" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" -dependencies = [ - "adler", -] - [[package]] name = "once_cell" version = "1.15.0" @@ -207,18 +184,18 @@ checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "proc-macro2" -version = "1.0.46" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -239,7 +216,6 @@ name = "regex-filter" version = "0.0.0" dependencies = [ "fluvio-smartmodule", - "once_cell", "regex", ] @@ -281,26 +257,34 @@ checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.101", ] [[package]] -name = "snap" -version = "1.0.5" +name = "serde_spanned" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45456094d1983e2ee2a18fdfebce3189fa451699d0502cb8e3b49dba5ba41451" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] [[package]] -name = "static_assertions" -version = "1.1.0" +name = "syn" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] [[package]] name = "syn" -version = "1.0.101" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -324,7 +308,42 @@ checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.101", +] + +[[package]] +name = "toml" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", ] [[package]] @@ -347,7 +366,7 @@ checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.101", ] [[package]] @@ -359,18 +378,17 @@ dependencies = [ "once_cell", ] -[[package]] -name = "twox-hash" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" -dependencies = [ - "cfg-if", - "static_assertions", -] - [[package]] name = "unicode-ident" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" + +[[package]] +name = "winnow" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" +dependencies = [ + "memchr", +]