Skip to content

Commit

Permalink
Improved CI by building the package
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Jun 5, 2020
1 parent 7455f10 commit fc27d75
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 77 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ jobs:
- run: make test
- name: Build and Test C API
run: |
make capi
make build-capi
make test-capi-cranelift
if: matrix.os != 'windows-latest'
- name: Build C API on Windows
run: make capi
run: make build-capi
if: matrix.os == 'windows-latest'
- name: Build Wasmer binary
run: |
make build-wasmer
# TODO: build wapm
# make build-wapm
make package
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
.DS_Store
.idea
**/.vscode
install/
capi/
api-docs/
api-docs-repo/
/.cargo_home/
/package/
/wapm-cli/

# Generated by tests on Android
/avd
Expand Down
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

129 changes: 104 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,51 +55,130 @@ compiler_features_spaced := $(foreach compiler,$(compilers),$(compiler))
compiler_features := --features "$(compiler_features_spaced)"


tests-spec-update-testsuite:
git subtree pull --prefix tests/wast/spec https://github.com/WebAssembly/testsuite.git master --squash
############
# Building #
############

test:
cargo test --release $(compiler_features)

release:
build-wasmer:
cargo build --release $(compiler_features)

doc:
cargo doc --all-features --document-private-items
WAPM_VERSION = v0.5.0
build-wapm:
git clone --branch $(WAPM_VERSION) https://github.com/wasmerio/wapm-cli.git
cargo build --release --manifest-path wapm-cli/Cargo.toml --features "telemetry update-notifications"

doc-local:
cargo doc --all-features --document-private-items --no-deps
build-docs:
cargo doc --release --all-features --document-private-items --no-deps

RUSTFLAGS := "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects" # TODO: add `-D missing-docs`
lint:
cargo fmt --all -- --check
RUSTFLAGS=${RUSTFLAGS} cargo clippy $(compiler_features)
build-docs-capi:
cd lib/c-api/ && doxygen doxyfile

# We use cranelift as the default backend for the capi for now
build-capi: build-capi-cranelift

capi-singlepass:
build-capi-singlepass:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features singlepass-backend,wasi

capi-cranelift:
build-capi-cranelift:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features cranelift-backend,wasi

capi-llvm:
build-capi-llvm:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features llvm-backend,wasi

# We use cranelift as the default backend for the capi for now
capi: capi-cranelift

test-capi-singlepass: capi-singlepass
###########
# Testing #
###########

test:
cargo test --release $(compiler_features)

test-capi-singlepass: build-capi-singlepass
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features singlepass-backend,wasi
--no-default-features --features singlepass,wasi

test-capi-cranelift: capi-cranelift
test-capi-cranelift: build-capi-cranelift
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features cranelift-backend,wasi -- --nocapture --test-threads=1
--no-default-features --features cranelift,wasi -- --nocapture --test-threads=1

test-capi-llvm: capi-llvm
test-capi-llvm: build-capi-llvm
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features llvm-backend,wasi
--no-default-features --features llvm,wasi

test-capi: test-capi-singlepass test-capi-cranelift test-capi-llvm test-capi-emscripten

#############
# Packaging #
#############

package-wasmer:
# This command doesn't build the binary, just packages it
mkdir -p ./package/bin
cp ./target/release/wasmer ./package/bin/

# Comment WAPM for now to speedup release process
# cp ./wapm-cli/target/release/wapm ./package/bin/
# # Create the wax binary as symlink to wapm
# cd ./package/bin/ && ln -sf wapm wax && chmod +x wax

package-capi:
# This command doesn't build the C-API, just packages it
mkdir -p ./package/
mkdir -p ./package/include
mkdir -p ./package/lib
ifeq ($(OS), Windows_NT)
cp target/release/wasmer_c_api.dll ./package/lib/wasmer.dll
cp target/release/wasmer_c_api.lib ./package/lib/wasmer.lib
else
ifeq ($(UNAME_S), Darwin)
cp target/release/libwasmer_c_api.dylib ./package/lib/libwasmer.dylib
cp target/release/libwasmer_c_api.a ./package/lib/libwasmer.a
# Fix the rpath for the dylib
install_name_tool -id "@rpath/libwasmer.dylib" ./package/lib/libwasmer.dylib
else
cp target/release/libwasmer_c_api.so ./package/lib/libwasmer.so
cp target/release/libwasmer_c_api.a ./package/lib/libwasmer.a
endif
endif
find target/release/build -name 'wasmer.h*' -exec cp {} ./package/include ';'
cp lib/c-api/doc/index.md ./package/include/README.md

