Reuse doc file for capi docs

This commit is contained in:
Syrus 2020-02-20 11:24:54 -08:00
parent 1d9741b856
commit aa0f33203c
3 changed files with 19 additions and 66 deletions

View File

@ -318,7 +318,7 @@ endif
find target/release/build -name 'wasmer.h*' -exec cp {} ./capi/include ';' find target/release/build -name 'wasmer.h*' -exec cp {} ./capi/include ';'
cp LICENSE ./capi/LICENSE cp LICENSE ./capi/LICENSE
cp lib/runtime-c-api/distribution/* ./capi/ 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 tar -C ./capi -zcvf wasmer-c-api.tar.gz lib include README.md LICENSE
# For installing the contents locally # For installing the contents locally
@ -333,9 +333,11 @@ publish-release:
dep-graph: 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 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:
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 .. cd lib/runtime-c-api/ && doxygen doxyfile && cd ..
docs: docs-capi
cargo doc --features=backend-singlepass,backend-cranelift,backend-llvm,docs,wasi,managed --workspace --document-private-items --no-deps
mkdir -p api-docs mkdir -p api-docs
mkdir -p api-docs/c mkdir -p api-docs/c
cp -R target/doc api-docs/crates cp -R target/doc api-docs/crates

View File

@ -1,32 +0,0 @@
# 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
## Documentation
The API documentation for the Wasmer Runtime C API can be found here:
https://wasmerio.github.io/wasmer/c/runtime-c-api/
## Usage
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

View File

@ -1,12 +1,9 @@
# Wasmer Runtime C API # Wasmer Runtime C API
[Wasmer] is a standalone [WebAssembly] runtime, aiming to be fully [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/).
compatible with WASI, Emscripten, Rust and Go. [Learn
more](https://github.com/wasmerio/wasmer).
The `wasmer-runtime-c-api` crate exposes a C and a C++ API to interact The Wasmer Runtime C API exposes a C and a C++ API to interact
with the Wasmer runtime. This document is the index of its with the Wasmer Runtime, so you can use WebAssembly anywhere.
auto-generated documentation.
[Wasmer]: https://github.com/wasmerio/wasmer [Wasmer]: https://github.com/wasmerio/wasmer
[WebAssembly]: https://webassembly.org/ [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 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++ designed to work hand-in-hand with its shared library. The C and C++
header files, namely [`wasmer.h`] and `wasmer.hh` are documented header files, namely [`wasmer.h`][wasmer_h] and `wasmer.hh` are documented
here. Their source code can be found in the source tree of this in the docs.
crate. They are automatically generated, and always up-to-date in this
repository. The C and C++ header files along with the runtime shared 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 libraries (`.so`, `.dylib`, `.dll`) can also be downloaded in the
Wasmer [release page]. Wasmer [release page].
[`wasmer.h`]: ./wasmer_8h.html
[release page]: https://github.com/wasmerio/wasmer/releases [release page]: https://github.com/wasmerio/wasmer/releases
Here is a simple example to use the C API: Here is a simple example to use the C API:
```c ```c
#include <stdio.h> #include <stdio.h>
#include "../wasmer.h" #include "wasmer.h"
#include <assert.h> #include <assert.h>
#include <stdint.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 You can check more examples of how to use the Wasmer C API here:
changes or compile with non-default features, please ensure you
rebuild in release mode for the tests to see the changes.
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 # License
@ -118,7 +102,6 @@ Wasmer is primarily distributed under the terms of the [MIT
license][mit-license] ([LICENSE][license]). license][mit-license] ([LICENSE][license]).
[wasmer_h]: ./wasmer.h [wasmer_h]: https://wasmerio.github.io/wasmer/c/runtime-c-api/wasmer_8h.html
[wasmer_hh]: ./wasmer.hh
[mit-license]: http://opensource.org/licenses/MIT [mit-license]: http://opensource.org/licenses/MIT
[license]: https://github.com/wasmerio/wasmer/blob/master/LICENSE [license]: https://github.com/wasmerio/wasmer/blob/master/LICENSE