brave / adblock-rust-ffi

An FFI crate to expose functionality from brave/adblock-rust
Mozilla Public License 2.0
47 stars 16 forks source link

How to migrate to Brave-Core CXX bindings #43

Open brandonroth opened 1 year ago

brandonroth commented 1 year ago

I inherited a project that uses these bindings and am attempting to update to a recent version of Adblock rust. It looks like this repo is no longer maintained and the functionality has been moved to brave-core https://github.com/brave/brave-core/pull/17368.

Im unfamiliar with this change and looking for advice on how to continue building the library bindings with the new approach. It feels like it's more tightly integrated into the brave-core project and I'm unsure how to get the build tools to output a header similar to lib.h in this repo. Ultimately the aim is to consume this in an android project through the JNI.

antonok-edm commented 1 year ago

There's been some major changes to the FFI in brave-core. Most recently it's been migrated to use cxx as of https://github.com/brave/brave-core/pull/17368. That is, the intermediate C code is autogenerated and not designed for human consumption, only as an implementation detail for the bindings to C++. This has been much more robust for our purposes, but probably won't be helpful for access through JNI.

My recommendation at this point would be to use something like the jni crate to make bindings directly from Rust code. Coincidentally, I created a supplemental tool for jni for unrelated reasons, although there are other options too.

I don't personally have the capacity to create official JNI bindings at this point, but I believe someone from Cốc Cốc was interested in JNI bindings too so there could definitely be a community around it. If you end up creating an open source repo for it I'm happy to provide some limited assistance and improve the adblock-rust docs as necessary.