package-docs: build-docs build-docs-capi
mkdir -p package/docs
mkdir -p package/docs/c
cp -R target/doc package/docs/crates
cp -R lib/c-api/doc/html package/docs/c-api
echo '<!-- Build $(SOURCE_VERSION) --><meta http-equiv="refresh" content="0; url=rust/wasmer_runtime/index.html">' > package/docs/index.html
echo '<!-- Build $(SOURCE_VERSION) --><meta http-equiv="refresh" content="0; url=wasmer_runtime/index.html">' > package/docs/crates/index.html

package: package-wasmer package-capi
cp LICENSE ./package/LICENSE
cp ATTRIBUTIONS.md ./package/ATTRIBUTIONS
tar -C ./package -zcvf wasmer.tar.gz bin lib include LICENSE ATTRIBUTIONS


################
# Miscelaneous #
################

# Updates the spectests from the repo
update-testsuite:
git subtree pull --prefix tests/wast/spec https://github.com/WebAssembly/testsuite.git master --squash

RUSTFLAGS := "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects" # TODO: add `-D missing-docs`
lint:
cargo fmt --all -- --check
RUSTFLAGS=${RUSTFLAGS} cargo clippy $(compiler_features)

install-local: package
tar -C ~/.wasmer -zxvf wasmer.tar.gz

