loro/crates/loro-ffi/README.md

48 lines
923 B
Markdown
Raw Normal View History

2023-01-28 11:59:37 +00:00
# loro-ffi
- `cargo build --release`
2023-01-28 11:59:37 +00:00
- move `libloro.a` and `loro_ffi.h` to directory `examples/lib`
2023-01-28 11:59:37 +00:00
- run
2023-01-28 11:59:37 +00:00
## C++
Read more: [cbindgen](https://github.com/eqrion/cbindgen)
2023-01-28 11:59:37 +00:00
```bash
g++ loro.cpp -Bstatic -framework Security -L. -lloro -o loro
```
2023-01-28 11:59:37 +00:00
## Go
Read more: [cgo](https://pkg.go.dev/cmd/cgo)
```bash
go run main.go
```
## [Python](../loro-python/)
## Java
Candidates:
2023-01-28 11:59:37 +00:00
- [JNR](https://github.com/jnr/jnr-ffi)
2023-01-28 11:59:37 +00:00
- [Panama](https://jdk.java.net/panama/) [blog](https://jornvernee.github.io/java/panama/rust/panama-ffi/2021/09/03/rust-panama-helloworld.html)
- [JNI](https://github.com/jni-rs/jni-rs)
### Panama
install panama-jdk and jextract
```bash
jextract -I /Library/Developer/CommandLineTools/usr/include/c++/v1 -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -d loro_java -t org.loro -l loro -- lib/loro_ffi.h
```
2023-01-28 11:59:37 +00:00
### JNR
move `libloro.dylib` into `jnr/app`
```bash
gradle run
```