Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions about cross-language data exchange and Android support #138

Open
WhiredPlanck opened this issue Jan 30, 2024 · 2 comments
Open

Comments

@WhiredPlanck
Copy link

WhiredPlanck commented Jan 30, 2024

There is a C++ native library I used for my Android app and it's able to provide data in Cap'n Proto. Naturally I want to utilize the ability to speed up the data exchanging, especially get data from C++ to Java/Kotlin, because common JNI object converting is really slow (ranges in ~40,000 µs to ~120,000 µs). So is there anyway to properly deal with this, like some Gradle plugins or any else example?

@dwrensha
Copy link
Member

Yes, you should be able to compile your .capnp schemas with capnpc-java and then use the capnproto-java runtime library. The Addressbook example shows one way to set up a pom.xml to achieve this:

<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<target>
<mkdir dir="src/main/generated"/>
<exec executable="capnp" failonerror="true">
<arg value="compile"/>
<arg value="-I"/>
<arg value="../compiler/src/main/schema/"/>
<arg value="--src-prefix=src/main/schema/"/>
<arg value="-o../capnpc-java:src/main/generated"/>
<arg value="src/main/schema/addressbook.capnp"/>
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>

There is also this maven plugin (but I've never used it): https://github.com/expretio/capnp-maven-plugin

One annoying bit about all this is that capnpc-java is still written in C++: #111

@WhiredPlanck
Copy link
Author

@dwrensha No bad. I'll give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants