diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be8ae0880ca..d5ccfb5ffb7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -213,9 +213,6 @@ jobs: # shell: bash # run: | # make build-wasmer-wasm - - name: Build Wapm binary - run: | - make build-wapm - name: Install Nightly Rust for Headless uses: dtolnay/rust-toolchain@nightly with: diff --git a/.github/workflows/cloudcompiler.yaml b/.github/workflows/cloudcompiler.yaml index 4bd3f1f5c43..46744f53b8b 100644 --- a/.github/workflows/cloudcompiler.yaml +++ b/.github/workflows/cloudcompiler.yaml @@ -35,7 +35,7 @@ jobs: make build-wasmer-wasm && mkdir target/wasm32-wasi/release/cloudcompiler cp target/wasm32-wasi/release/wasmer-compiler.wasm target/wasm32-wasi/release/cloudcompiler/cloudcompiler.wasm && - cat << EOF > target/wasm32-wasi/release/cloudcompiler/wapm.toml + cat << EOF > target/wasm32-wasi/release/cloudcompiler/wasmer.toml [package] name = "${{ secrets.WAPM_DEV_USERNAME }}/cloudcompiler" version = "0.1.0" @@ -55,17 +55,17 @@ jobs: name = "cloudcompiler" module = "cloudcompiler" EOF - - name: Fix wapm.toml version + - name: Fix wasmer.toml version run: | echo $(git tag | tail -n1) > ./version.txt v=$(git describe --tags --abbrev=0) && \ echo "version = ${v}" && - sed -i "s/version = \".*\"/version = \"${v}\"/g" target/wasm32-wasi/release/cloudcompiler/wapm.toml \ + sed -i "s/version = \".*\"/version = \"${v}\"/g" target/wasm32-wasi/release/cloudcompiler/wasmer.toml \ - name: Build cloudcompiler.wasm shell: bash run: | git tag && - cat target/wasm32-wasi/release/cloudcompiler/wapm.toml && + cat target/wasm32-wasi/release/cloudcompiler/wasmer.toml && echo "ls" && ls target/wasm32-wasi/release/cloudcompiler - name: Publish to WAPM diff --git a/.gitignore b/.gitignore index 24affcea4df..ad4731344ed 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,8 @@ api-docs-repo/ /src/windows-installer/WasmerInstaller.exe /lib/c-api/wasmer.h .xwin-cache +wapm.toml +wasmer.toml # Generated by tests on Android /avd /core diff --git a/Cargo.lock b/Cargo.lock index 068b0c26887..59accbaca8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,6 +73,12 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "arrayvec" version = "0.7.2" @@ -176,7 +182,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", - "arrayvec", + "arrayvec 0.7.2", "cc", "cfg-if 1.0.0", "constant_time_eq", @@ -264,6 +270,38 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70" +[[package]] +name = "camino" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982a0cf6a99c350d7246035613882e376d58cebe571785abc5da4f648d53ac0a" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.14", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cast" version = "0.3.0" @@ -324,6 +362,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "cipher" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e" +dependencies = [ + "crypto-common", + "inout", +] + [[package]] name = "clap" version = "2.34.0" @@ -1055,6 +1103,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + [[package]] name = "fastrand" version = "1.8.0" @@ -1431,6 +1485,15 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashlink" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" +dependencies = [ + "hashbrown 0.12.3", +] + [[package]] name = "heck" version = "0.3.3" @@ -1461,6 +1524,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + [[package]] name = "http" version = "0.2.8" @@ -1612,6 +1684,18 @@ dependencies = [ "serde", ] +[[package]] +name = "indicatif" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4295cbb7573c16d310e99e713cf9e75101eb190ab31fccd35f2d2691b4352b19" +dependencies = [ + "console", + "number_prefix", + "portable-atomic", + "unicode-width", +] + [[package]] name = "inkwell" version = "0.1.0-beta.4" @@ -1666,6 +1750,15 @@ dependencies = [ "rustc_version 0.3.3", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + [[package]] name = "instant" version = "0.1.12" @@ -1757,6 +1850,19 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" +[[package]] +name = "lexical-core" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" +dependencies = [ + "arrayvec 0.5.2", + "bitflags", + "cfg-if 1.0.0", + "ryu", + "static_assertions", +] + [[package]] name = "lexical-sort" version = "0.3.1" @@ -1794,19 +1900,24 @@ dependencies = [ ] [[package]] -name = "link-cplusplus" -version = "1.0.7" +name = "libsqlite3-sys" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +checksum = "29f835d03d717946d28b1d1ed632eb6f0e24a299388ee623d0c23118d3e8a7fa" dependencies = [ "cc", + "pkg-config", + "vcpkg", ] [[package]] -name = "linked-hash-map" -version = "0.5.6" +name = "link-cplusplus" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] [[package]] name = "llvm-sys" @@ -1971,6 +2082,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "minisign" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce49953dd06a44e1034590bb619bfe8900c29500053c0c0f83e9260a34466aa5" +dependencies = [ + "getrandom", + "rpassword", + "scrypt", +] + [[package]] name = "miniz_oxide" version = "0.5.4" @@ -2042,6 +2164,17 @@ dependencies = [ "pin-utils", ] +[[package]] +name = "nom" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +dependencies = [ + "lexical-core", + "memchr", + "version_check", +] + [[package]] name = "nom" version = "7.1.1" @@ -2093,6 +2226,12 @@ dependencies = [ "libc", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.28.4" @@ -2194,6 +2333,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd" +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest", +] + [[package]] name = "percent-encoding" version = "2.2.0" @@ -2256,6 +2404,12 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "portable-atomic" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac662b3a6490de378b0ee15cf2dfff7127aebfe0b19acc65e7fbca3d299c3788" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2711,6 +2865,41 @@ dependencies = [ "syn", ] +[[package]] +name = "rpassword" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" +dependencies = [ + "libc", + "rtoolbox", + "winapi", +] + +[[package]] +name = "rtoolbox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "rusqlite" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" +dependencies = [ + "bitflags", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + [[package]] name = "rustc-demangle" version = "0.1.21" @@ -2802,6 +2991,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + [[package]] name = "same-file" version = "1.0.6" @@ -2829,6 +3027,18 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +[[package]] +name = "scrypt" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" +dependencies = [ + "hmac", + "pbkdf2", + "salsa20", + "sha2", +] + [[package]] name = "sct" version = "0.6.1" @@ -2997,14 +3207,15 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.26" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +checksum = "6d232d893b10de3eb7258ff01974d6ee20663d8e833263c99409d4b13a0209da" dependencies = [ "indexmap", + "itoa 1.0.4", "ryu", "serde", - "yaml-rust", + "unsafe-libyaml", ] [[package]] @@ -3128,6 +3339,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "stdweb" version = "0.4.20" @@ -3391,11 +3608,29 @@ dependencies = [ "libc", "standback", "stdweb", - "time-macros", + "time-macros 0.1.1", "version_check", "winapi", ] +[[package]] +name = "time" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +dependencies = [ + "itoa 1.0.4", + "serde", + "time-core", + "time-macros 0.2.6", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + [[package]] name = "time-macros" version = "0.1.1" @@ -3406,6 +3641,15 @@ dependencies = [ "time-macros-impl", ] +[[package]] +name = "time-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +dependencies = [ + "time-core", +] + [[package]] name = "time-macros-impl" version = "0.1.2" @@ -3694,6 +3938,12 @@ dependencies = [ "void", ] +[[package]] +name = "unsafe-libyaml" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1e5fa573d8ac5f1a856f8d7be41d390ee973daf97c806b2c1a465e4e1406e68" + [[package]] name = "untrusted" version = "0.7.1" @@ -3712,6 +3962,12 @@ dependencies = [ "serde", ] +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version-compare" version = "0.1.1" @@ -3760,23 +4016,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wapm-toml" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a61b6d3b6a2fc171198e6378b3a9b38650e114298775a9e63401613abb6a10b3" -dependencies = [ - "anyhow", - "semver 1.0.14", - "serde", - "serde_cbor", - "serde_derive", - "serde_json", - "serde_yaml", - "thiserror", - "toml", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -4056,6 +4295,7 @@ dependencies = [ "anyhow", "atty", "bytesize", + "cargo_metadata", "cfg-if 1.0.0", "chrono", "clap 3.2.23", @@ -4064,27 +4304,34 @@ dependencies = [ "dirs", "distance", "fern", + "flate2", "hex", "http_req", "isatty", "libc", "log", + "minisign", "nuke-dir", "prettytable-rs", "regex", "reqwest", + "rpassword", + "rusqlite", + "semver 1.0.14", "serde", "serde_json", "spinoff", + "tar", "target-lexicon 0.12.5", "tempdir", "tempfile", + "thiserror", + "time 0.3.17", "tldextract", "toml", "unix_mode", "url", "walkdir", - "wapm-toml", "wasmer", "wasmer-cache", "wasmer-compiler", @@ -4094,12 +4341,15 @@ dependencies = [ "wasmer-emscripten", "wasmer-object", "wasmer-registry", + "wasmer-toml", "wasmer-types", "wasmer-vfs", "wasmer-vm", "wasmer-wasi", "wasmer-wasi-experimental-io-devices", + "wasmer-wasm-interface", "wasmer-wast", + "wasmparser 0.51.4", "webc", ] @@ -4232,7 +4482,7 @@ dependencies = [ "lazy_static", "libc", "log", - "time", + "time 0.2.27", "wasmer", "wasmer-types", ] @@ -4271,6 +4521,7 @@ version = "3.1.0" dependencies = [ "anyhow", "flate2", + "pretty_assertions", "rand 0.8.5", "tar", "target-lexicon 0.12.5", @@ -4304,6 +4555,7 @@ name = "wasmer-registry" version = "3.1.0" dependencies = [ "anyhow", + "console", "dirs", "filetime", "flate2", @@ -4311,6 +4563,8 @@ dependencies = [ "futures-util", "graphql_client", "hex", + "indicatif", + "lazy_static", "log", "lzma-rs", "rand 0.8.5", @@ -4326,11 +4580,27 @@ dependencies = [ "tokio", "toml", "url", - "wapm-toml", + "wasmer-toml", "webc", "whoami", ] +[[package]] +name = "wasmer-toml" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03d0f664e5dfad0339727ad2f4f8a7d982b4c120d87b800380e306c0dc038a49" +dependencies = [ + "anyhow", + "semver 1.0.14", + "serde", + "serde_cbor", + "serde_json", + "serde_yaml", + "thiserror", + "toml", +] + [[package]] name = "wasmer-types" version = "3.1.0" @@ -4463,7 +4733,7 @@ dependencies = [ "byteorder", "pretty_assertions", "serde", - "time", + "time 0.2.27", "wasmer", "wasmer-derive", "wasmer-types", @@ -4473,6 +4743,18 @@ dependencies = [ "wasmer-wit-parser", ] +[[package]] +name = "wasmer-wasm-interface" +version = "3.1.0" +dependencies = [ + "bincode", + "either", + "nom 5.1.2", + "serde", + "wasmparser 0.51.4", + "wat", +] + [[package]] name = "wasmer-wast" version = "3.1.0" @@ -4586,6 +4868,12 @@ dependencies = [ "wasmer-wast", ] +[[package]] +name = "wasmparser" +version = "0.51.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" + [[package]] name = "wasmparser" version = "0.83.0" @@ -4972,7 +5260,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7" dependencies = [ - "nom", + "nom 7.1.1", ] [[package]] @@ -4981,15 +5269,6 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "yansi" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 931d979465e..25dbdf20a83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,7 @@ members = [ "lib/wasi-types", "lib/wasi-experimental-io-devices", "lib/wasi-local-networking", + "lib/wasm-interface", "lib/c-api/tests/wasmer-c-api-test-runner", "lib/c-api/examples/wasmer-capi-examples-runner", "lib/types", diff --git a/Makefile b/Makefile index 0123ebf7c97..c0f3a6d0d1f 100644 --- a/Makefile +++ b/Makefile @@ -401,18 +401,6 @@ else strip --strip-unneeded target/$(HOST_TARGET)/release/wasmer-headless endif -WAPM_VERSION = v0.5.3 -get-wapm: - [ -d "wapm-cli" ] || git clone --branch $(WAPM_VERSION) https://github.com/wasmerio/wapm-cli.git - -build-wapm: get-wapm -ifeq ($(IS_DARWIN), 1) - # We build it without bundling sqlite, as is included by default in macos - $(CARGO_BINARY) build $(CARGO_TARGET) --release --manifest-path wapm-cli/Cargo.toml --no-default-features --features "full packagesigning telemetry update-notifications" -else - $(CARGO_BINARY) build $(CARGO_TARGET) --release --manifest-path wapm-cli/Cargo.toml --features "telemetry update-notifications" -endif - build-docs: $(CARGO_BINARY) doc $(CARGO_TARGET) --release $(compiler_features) --document-private-items --no-deps --workspace --exclude wasmer-c-api @@ -549,6 +537,7 @@ test-examples: $(CARGO_BINARY) test $(CARGO_TARGET) --release $(compiler_features) --features wasi --examples test-integration-cli: + rustup target add wasm32-wasi $(CARGO_BINARY) test $(CARGO_TARGET) --features webc_runner --no-fail-fast -p wasmer-integration-tests-cli -- --nocapture --test-threads=1 test-integration-ios: @@ -564,23 +553,6 @@ generate-wasi-tests: # ##### -package-wapm: - mkdir -p "package/bin" -ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX) $(IS_FREEBSD))) - if [ -d "wapm-cli" ]; then \ - cp wapm-cli/$(TARGET_DIR)/wapm package/bin/ ;\ - echo -e "#!/bin/bash\nwapm execute \"\$$@\"" > package/bin/wax ;\ - chmod +x package/bin/wax ;\ - fi -else - if [ -d "wapm-cli" ]; then \ - cp wapm-cli/$(TARGET_DIR)/wapm package/bin/ ;\ - fi -ifeq ($(IS_DARWIN), 1) - codesign -s - package/bin/wapm || true -endif -endif - package-minimal-headless-wasmer: ifeq ($(IS_WINDOWS), 1) if [ -f "target/$(HOST_TARGET)/release/wasmer-headless.exe" ]; then \ diff --git a/lib/api/tests/externals.rs b/lib/api/tests/externals.rs index 5c17579a4ab..f593c763b79 100644 --- a/lib/api/tests/externals.rs +++ b/lib/api/tests/externals.rs @@ -210,28 +210,25 @@ fn memory_grow() -> Result<(), String> { fn function_new() -> Result<(), String> { let mut store = Store::default(); let function = Function::new_typed(&mut store, || {}); - assert_eq!( - function.ty(&mut store).clone(), - FunctionType::new(vec![], vec![]) - ); + assert_eq!(function.ty(&mut store), FunctionType::new(vec![], vec![])); let function = Function::new_typed(&mut store, |_a: i32| {}); assert_eq!( - function.ty(&mut store).clone(), + function.ty(&mut store), FunctionType::new(vec![Type::I32], vec![]) ); let function = Function::new_typed(&mut store, |_a: i32, _b: i64, _c: f32, _d: f64| {}); assert_eq!( - function.ty(&mut store).clone(), + function.ty(&mut store), FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]) ); let function = Function::new_typed(&mut store, || -> i32 { 1 }); assert_eq!( - function.ty(&mut store).clone(), + function.ty(&mut store), FunctionType::new(vec![], vec![Type::I32]) ); let function = Function::new_typed(&mut store, || -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) }); assert_eq!( - function.ty(&mut store).clone(), + function.ty(&mut store), FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]) ); Ok(()) @@ -246,14 +243,11 @@ fn function_new_env() -> Result<(), String> { let my_env = MyEnv {}; let env = FunctionEnv::new(&mut store, my_env); let function = Function::new_typed_with_env(&mut store, &env, |_env: FunctionEnvMut| {}); - assert_eq!( - function.ty(&mut store).clone(), - FunctionType::new(vec![], vec![]) - ); + assert_eq!(function.ty(&mut store), FunctionType::new(vec![], vec![])); let function = Function::new_typed_with_env(&mut store, &env, |_env: FunctionEnvMut, _a: i32| {}); assert_eq!( - function.ty(&mut store).clone(), + function.ty(&mut store), FunctionType::new(vec![Type::I32], vec![]) ); let function = Function::new_typed_with_env( @@ -262,13 +256,13 @@ fn function_new_env() -> Result<(), String> { |_env: FunctionEnvMut, _a: i32, _b: i64, _c: f32, _d: f64| {}, ); assert_eq!( - function.ty(&mut store).clone(), + function.ty(&mut store), FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]) ); let function = Function::new_typed_with_env(&mut store, &env, |_env: FunctionEnvMut| -> i32 { 1 }); assert_eq!( - function.ty(&mut store).clone(), + function.ty(&mut store), FunctionType::new(vec![], vec![Type::I32]) ); let function = Function::new_typed_with_env( @@ -277,7 +271,7 @@ fn function_new_env() -> Result<(), String> { |_env: FunctionEnvMut| -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) }, ); assert_eq!( - function.ty(&mut store).clone(), + function.ty(&mut store), FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]) ); Ok(()) @@ -294,35 +288,35 @@ fn function_new_dynamic() -> Result<(), String> { &function_type, |_values: &[Value]| unimplemented!(), ); - assert_eq!(function.ty(&mut store).clone(), function_type); + assert_eq!(function.ty(&mut store), function_type); let function_type = FunctionType::new(vec![Type::I32], vec![]); let function = Function::new( &mut store, &function_type, |_values: &[Value]| unimplemented!(), ); - assert_eq!(function.ty(&mut store).clone(), function_type); + assert_eq!(function.ty(&mut store), function_type); let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]); let function = Function::new( &mut store, &function_type, |_values: &[Value]| unimplemented!(), ); - assert_eq!(function.ty(&mut store).clone(), function_type); + assert_eq!(function.ty(&mut store), function_type); let function_type = FunctionType::new(vec![], vec![Type::I32]); let function = Function::new( &mut store, &function_type, |_values: &[Value]| unimplemented!(), ); - assert_eq!(function.ty(&mut store).clone(), function_type); + assert_eq!(function.ty(&mut store), function_type); let function_type = FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]); let function = Function::new( &mut store, &function_type, |_values: &[Value]| unimplemented!(), ); - assert_eq!(function.ty(&mut store).clone(), function_type); + assert_eq!(function.ty(&mut store), function_type); // Using array signature let function_type = ([Type::V128], [Type::I32, Type::F32, Type::F64]); @@ -356,7 +350,7 @@ fn function_new_dynamic_env() -> Result<(), String> { &function_type, |_env: FunctionEnvMut, _values: &[Value]| unimplemented!(), ); - assert_eq!(function.ty(&mut store).clone(), function_type); + assert_eq!(function.ty(&mut store), function_type); let function_type = FunctionType::new(vec![Type::I32], vec![]); let function = Function::new_with_env( &mut store, @@ -364,7 +358,7 @@ fn function_new_dynamic_env() -> Result<(), String> { &function_type, |_env: FunctionEnvMut, _values: &[Value]| unimplemented!(), ); - assert_eq!(function.ty(&mut store).clone(), function_type); + assert_eq!(function.ty(&mut store), function_type); let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]); let function = Function::new_with_env( &mut store, @@ -372,7 +366,7 @@ fn function_new_dynamic_env() -> Result<(), String> { &function_type, |_env: FunctionEnvMut, _values: &[Value]| unimplemented!(), ); - assert_eq!(function.ty(&mut store).clone(), function_type); + assert_eq!(function.ty(&mut store), function_type); let function_type = FunctionType::new(vec![], vec![Type::I32]); let function = Function::new_with_env( &mut store, @@ -380,7 +374,7 @@ fn function_new_dynamic_env() -> Result<(), String> { &function_type, |_env: FunctionEnvMut, _values: &[Value]| unimplemented!(), ); - assert_eq!(function.ty(&mut store).clone(), function_type); + assert_eq!(function.ty(&mut store), function_type); let function_type = FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]); let function = Function::new_with_env( &mut store, @@ -388,7 +382,7 @@ fn function_new_dynamic_env() -> Result<(), String> { &function_type, |_env: FunctionEnvMut, _values: &[Value]| unimplemented!(), ); - assert_eq!(function.ty(&mut store).clone(), function_type); + assert_eq!(function.ty(&mut store), function_type); // Using array signature let function_type = ([Type::V128], [Type::I32, Type::F32, Type::F64]); diff --git a/lib/api/tests/reference_types.rs b/lib/api/tests/reference_types.rs index aecd46d48ec..8746936f06f 100644 --- a/lib/api/tests/reference_types.rs +++ b/lib/api/tests/reference_types.rs @@ -367,7 +367,7 @@ pub mod reference_types { let global: &Global = instance.exports.get_global("global")?; { let er = ExternRef::new(&mut store, 3usize); - global.set(&mut store, Value::ExternRef(Some(er.clone())))?; + global.set(&mut store, Value::ExternRef(Some(er)))?; } let get_from_global: TypedFunction<(), Option> = instance .exports @@ -398,7 +398,7 @@ pub mod reference_types { let er = ExternRef::new(&mut store, 3usize); - let result = pass_extern_ref.call(&mut store, Some(er.clone())); + let result = pass_extern_ref.call(&mut store, Some(er)); assert!(result.is_err()); Ok(()) @@ -442,7 +442,7 @@ pub mod reference_types { let result = grow_table_with_ref.call(&mut store, Some(er1.clone()), 10_000)?; assert_eq!(result, -1); - let result = grow_table_with_ref.call(&mut store, Some(er1.clone()), 8)?; + let result = grow_table_with_ref.call(&mut store, Some(er1), 8)?; assert_eq!(result, 2); for i in 2..10 { @@ -454,7 +454,7 @@ pub mod reference_types { } { - fill_table_with_ref.call(&mut store, Some(er2.clone()), 0, 2)?; + fill_table_with_ref.call(&mut store, Some(er2), 0, 2)?; } { @@ -462,7 +462,7 @@ pub mod reference_types { table2.set(&mut store, 1, Value::ExternRef(Some(er3.clone())))?; table2.set(&mut store, 2, Value::ExternRef(Some(er3.clone())))?; table2.set(&mut store, 3, Value::ExternRef(Some(er3.clone())))?; - table2.set(&mut store, 4, Value::ExternRef(Some(er3.clone())))?; + table2.set(&mut store, 4, Value::ExternRef(Some(er3)))?; } { diff --git a/lib/c-api/examples/assets/qjs-wapm.toml b/lib/c-api/examples/assets/qjs-wasmer.toml similarity index 100% rename from lib/c-api/examples/assets/qjs-wapm.toml rename to lib/c-api/examples/assets/qjs-wasmer.toml diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index ac8a1d9b639..0062558e3d9 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -40,6 +40,8 @@ wasmer-types = { version = "=3.1.0", path = "../types" } wasmer-registry = { version = "=3.1.0", path = "../registry" } wasmer-object = { version = "=3.1.0", path = "../object", optional = true } wasmer-vfs = { version = "=3.1.0", path = "../vfs", default-features = false, features = ["host-fs"] } +wasmer-wasm-interface = { version = "3.1.0", path = "../wasm-interface" } +wasmparser = "0.51.4" atty = "0.2" colored = "2.0" anyhow = "1.0" @@ -52,7 +54,6 @@ bytesize = "1.0" cfg-if = "1.0" # For debug feature fern = { version = "0.6", features = ["colored"], optional = true } -log = { version = "0.4", optional = true } tempfile = "3" tempdir = "0.3.7" http_req = { version="^0.8", default-features = false, features = ["rust-tls"] } @@ -62,7 +63,7 @@ dirs = { version = "4.0" } serde_json = { version = "1.0" } target-lexicon = { version = "0.12", features = ["std"] } prettytable-rs = "0.9.0" -wapm-toml = "0.2.0" +wasmer-toml = "0.5.0" walkdir = "2.3.2" regex = "1.6.0" toml = "0.5.9" @@ -74,6 +75,16 @@ isatty = "0.1.9" dialoguer = "0.10.2" tldextract = "0.6.0" hex = "0.4.3" +flate2 = "1.0.25" +cargo_metadata = "0.15.2" +rusqlite = { version = "0.28.0", features = ["bundled"] } +tar = "0.4.38" +thiserror = "1.0.37" +time = { version = "0.3.17", default-features = false, features = ["parsing", "std", "formatting"] } +log = "0.4.17" +minisign = "0.7.2" +semver = "1.0.14" +rpassword = "7.2.0" [build-dependencies] chrono = { version = "^0.4", default-features = false, features = [ "std", "clock" ] } @@ -144,7 +155,7 @@ llvm = [ "wasmer-compiler-llvm", "compiler", ] -debug = ["fern", "log", "wasmer-wasi/logging"] +debug = ["fern", "wasmer-wasi/logging"] disable-all-logging = ["wasmer-wasi/disable-all-logging"] headless = [] headless-minimal = ["headless", "disable-all-logging", "wasi"] diff --git a/lib/cli/sql/migrations/0000.sql b/lib/cli/sql/migrations/0000.sql new file mode 100644 index 00000000000..a527dbc4f29 --- /dev/null +++ b/lib/cli/sql/migrations/0000.sql @@ -0,0 +1,27 @@ +CREATE TABLE personal_keys +( + id integer primary key, + active integer not null, + public_key_id text not null UNIQUE, + public_key_value text not null UNIQUE, + private_key_location text UNIQUE, + key_type_identifier text not null, + date_added text not null +); + +CREATE TABLE wapm_users +( + id integer primary key, + name text not null UNIQUE +); + +CREATE TABLE wapm_public_keys +( + id integer primary key, + public_key_id text not null UNIQUE, + user_key integer not null, + public_key_value text not null UNIQUE, + key_type_identifier text not null, + date_added text not null, + FOREIGN KEY(user_key) REFERENCES wapm_users(id) +); diff --git a/lib/cli/sql/migrations/0001.sql b/lib/cli/sql/migrations/0001.sql new file mode 100644 index 00000000000..42587319156 --- /dev/null +++ b/lib/cli/sql/migrations/0001.sql @@ -0,0 +1,9 @@ +CREATE TABLE wasm_contracts +( + id integer primary key, + contract_name text not null, + version text not null, + date_added text not null, + content text not null, + CONSTRAINT name_version_unique UNIQUE (contract_name, version) +); diff --git a/lib/cli/sql/migrations/0002.sql b/lib/cli/sql/migrations/0002.sql new file mode 100644 index 00000000000..cc57ff9b8ee --- /dev/null +++ b/lib/cli/sql/migrations/0002.sql @@ -0,0 +1,26 @@ +PRAGMA foreign_keys=off; + +CREATE TABLE wasm_interfaces +( + id integer primary key, + interface_name text not null, + version text not null, + date_added text not null, + content text not null, + CONSTRAINT name_version_unique UNIQUE (interface_name, version) +); + +INSERT INTO wasm_interfaces +( + id, + interface_name, + version, + date_added, + content +) + SELECT id, contract_name, version, date_added, content + FROM wasm_contracts; + +DROP TABLE wasm_contracts; + +PRAGMA foreign_keys=on; diff --git a/lib/cli/src/cli.rs b/lib/cli/src/cli.rs index 3b9b8cea6f3..9e7bd97f395 100644 --- a/lib/cli/src/cli.rs +++ b/lib/cli/src/cli.rs @@ -11,7 +11,7 @@ use crate::commands::CreateObj; #[cfg(feature = "wast")] use crate::commands::Wast; use crate::commands::{ - Add, Cache, Config, Inspect, List, Login, Run, SelfUpdate, Validate, Whoami, + Add, Cache, Config, Init, Inspect, List, Login, Publish, Run, SelfUpdate, Validate, Whoami, }; use crate::error::PrettyError; use clap::{CommandFactory, ErrorKind, Parser}; @@ -46,6 +46,10 @@ enum WasmerCLIOptions { /// Login into a wapm.io-like registry Login(Login), + /// Login into a wapm.io-like registry + #[clap(name = "publish")] + Publish(Publish), + /// Wasmer cache #[clap(subcommand)] Cache(Cache), @@ -135,6 +139,10 @@ enum WasmerCLIOptions { /// Inspect a WebAssembly file Inspect(Inspect), + /// Initializes a new wasmer.toml file + #[clap(name = "init")] + Init(Init), + /// Run spec testsuite #[cfg(feature = "wast")] Wast(Wast), @@ -165,8 +173,10 @@ impl WasmerCLIOptions { Self::CreateObj(create_obj) => create_obj.execute(), Self::Config(config) => config.execute(), Self::Inspect(inspect) => inspect.execute(), + Self::Init(init) => init.execute(), Self::List(list) => list.execute(), Self::Login(login) => login.execute(), + Self::Publish(publish) => publish.execute(), #[cfg(feature = "wast")] Self::Wast(wast) => wast.execute(), #[cfg(target_os = "linux")] @@ -224,10 +234,9 @@ fn wasmer_main_inner() -> Result<(), anyhow::Error> { WasmerCLIOptions::Run(Run::from_binfmt_args()) } else { match command.unwrap_or(&"".to_string()).as_ref() { - "add" | "cache" | "compile" | "config" | "create-exe" | "help" | "inspect" | "run" - | "self-update" | "validate" | "wast" | "binfmt" | "list" | "login" => { - WasmerCLIOptions::parse() - } + "add" | "cache" | "compile" | "config" | "create-exe" | "help" | "inspect" | "init" + | "run" | "self-update" | "validate" | "wast" | "binfmt" | "list" | "login" + | "publish" => WasmerCLIOptions::parse(), _ => { WasmerCLIOptions::try_parse_from(args.iter()).unwrap_or_else(|e| { match e.kind() { diff --git a/lib/cli/src/commands.rs b/lib/cli/src/commands.rs index d59d5c78cf4..00b814d4df5 100644 --- a/lib/cli/src/commands.rs +++ b/lib/cli/src/commands.rs @@ -10,9 +10,11 @@ mod config; mod create_exe; #[cfg(feature = "static-artifact-create")] mod create_obj; +mod init; mod inspect; mod list; mod login; +mod publish; mod run; mod self_update; mod validate; @@ -31,8 +33,8 @@ pub use create_obj::*; #[cfg(feature = "wast")] pub use wast::*; pub use { - add::*, cache::*, config::*, inspect::*, list::*, login::*, run::*, self_update::*, - validate::*, whoami::*, + add::*, cache::*, config::*, init::*, inspect::*, list::*, login::*, publish::*, run::*, + self_update::*, validate::*, whoami::*, }; /// The kind of object format to emit. diff --git a/lib/cli/src/commands/add.rs b/lib/cli/src/commands/add.rs index fc1395c5ca5..443b966d41a 100644 --- a/lib/cli/src/commands/add.rs +++ b/lib/cli/src/commands/add.rs @@ -76,7 +76,9 @@ impl Add { match &self.registry { Some(r) => Ok(r.clone()), None => { - let cfg = PartialWapmConfig::from_file() + let wasmer_dir = + PartialWapmConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("{e}"))?; + let cfg = PartialWapmConfig::from_file(&wasmer_dir) .map_err(Error::msg) .context("Unable to load WAPM's config file")?; Ok(cfg.registry.get_current_registry()) diff --git a/lib/cli/src/commands/init.rs b/lib/cli/src/commands/init.rs new file mode 100644 index 00000000000..d3e4e520313 --- /dev/null +++ b/lib/cli/src/commands/init.rs @@ -0,0 +1,517 @@ +use anyhow::Context; +use cargo_metadata::{CargoOpt, MetadataCommand}; +use clap::Parser; +use std::collections::HashMap; +use std::path::Path; +use std::path::PathBuf; +use wasmer_registry::PartialWapmConfig; + +static NOTE: &str = + "# See more keys and definitions at https://docs.wasmer.io/ecosystem/wapm/manifest"; + +const NEWLINE: &str = if cfg!(windows) { "\r\n" } else { "\n" }; + +/// CLI args for the `wasmer init` command +#[derive(Debug, Parser)] +pub struct Init { + /// Initialize wasmer.toml for a library package + #[clap(long, group = "crate-type")] + pub lib: bool, + /// Initialize wasmer.toml for a binary package + #[clap(long, group = "crate-type")] + pub bin: bool, + /// Initialize an empty wasmer.toml + #[clap(long, group = "crate-type")] + pub empty: bool, + /// Force overwriting the wasmer.toml, even if it already exists + #[clap(long)] + pub overwrite: bool, + /// Don't display debug output + #[clap(long)] + pub quiet: bool, + /// Namespace to init with, default = current logged in user or _ + #[clap(long)] + pub namespace: Option, + /// Package name to init with, default = Cargo.toml name or current directory name + #[clap(long)] + pub package_name: Option, + /// Version of the initialized package + #[clap(long)] + pub version: Option, + /// If the `manifest-path` is a Cargo.toml, use that file to initialize the wasmer.toml + #[clap(long)] + pub manifest_path: Option, + /// Add default dependencies for common packages + #[clap(long, value_enum)] + pub template: Option