mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-25 02:12:13 +00:00
Improved Wasmer C API artifacts
This commit is contained in:
parent
d93d878aa4
commit
40fb54c58f
27
Makefile
27
Makefile
@ -294,6 +294,33 @@ build-install:
|
|||||||
cp ./target/release/wasmer ./install/bin/
|
cp ./target/release/wasmer ./install/bin/
|
||||||
tar -C ./install -zcvf wasmer.tar.gz bin/wapm bin/wasmer
|
tar -C ./install -zcvf wasmer.tar.gz bin/wapm bin/wasmer
|
||||||
|
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
|
build-capi:
|
||||||
|
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
|
||||||
|
|
||||||
|
find target/release/build -name 'wasmer.h*' -exec cp {} ./capi/include ';'
|
||||||
|
cp LICENSE ./capi/LICENSE
|
||||||
|
cp lib/runtime-c-api/distribution/* ./capi/
|
||||||
|
tar -C ./capi -zcvf wasmer-c-api.tar.gz lib include README.md LICENSE
|
||||||
|
|
||||||
# For installing the contents locally
|
# For installing the contents locally
|
||||||
do-install:
|
do-install:
|
||||||
tar -C ~/.wasmer -zxvf wasmer.tar.gz
|
tar -C ~/.wasmer -zxvf wasmer.tar.gz
|
||||||
|
@ -213,21 +213,12 @@ jobs:
|
|||||||
condition: and(succeeded(), not(eq(variables['Agent.OS'], 'Windows_NT')))
|
condition: and(succeeded(), not(eq(variables['Agent.OS'], 'Windows_NT')))
|
||||||
- bash: |
|
- bash: |
|
||||||
make capi
|
make capi
|
||||||
cp target/release/libwasmer_runtime_c_api.so ./artifacts
|
displayName: Build c-api
|
||||||
find target/release/build -name 'wasmer.h*' -exec cp {} ./artifacts ';'
|
|
||||||
displayName: Build c-api (Linux)
|
|
||||||
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
|
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
|
||||||
- bash: |
|
- bash: |
|
||||||
make capi
|
make build-capi
|
||||||
install_name_tool -id "@rpath/libwasmer_runtime_c_api.dylib" target/release/libwasmer_runtime_c_api.dylib
|
cp ./wasmer-c-api.tar.gz ./artifacts/$(./scripts/capi-name.sh)
|
||||||
cp target/release/libwasmer_runtime_c_api.dylib ./artifacts
|
displayName: Build c-api 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'))
|
|
||||||
- publish: $(System.DefaultWorkingDirectory)/artifacts
|
- publish: $(System.DefaultWorkingDirectory)/artifacts
|
||||||
artifact: library-$(Agent.OS)
|
artifact: library-$(Agent.OS)
|
||||||
|
|
||||||
|
25
lib/runtime-c-api/distribution/README.md
Normal file
25
lib/runtime-c-api/distribution/README.md
Normal file
@ -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
|
||||||
|
|
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}"
|
Loading…
x
Reference in New Issue
Block a user