mirror of
https://github.com/fluencelabs/wasmer
synced 2025-07-31 23:32:04 +00:00
Merge #1233
1233: Improved Wasmer C API release artifacts r=syrusakbary a=syrusakbary <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description This PR updates the artifacts generated for Wasmer C API, in a way that is much more consumable, including a quick README and License. So, after running `make capi && make build-capi` We will have a `wasmer-c-api.tar.gz` file with the following structure ``` / lib/ libwasmer.a libwasmer.so include/ wasmer.h wasmer.hh README.md LICENSE ``` See example generated artifact here: [wasmer-c-api.tar.gz](https://github.com/wasmerio/wasmer/files/4228560/wasmer-c-api.tar.gz) <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Syrus <me@syrusakbary.com> Co-authored-by: Syrus Akbary <me@syrusakbary.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,5 +5,6 @@
|
||||
.idea
|
||||
**/.vscode
|
||||
install/
|
||||
capi/
|
||||
api-docs/
|
||||
api-docs-repo/
|
||||
|
@@ -29,7 +29,7 @@ before_deploy:
|
||||
# Release
|
||||
- make release-singlepass
|
||||
- make wapm
|
||||
- make build-install
|
||||
- make build-install-package
|
||||
- mkdir -p artifacts
|
||||
- cp ./wasmer.tar.gz ./artifacts/$(./scripts/binary-name.sh)
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
## **[Unreleased]**
|
||||
|
||||
- [#1233](https://github.com/wasmerio/wasmer/pull/1233) Improved Wasmer C API release artifacts.
|
||||
- [#1216](https://github.com/wasmerio/wasmer/pull/1216) `wasmer-interface-types` receives a binary encoder.
|
||||
- [#1228](https://github.com/wasmerio/wasmer/pull/1228) Singlepass cleanup: Resolve several FIXMEs and remove protect_unix.
|
||||
- [#1218](https://github.com/wasmerio/wasmer/pull/1218) Enable Cranelift verifier in debug mode. Fix bug with table indices being the wrong type.
|
||||
|
36
Makefile
36
Makefile
@@ -287,13 +287,39 @@ bench-llvm:
|
||||
cargo bench --all --no-default-features --features "backend-llvm" \
|
||||
--exclude wasmer-singlepass-backend --exclude wasmer-clif-backend --exclude wasmer-kernel-loader
|
||||
|
||||
# Build utils
|
||||
build-install:
|
||||
build-install-package:
|
||||
# This command doesn't build the binary, just packages it
|
||||
mkdir -p ./install/bin
|
||||
cp ./wapm-cli/target/release/wapm ./install/bin/
|
||||
cp ./target/release/wasmer ./install/bin/
|
||||
tar -C ./install -zcvf wasmer.tar.gz bin/wapm bin/wasmer
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
|
||||
build-capi-package:
|
||||
# This command doesn't build the C-API, just packages it
|
||||
mkdir -p ./capi/
|
||||
mkdir -p ./capi/include
|
||||
mkdir -p ./capi/lib
|
||||
ifeq ($(OS), Windows_NT)
|
||||
cp target/release/wasmer_runtime_c_api.dll ./capi/lib/wasmer.dll
|
||||
cp target/release/wasmer_runtime_c_api.lib ./capi/lib/wasmer.lib
|
||||
else
|
||||
ifeq ($(UNAME_S), Darwin)
|
||||
cp target/release/libwasmer_runtime_c_api.dylib ./capi/lib/libwasmer.dylib
|
||||
cp target/release/libwasmer_runtime_c_api.dylib ./capi/lib/libwasmer.a
|
||||
# Fix the rpath for the dylib
|
||||
install_name_tool -id "@rpath/libwasmer.dylib" ./capi/lib/libwasmer.dylib
|
||||
else
|
||||
cp target/release/libwasmer_runtime_c_api.so ./capi/lib/libwasmer.so
|
||||
cp target/release/libwasmer_runtime_c_api.a ./capi/lib/libwasmer.a
|
||||
endif
|
||||
endif
|
||||
find target/release/build -name 'wasmer.h*' -exec cp {} ./capi/include ';'
|
||||
cp LICENSE ./capi/LICENSE
|
||||
cp lib/runtime-c-api/doc/index.md ./capi/README.md
|
||||
tar -C ./capi -zcvf wasmer-c-api.tar.gz lib include README.md LICENSE
|
||||
|
||||
# For installing the contents locally
|
||||
do-install:
|
||||
tar -C ~/.wasmer -zxvf wasmer.tar.gz
|
||||
@@ -306,9 +332,11 @@ publish-release:
|
||||
dep-graph:
|
||||
cargo deps --optional-deps --filter wasmer-wasi wasmer-wasi-tests wasmer-kernel-loader wasmer-dev-utils wasmer-llvm-backend wasmer-emscripten wasmer-emscripten-tests wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-middleware-common-tests wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png
|
||||
|
||||
docs:
|
||||
docs-capi:
|
||||
cd lib/runtime-c-api/ && doxygen doxyfile
|
||||
|
||||
docs: docs-capi
|
||||
cargo doc --features=backend-singlepass,backend-cranelift,backend-llvm,docs,wasi,managed --workspace --document-private-items --no-deps
|
||||
cd lib/runtime-c-api/ && doxygen doxyfile && cd ..
|
||||
mkdir -p api-docs
|
||||
mkdir -p api-docs/c
|
||||
cp -R target/doc api-docs/crates
|
||||
|
@@ -153,7 +153,7 @@ jobs:
|
||||
condition: |
|
||||
startsWith(variables['Build.SourceBranch'], 'refs/tags')
|
||||
- bash: |
|
||||
make build-install
|
||||
make build-install-package
|
||||
cp ./wasmer.tar.gz ./artifacts/$(./scripts/binary-name.sh)
|
||||
displayName: Build Distribution (*nix)
|
||||
condition: |
|
||||
@@ -213,21 +213,25 @@ jobs:
|
||||
condition: and(succeeded(), not(eq(variables['Agent.OS'], 'Windows_NT')))
|
||||
- bash: |
|
||||
make capi
|
||||
cp target/release/libwasmer_runtime_c_api.so ./artifacts
|
||||
find target/release/build -name 'wasmer.h*' -exec cp {} ./artifacts ';'
|
||||
displayName: Build c-api (Linux)
|
||||
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
|
||||
displayName: Build c-api
|
||||
- bash: |
|
||||
make capi
|
||||
install_name_tool -id "@rpath/libwasmer_runtime_c_api.dylib" target/release/libwasmer_runtime_c_api.dylib
|
||||
cp target/release/libwasmer_runtime_c_api.dylib ./artifacts
|
||||
displayName: Build c-api (Darwin)
|
||||
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
|
||||
make build-capi-package
|
||||
cp ./wasmer-c-api.tar.gz ./artifacts/$(./scripts/capi-name.sh)
|
||||
displayName: Build c-api artifacts (Unix)
|
||||
condition: |
|
||||
and(
|
||||
succeeded(),
|
||||
not(eq(variables['Agent.OS'], 'Windows_NT'))
|
||||
)
|
||||
- bash: |
|
||||
make capi
|
||||
cp target/release/wasmer_runtime_c_api.dll ./artifacts
|
||||
displayName: Build c-api (Windows)
|
||||
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
|
||||
make build-capi-package
|
||||
cp ./wasmer-c-api.tar.gz ./artifacts/wasmer-c-api-windows.tar.gz
|
||||
displayName: Build c-api artifacts (Windows)
|
||||
condition: |
|
||||
and(
|
||||
succeeded(),
|
||||
eq(variables['Agent.OS'], 'Windows_NT')
|
||||
)
|
||||
- publish: $(System.DefaultWorkingDirectory)/artifacts
|
||||
artifact: library-$(Agent.OS)
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
name = "wasmer-runtime-c-api"
|
||||
version = "0.13.1"
|
||||
description = "Wasmer C API library"
|
||||
documentation = "https://wasmerio.github.io/wasmer/c/runtime-c-api/"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
repository = "https://github.com/wasmerio/wasmer"
|
||||
|
@@ -1,12 +1,9 @@
|
||||
# Wasmer Runtime C API
|
||||
|
||||
[Wasmer] is a standalone [WebAssembly] runtime, aiming to be fully
|
||||
compatible with WASI, Emscripten, Rust and Go. [Learn
|
||||
more](https://github.com/wasmerio/wasmer).
|
||||
[Wasmer] is a standalone WebAssembly runtime for running WebAssembly [outside of the browser](https://webassembly.org/docs/non-web/), supporting [WASI](https://github.com/WebAssembly/WASI) and [Emscripten](https://emscripten.org/).
|
||||
|
||||
The `wasmer-runtime-c-api` crate exposes a C and a C++ API to interact
|
||||
with the Wasmer runtime. This document is the index of its
|
||||
auto-generated documentation.
|
||||
The Wasmer Runtime C API exposes a C and a C++ API to interact
|
||||
with the Wasmer Runtime, so you can use WebAssembly anywhere.
|
||||
|
||||
[Wasmer]: https://github.com/wasmerio/wasmer
|
||||
[WebAssembly]: https://webassembly.org/
|
||||
@@ -15,21 +12,22 @@ auto-generated documentation.
|
||||
|
||||
Since the Wasmer runtime is written in Rust, the C and C++ API are
|
||||
designed to work hand-in-hand with its shared library. The C and C++
|
||||
header files, namely [`wasmer.h`] and `wasmer.hh` are documented
|
||||
here. Their source code can be found in the source tree of this
|
||||
crate. They are automatically generated, and always up-to-date in this
|
||||
repository. The C and C++ header files along with the runtime shared
|
||||
header files, namely [`wasmer.h`][wasmer_h] and `wasmer.hh` are documented
|
||||
in the docs.
|
||||
|
||||
Their source code can be found in the source tree of the [wasmer-runtime-c-api](https://github.com/wasmerio/wasmer/tree/master/lib/runtime-c-api)
|
||||
crate.
|
||||
The C and C++ header files along with the runtime shared
|
||||
libraries (`.so`, `.dylib`, `.dll`) can also be downloaded in the
|
||||
Wasmer [release page].
|
||||
|
||||
[`wasmer.h`]: ./wasmer_8h.html
|
||||
[release page]: https://github.com/wasmerio/wasmer/releases
|
||||
|
||||
Here is a simple example to use the C API:
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include "../wasmer.h"
|
||||
#include "wasmer.h"
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -90,26 +88,12 @@ int main()
|
||||
}
|
||||
```
|
||||
|
||||
# Testing
|
||||
# Examples
|
||||
|
||||
Tests are run using the release build of the library. If you make
|
||||
changes or compile with non-default features, please ensure you
|
||||
rebuild in release mode for the tests to see the changes.
|
||||
You can check more examples of how to use the Wasmer C API here:
|
||||
|
||||
The tests can be run via `cargo test`, such as:
|
||||
https://docs.wasmer.io/integrations/c/examples
|
||||
|
||||
```sh
|
||||
$ cargo test --release -- --nocapture
|
||||
```
|
||||
|
||||
To run tests manually, enter the `lib/runtime-c-api/tests` directory
|
||||
and run the following commands:
|
||||
|
||||
```sh
|
||||
$ cmake .
|
||||
$ make
|
||||
$ make test
|
||||
```
|
||||
|
||||
|
||||
# License
|
||||
@@ -118,7 +102,6 @@ Wasmer is primarily distributed under the terms of the [MIT
|
||||
license][mit-license] ([LICENSE][license]).
|
||||
|
||||
|
||||
[wasmer_h]: ./wasmer.h
|
||||
[wasmer_hh]: ./wasmer.hh
|
||||
[wasmer_h]: https://wasmerio.github.io/wasmer/c/runtime-c-api/wasmer_8h.html
|
||||
[mit-license]: http://opensource.org/licenses/MIT
|
||||
[license]: https://github.com/wasmerio/wasmer/blob/master/LICENSE
|
||||
|
@@ -2,7 +2,6 @@
|
||||
name = "wasmer-runtime"
|
||||
version = "0.13.1"
|
||||
description = "Wasmer runtime library"
|
||||
documentation = "https://wasmerio.github.io/wasmer/c/runtime-c-api/"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
repository = "https://github.com/wasmerio/wasmer"
|
||||
|
46
scripts/capi-name.sh
Executable file
46
scripts/capi-name.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
initArch() {
|
||||
ARCH=$(uname -m)
|
||||
if [ -n "$WASMER_ARCH" ]; then
|
||||
ARCH="$WASMER_ARCH"
|
||||
fi
|
||||
# If you modify this list, please also modify install.sh
|
||||
case $ARCH in
|
||||
amd64) ARCH="amd64";;
|
||||
x86_64) ARCH="amd64";;
|
||||
aarch64) ARCH="arm64";;
|
||||
i386) ARCH="386";;
|
||||
*) echo "Architecture ${ARCH} is not supported by this installation script"; exit 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
initOS() {
|
||||
OS=$(uname | tr '[:upper:]' '[:lower:]')
|
||||
if [ -n "$WASMER_OS" ]; then
|
||||
echo "Using WASMER_OS"
|
||||
OS="$WASMER_OS"
|
||||
fi
|
||||
case "$OS" in
|
||||
darwin) OS='darwin';;
|
||||
linux) OS='linux';;
|
||||
freebsd) OS='freebsd';;
|
||||
# mingw*) OS='windows';;
|
||||
# msys*) OS='windows';;
|
||||
*) echo "OS ${OS} is not supported by this installation script"; exit 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
# identify platform based on uname output
|
||||
initArch
|
||||
initOS
|
||||
|
||||
# determine install directory if required
|
||||
BINARY="wasmer-c-api-${OS}-${ARCH}.tar.gz"
|
||||
|
||||
# add .exe if on windows
|
||||
# if [ "$OS" = "windows" ]; then
|
||||
# BINARY="$BINARY.exe"
|
||||
# fi
|
||||
|
||||
echo "${BINARY}"
|
Reference in New Issue
Block a user