This directory contains the C++ Foreign Function Interface (FFI) code required to communicate with the underlying Rust "Ark" project.
The primary goal of this code is to provide a C++-callable API that bridges the gap between the native mobile environment (iOS/Android) and the Rust core logic within the "Ark" project. This allows higher-level applications, such as a React Native application, to interact with the Rust functionalities through a C++ layer.
The C++ code in this directory typically involves:
- Defining C-compatible function signatures: These functions will be exposed from the Rust side (using
#[no_mangle]andextern "C") and called from this C++ code. - Handling data marshalling: Converting data types between C++ and Rust (e.g., strings, numbers, complex objects). This might involve serialization/deserialization or direct memory manipulation.
- Exposing a C++ API: Providing a clean C++ interface that encapsulates the FFI calls, making it easier for other C++ code (like the React Native Nitro module) to consume.
The code in this directory is compiled into a static library (e.g., .a for iOS, .so for Android). This static library is then linked into the main mobile application, allowing the React Native Nitro module to call its functions.
Refer to the main project's build system for specific compilation instructions for different platforms.
- Ark (Rust Project): This C++ code directly calls functions exposed by the Ark Rust project.
- React Native Nitro Module (
react-native-nitro-ark/cpp): The C++ code in the React Native module utilizes the API provided by thisbark-cpplayer to execute Rust logic.
- Install nix
- Install direnv
- Run
direnv allowto allow direnv to load the nix environment. - For iOS you will need to install XCode.
- For Android you will need to install Android Studio.
- Android - Run the
build-android.shscript to build the Android binary. - iOS - Run the
build-ios.shscript to build the iOS binary. - Mac - You can also run the main.rs file locally using
cargo run --bin bark.