Giter VIP home page Giter VIP logo

iroh-ffi's Introduction

iroh-ffi

Foreign Function Interface (FFI) bindings for Iroh

This repo defines Python & Swift bindings for iroh, which is written in Rust.

Published Packages:

Python Swift

Planned Support:

We're hoping to ship support for the following langauges in the future

  • Kotlin

Library Compilation

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.

Swift

Xcode and IOS

  • Run make_swift.sh.
  • Add IrohLib as a local package dependency under Frameworks, Libraries, and Embedded Content in the General settings 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 SystemConfiguration as a Framework.
  • Now you can just import the library in Swift with a standard import statement like import IrohLib.

Python

  • Install maturin for python development and packaging.
  • Install uniffi-bindgen with pip
  • maturin develop will build your package
  • maturin expects you to use virtualenv to manage your virtual environment

Building wheels

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

Example

  • Make sure the iroh is installed pip install iroh
  • Run with python3 main.py --help

Go

Mac

Building

Ensure you have golang & rust installed.

Install uniffi-bindgen-go:

cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.0+v0.25.0

Build the bindings:

./build_go.sh

Or build in release mode:

./build_go.sh release

Running

Once you've built the bindings, run go normally:

cd iroh-go
go test ./...

Linux

Ensure you have golang & rust installed.

Install uniffi-bindgen-go:

cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.0+v0.25.0

Build the bindings:

./build_go.sh

Or in release mode:

./build_go.sh release

Running

If you've used the build script to build the go bindings, it will also place the files in the correct locations.

Add the following to let go know where the dynamically linked files are located:

cd iroh-go
LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:.iroh/ffi" \
CGO_LDFLAGS="-liroh -L .iroh/ffi" \
go <actual go command to build or run>

Windows

Building

Ensure you have golang & rust installed.

Install uniffi-bindgen-go:

cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.0+v0.25.0

Build the bindings:

cargo build

Running

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.

Running

If you've used the build script to build the go bindings, it will also place the files in the correct locations.

Add the following to let go know where the dynamically linked files are located:

cd iroh-go
LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:.iroh/ffi" \
CGO_LDFLAGS="-liroh -L .iroh/ffi" \
go <actual go command to build or run>

Updating the bindings

Developers

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.

License

This project is licensed under either of

at your option.

Contribution

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.

iroh-ffi's People

Contributors

b5 avatar ramfox avatar dignifiedquire avatar arqu avatar flub avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.