wasmerio / cargo-wasmer Goto Github PK
View Code? Open in Web Editor NEWA cargo sub-command for publishing Rust crates to the WebAssembly Package Manager.
License: Apache License 2.0
A cargo sub-command for publishing Rust crates to the WebAssembly Package Manager.
License: Apache License 2.0
I tried cargo wapm
, expecting to see what WAPM-related commands does cargo-wapm
has. But it immediately tried to publish the package.
Maybe publishing should be a separate subcommand (even if currently it is the only subcommand), to make room for other future things like cargo wapm add
for adding dependencies from WAPM? Or cargo wapm yank
for unpublishing packages, if/when it will be supported.
It'd be nice if people can use cargo wapm
in CI without needing to do a full cargo install cargo-wapm
.
Let's add a releases.yml
job which will compile binary artifacts, create a release, and attach the artifacts to it. We'd also want to update README.md
with a one-liner people can use to download the latest binaries.
When constructing a wapm_toml::Manifest
, we call determine_target()
which takes a cargo_metadata::Package
(i.e. a parsed Cargo.toml
) and returns a reference to the one cargo_metadata::Target
in that Package
. From there, we construct a wapm_toml::Manifest
with a single wapm_toml::Module
that corresponds to that Target
(i.e. a WASI executable or WebAssembly library).
WAPM packages support multiple modules, so it'd be nice if our "autodiscovery" can generate a wapm_toml::Manifest
containing multiple wapm_toml::Module
s, where we have one Module
per Target
(e.g. if your crate contains a library and a binary, the WAPM package would make both available).
TLDR. Run that command and it'll delete everything in the current directory. This appears to only happen when the current directory is a valid project.
When I use cargo wapm --dry-run
with the following:
[package.metadata.wapm]
namespace = "wasmer"
abi = "none"
bindings = { wai-version = "0.2.0", exports = "sha2.wai" }
I get the errrors:
Error: Could not parse manifest because missing field `wit-exports` for key `module.bindings` at line 14 column 1.
Error: Unable to publish "sha2-wasm"
Caused by:
The wapm CLI exited unsuccessfully with exit code -1
Publishing Rust crates with the wapm
command no longer works because you run into validation errors around bulk memory operations.
$ cargo wapm --dry-run
2023-07-19T02:43:40.113941Z INFO publish: cargo_wapm::publish: Getting ready to publish dry_run=true pkg="wapm-to-webc"
Error: WASM file "/Users/work/Documents/wasmer/pirita/target/wapm/wapm2pirita.wasm" detected as invalid because bulk memory support is not enabled (at offset 4615795)
╭─────────────────────────────────────────────────────────────────────────────╮
│ │
│ There's a new version of wasmer and wapm! 4.0.0-beta.1 → v3.3.0 │
│ Changelog: https://github.com/wasmerio/wasmer/releases/tag/v3.3.0 │
│ Update with wasmer self-update │
│ │
╰─────────────────────────────────────────────────────────────────────────────╯
Error: Unable to publish "wapm-to-webc"
Caused by:
The wapm CLI exited unsuccessfully with exit code 255
The wapm
command has also been removed from the Wasmer toolchain and its functionality was merged into the main wasmer
CLI. As part of this migration, we also renamed wapm.toml
to wasmer.toml
.
To avoid more breaking changes in the future, we should publish to the Wasmer registry directly. This will involve:
wasmer.toml
instead of wapm.toml
wasmer_registry::publish
or by querying the GraphQL API directly)It'd be nice if cargo-wapm
made its functionality available as a library as well as an executable. That way external tools can use the packaging functionality without needing to install the cargo wapm
executable.
See also: wasmerio/wasmer-pack#112
There is a tool that can be built for WASI along with other non-wasm platforms.
But cargo wapm
does not to publish it.
$ cargo wapm --dry-run
2022-08-12T21:39:43.681554Z INFO publish: cargo_wapm: Publishing dry_run=true pkg="random-distributions-cli"
Error: Unable to publish "random-distributions-cli"
Caused by:
The package doesn't contain a library with the "cdylib" crate-type
Or is WAPM only for libraries, not for executables, unlike crates.io
?
It looks like when cargo-wapm
generates the wapm.toml
, it uses absolute paths for things like the README
rather than making them relative to the base directory.
Here is one example:
[package]
name = "aysjha/sgp3"
version = "0.1.5"
description = "sgp4 for wasm, published on WAPM"
license = "MIT OR Apache-2.0"
readme = "/Users/ayushjha/git/wasmer/sgp4/README.md"
This used to work previously because we never did any validation on the manifest and wapm2pirita
blindly copied everything from the package directory into the *.tar.gz
file that gets published, whereas newer versions are more selective in what they upload.
@ayys this is why we're seeing a bunch of failures at the moment.
With wasmerio/wasmer-toml#8 now being merged, we should rename the command to cargo wasmer
and switch to the wasmer-toml
crate.
For compatibility, it might be a good idea to leave the cargo-wapm
binary around for a while and print a big warning so people know to use the cargo wasmer
sub-command.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.