Browse Source

add document to use install_dora

pull/942/head
starlitxiling 10 months ago
parent
commit
70b70772e5
3 changed files with 27 additions and 10 deletions
  1. +2
    -2
      .github/workflows/libdora-release.yml
  2. +15
    -0
      examples/c++-dataflow/README.md
  3. +10
    -8
      install_libdora.sh

+ 2
- 2
.github/workflows/libdora-release.yml View File

@@ -111,11 +111,11 @@ jobs:
echo "Copying library files..."
case "$RUNNER_OS" in
"Linux" | "macOS")
cp target/${{ matrix.target }}/release/*.a dist/lib/ || echo "No libdora_node_api_c.a found"
cp target/${{ matrix.target }}/debug/*.a dist/lib/ || echo "No libdora_node_api_c.a found"
cp target/${{ matrix.target }}/debug/libdora_node_api_cxx.a dist/lib || echo "No libdora_node_api_cxx.a found"
;;
"Windows")
cp target/${{ matrix.target }}/release/*.lib dist/lib/ || echo "No dora_node_api_c found"
cp target/${{ matrix.target }}/debug/*.lib dist/lib/ || echo "No dora_node_api_c found"
cp target/${{ matrix.target }}/debug/libdora_node_api_cxx.a dist/lib || echo "No libdora_node_api_cxx.a found"
;;
esac


+ 15
- 0
examples/c++-dataflow/README.md View File

@@ -4,6 +4,21 @@ This example shows how to create dora operators and custom nodes with C++.

Dora does not provide a C++ API yet, but we can create adapters for either the C or Rust API. The `operator-rust-api` and `node-rust-api` folders implement an example operator and node based on dora's Rust API, using the `cxx` crate for bridging. The `operator-c-api` and `node-c-api` show how to create operators and nodes based on dora's C API. Both approaches work, so you can choose the API that fits your application better.

## Install Dora cpp library
You can use the following script to install the latest dora cpp api.
```bash
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dora-rs/dora/blob/main/install_libdora.sh | sudo -E bash
```
If you want to install other versions, you can download them from https://github.com/dora-rs/dora/tags.
If you have it installed, you can compile your Dora node with the C API like this:
~~~bash
clang++ -std=c++11 -I/usr/local/include/dora -o main main.cc -L/usr/local/lib -ldora_node_api_c
~~~
If you're writing a Dora node in C++ and need to use the `dora_node_api_cxx` binding (generated using Rust's `cxx` crate), use the following:
```bash
clang++ -std=c++17 -I/usr/local/include/dora main.cc -ldora_node_api_cxx -o main
```

## Compile and Run

To try it out, you can use the [`run.rs`](./run.rs) binary. It performs all required build steps and then starts the dataflow. Use the following command to run it: `cargo run --example cxx-dataflow`.


+ 10
- 8
install_libdora.sh View File

@@ -55,7 +55,7 @@ if ! command -v curl >/dev/null 2>&1; then
fi

if ! command -v jq >/dev/null 2>&1; then
echo "Error: 'jq' not found!" >&2
echo "Error: 'jq' not found! Please install it (e.g. 'brew install jq' or 'apt install jq')" >&2
exit 1
fi

@@ -64,7 +64,7 @@ PLATFORM="$(detect_platform)"
echo " => PLATFORM: $PLATFORM"

echo "==> Fetching latest Dora release info from GitHub..."
LATEST_JSON=$(curl -s https://api.github.com/repos/starlitxiling/dora-rerun/releases/latest)
LATEST_JSON=$(curl -s https://api.github.com/repos/dora-rs/dora/releases/latest)

if [ -z "$LATEST_JSON" ]; then
echo "Error: failed to fetch release info from GitHub!"
@@ -122,15 +122,17 @@ echo "==> Extracting $CHOSEN_ASSET_NAME ..."
tar -zxvf "$CHOSEN_ASSET_NAME"

FILE_TO_FIX="include/operator.h"
OLD_PATH="../operator-rust-api/operator.h"
NEW_PATH="operator.h"

if [ -f "$FILE_TO_FIX" ] && grep -q "$OLD_PATH" "$FILE_TO_FIX"; then
echo "==> Fixing include path in $FILE_TO_FIX ..."
if [ -f "$FILE_TO_FIX" ]; then
echo "==> Fixing include paths in $FILE_TO_FIX ..."
if sed --version 2>/dev/null | grep -q "GNU"; then
sed -i "s|$OLD_PATH|$NEW_PATH|g" "$FILE_TO_FIX"
sed -i 's|../operator-rust-api/operator.h|operator.h|g' "$FILE_TO_FIX"
sed -i 's|#include "../../../apis/c/operator/operator_api.h"|#include "operator_api.h"|' "$FILE_TO_FIX"
sed -i 's|#include "../build/dora-operator-api.h"|#include "dora-operator-api.h"|' "$FILE_TO_FIX"
else
sed -i "" "s|$OLD_PATH|$NEW_PATH|g" "$FILE_TO_FIX"
sed -i '' 's|../operator-rust-api/operator.h|operator.h|g' "$FILE_TO_FIX"
sed -i '' 's|#include "../../../apis/c/operator/operator_api.h"|#include "operator_api.h"|' "$FILE_TO_FIX"
sed -i '' 's|#include "../build/dora-operator-api.h"|#include "dora-operator-api.h"|' "$FILE_TO_FIX"
fi
fi



Loading…
Cancel
Save