Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Wasmer C API release artifacts #1233

Merged
merged 13 commits into from
Feb 20, 2020
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,33 @@ build-install:
cp ./target/release/wasmer ./install/bin/
tar -C ./install -zcvf wasmer.tar.gz bin/wapm bin/wasmer

UNAME_S := $(shell uname -s)

build-capi:
syrusakbary marked this conversation as resolved.
Show resolved Hide resolved
mkdir -p ./capi/
mkdir -p ./capi/include
mkdir -p ./capi/lib

ifeq ($(OS), Windows_NT)
cp target/release/libwasmer_runtime_c_api.dll ./capi/lib/wasmer.dll
cp target/release/libwasmer_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

syrusakbary marked this conversation as resolved.
Show resolved Hide resolved
find target/release/build -name 'wasmer.h*' -exec cp {} ./capi/include ';'
cp LICENSE ./capi/LICENSE
cp lib/runtime-c-api/distribution/* ./capi/
syrusakbary marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
17 changes: 4 additions & 13 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,12 @@ 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)
displayName: Build c-api
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
- 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'))
- 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
cp ./wasmer-c-api.tar.gz ./artifacts/$(./scripts/capi-name.sh)
displayName: Build c-api artifacts
- publish: $(System.DefaultWorkingDirectory)/artifacts
artifact: library-$(Agent.OS)

Expand Down
1 change: 1 addition & 0 deletions lib/runtime-c-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
repository = "https://github.com/wasmerio/wasmer"
Expand Down
25 changes: 25 additions & 0 deletions lib/runtime-c-api/distribution/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Wasmer C API

This is the [Wasmer WebAssembly Runtime](https://wasmer.io) shared library.
You can use it in any C/C++ projects.

This directory is structured like the following:
* `lib` is where the Wasmer shared library lives.
* `include` is where the Wasmer headers live

## Using it

If you want to compile a `c` file using Wasmer, you can do:

```bash
clang YOUR_FILE -Iinclude -lwasmer -Llib
```

> Note: append ` -rpath lib` if you are in macOS.

## Examples

You can check examples of how to use the Wasmer C API here:

https://docs.wasmer.io/integrations/c/examples
syrusakbary marked this conversation as resolved.
Show resolved Hide resolved

1 change: 0 additions & 1 deletion lib/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a wrong doc link, intended to be the runtime-c-api not for the runtime.

We are fixing it in this PR :)

license = "MIT"
authors = ["The Wasmer Engineering Team <[email protected]>"]
repository = "https://github.com/wasmerio/wasmer"
Expand Down
46 changes: 46 additions & 0 deletions scripts/capi-name.sh
Original file line number Diff line number Diff line change
@@ -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}"