From aa0f33203ce4c44b980f5c7c1d92eb651fde25a0 Mon Sep 17 00:00:00 2001 From: Syrus Date: Thu, 20 Feb 2020 11:24:54 -0800 Subject: [PATCH] Reuse doc file for capi docs --- Makefile | 8 +++-- lib/runtime-c-api/distribution/README.md | 32 ----------------- lib/runtime-c-api/doc/index.md | 45 ++++++++---------------- 3 files changed, 19 insertions(+), 66 deletions(-) delete mode 100644 lib/runtime-c-api/distribution/README.md diff --git a/Makefile b/Makefile index a8df5cd28..9692c4178 100644 --- a/Makefile +++ b/Makefile @@ -318,7 +318,7 @@ endif find target/release/build -name 'wasmer.h*' -exec cp {} ./capi/include ';' 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 # For installing the contents locally @@ -333,9 +333,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: - cargo doc --features=backend-singlepass,backend-cranelift,backend-llvm,docs,wasi,managed --workspace --document-private-items --no-deps +docs-capi: 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/c cp -R target/doc api-docs/crates diff --git a/lib/runtime-c-api/distribution/README.md b/lib/runtime-c-api/distribution/README.md deleted file mode 100644 index bb1689ee0..000000000 --- a/lib/runtime-c-api/distribution/README.md +++ /dev/null @@ -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 - diff --git a/lib/runtime-c-api/doc/index.md b/lib/runtime-c-api/doc/index.md index 84b08e56a..ebd5dadb7 100644 --- a/lib/runtime-c-api/doc/index.md +++ b/lib/runtime-c-api/doc/index.md @@ -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 -#include "../wasmer.h" +#include "wasmer.h" #include #include @@ -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