publish-docs:
git clone -b "gh-pages" --depth=1 https://wasmerbot:$(GITHUB_DOCS_TOKEN)@github.com/wasmerio/wasmer.git api-docs-repo
cp -R package/docs/* api-docs-repo/
cd api-docs-repo && git add index.html crates/* c-api/*
cd api-docs-repo && (git diff-index --quiet HEAD || git commit -m "Publishing GitHub Pages")
# cd api-docs-repo && git push origin gh-pages
14 changes: 9 additions & 5 deletions lib/c-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "wasmer-runtime-c-api"
name = "wasmer-c-api"
version = "0.16.2"
description = "Wasmer C API library"
documentation = "https://wasmerio.github.io/wasmer/c/runtime-c-api/"
documentation = "https://wasmerio.github.io/wasmer/c-api/"
license = "MIT"
authors = ["The Wasmer Engineering Team <[email protected]>"]
repository = "https://github.com/wasmerio/wasmer"
Expand Down Expand Up @@ -49,13 +49,17 @@ optional = true

[features]
default = ["cranelift-backend", "wasi"]
singlepass-backend = ["wasmer/singlepass"]
cranelift-backend = ["wasmer/cranelift"]
llvm-backend = ["wasmer/llvm"]
singlepass = ["wasmer/singlepass"]
cranelift = ["wasmer/cranelift"]
llvm = ["wasmer/llvm"]
wasi = ["wasmer-wasi"]
#emscripten = ["wasmer-emscripten"]
# used to avoid generating standard Wasm C API types in our header files
ignore-wasm-c-api = []
# This is for compatibility for old usage
singlepass-backend = ["singlepass"]
cranelift-backend = ["cranelift"]
llvm-backend = ["llvm"]

[build-dependencies]
cbindgen = { git = "https://github.com/eqrion/cbindgen", version = "0.14" }
40 changes: 28 additions & 12 deletions lib/c-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,48 @@
<a href="https://spectrum.chat/wasmer">
<img src="https://withspectrum.github.io/badge/badge.svg" alt="Join the Wasmer Community">
</a>
<a href="https://crates.io/crates/wasmer-runtime-c-api">
<img src="https://img.shields.io/crates/d/wasmer-runtime-c-api.svg?style=flat-square" alt="Number of downloads from crates.io">
<a href="https://crates.io/crates/wasmer-c-api">
<img src="https://img.shields.io/crates/d/wasmer-c-api.svg?style=flat-square" alt="Number of downloads from crates.io">
</a>
<a href="https://wasmerio.github.io/wasmer/c/runtime-c-api/">
<a href="https://wasmerio.github.io/wasmer/c-api/">
<img src="https://img.shields.io/badge/Docs-Wasmer%20C%20API-blue?style=flat-square" alt="Wasmer C API Documentation">
</a>
</p>

# Wasmer Runtime C API

Wasmer is a standalone JIT WebAssembly runtime, aiming to be fully
Wasmer is a standalone WebAssembly runtime, aiming to be fully
compatible with WASI, Emscripten, Rust and Go. [Learn
more](https://github.com/wasmerio/wasmer).

This crate exposes a C and a C++ API for the Wasmer runtime.

# Usage

The C and C++ header files can be found in the source tree of this
crate, respectively [`wasmer.h`][wasmer_h] and
[`wasmer.hh`][wasmer_hh]. They are automatically generated, and always
up-to-date in this repository.
The runtime shared library (so, dll, dylib) can also be downloaded in Wasmer [release page](https://github.com/wasmerio/wasmer/releases).
Upon installing Wasmer, the shared object files and the headers will
be automatically available inside the Wasmer folder.

You can find the full C API documentation here:
https://wasmerio.github.io/wasmer/c/runtime-c-api/
The C ([`wasmer.h`][wasmer_h]) and C++ ([`wasmer.hh`][wasmer_hh]) header
files can be found in the `include` directory where Wasmer is installed and also via:

```bash
wasmer config --includedir
```

The runtime shared libraries (`.so`, `.dylib`, `.dll`) can be found in the
`lib` directory where Wasmer is installed and also via:

```bash
wasmer config --libdir
```

You can also download the libraries or header files directly from the Wasmer
[release page].

[release page]: https://github.com/wasmerio/wasmer/releases

The full C API documentation can be found here:
https://wasmerio.github.io/wasmer/c-api/

Here is a simple example to use the C API:

Expand Down Expand Up @@ -118,7 +134,7 @@ The tests can be run via `cargo test`, such as:
$ cargo test --release -- --nocapture
```

To run tests manually, enter the `lib/runtime-c-api/tests` directory
To run tests manually, enter the `lib/c-api/tests` directory
and run the following commands:

```sh
Expand Down
32 changes: 22 additions & 10 deletions lib/c-api/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,31 @@ with the Wasmer Runtime, so you can use WebAssembly anywhere.

# Usage

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`][wasmer_h] and `wasmer.hh` are documented
in the docs.
Upon installing Wasmer, the shared object files and the headers will
be automatically available inside the Wasmer folder.

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].
The C ([`wasmer.h`][wasmer_h]) and C++ ([`wasmer.hh`][wasmer_hh]) header
files can be found in the `include` directory where Wasmer is installed and also via:

```bash
wasmer config --includedir
```

The runtime shared libraries (`.so`, `.dylib`, `.dll`) can be found in the
`lib` directory where Wasmer is installed and also via:

```bash
wasmer config --libdir
```

You can also download the libraries or header files directly from the Wasmer
[release page].

[release page]: https://github.com/wasmerio/wasmer/releases

The full C API documentation can be found here:
https://wasmerio.github.io/wasmer/c-api/

Here is a simple example to use the C API:

```c
Expand Down Expand Up @@ -102,6 +114,6 @@ Wasmer is primarily distributed under the terms of the [MIT
license][mit-license] ([LICENSE][license]).


[wasmer_h]: https://wasmerio.github.io/wasmer/c/runtime-c-api/wasmer_8h.html
[wasmer_h]: https://wasmerio.github.io/wasmer/c-api/wasmer_8h.html
[mit-license]: http://opensource.org/licenses/MIT
[license]: https://github.com/wasmerio/wasmer/blob/master/LICENSE
2 changes: 1 addition & 1 deletion lib/c-api/doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "wasmer-runtime-c-api"
PROJECT_NAME = "wasmer-c-api"
PROJECT_NUMBER =
PROJECT_BRIEF =
PROJECT_LOGO = ../../assets/logo.png
Expand Down
Loading

0 comments on commit fc27d75

Please sign in to comment.