Foreign Function Interface (FFI) bindings for Iroh
This repo defines Python & Swift bindings for iroh, which is written in Rust.
We're hoping to ship support for the following langauges in the future
- Kotlin
Running cargo build --release will produce a dynamic library and a static library.
For builds targeting older versions of MacOS, build with with: MACOSX_DEPLOYMENT_TARGET=10.7 && cargo build --target x86_64-apple-darwin --release.
- Run
make_swift.sh. - Add
IrohLibas a local package dependency underFrameworks, Libraries, and Embedded Contentin theGeneralsettings of your project. - Run
Build - Check that it is now listed under
Frameworks, Libraries, and Embedded Content, if not click+again and add it from the list. - Add
SystemConfigurationas a Framework. - Now you can just import the library in Swift with a standard import statement like
import IrohLib.
- Install
maturinfor python development and packaging. - Install
uniffi-bindgenwithpip maturin developwill build your package- maturin expects you to use
virtualenvto manage your virtual environment
Invoking maturin build will build a wheel in target/wheels. This
will likely only work on your specific platform. To build a portable
wheel for linux use:
docker run --rm -v $(pwd):/mnt -w /mnt quay.io/pypa/manylinux2014_x86_64 /mnt/build-wheel.sh
- Make sure the
irohis installedpip install iroh - Run with
python3 main.py --help
To make sure everything go needs to find is included the following is needed
LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:<binaries path>" \
CGO_LDFLAGS="-liroh -L <binaries path>" \
go <actual go command to build or run>
where <binaries path needs to be replaced with the absolute path to where the rust build output is. Eg /<path to repo>/iroh-ffi/target/debug in debug mode.
Install uniffi-bindgen-go:
cargo install uniffi-bindgen-go --git https://github.com/dignifiedquire/uniffi-bindgen-go --branch upgarde-uniffi-24
Check our our DEVELOPERS.md for guides on how to translate from the iroh rust API to the iroh FFI API, as well as how to set up testing for golang and python.
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.