-
Notifications
You must be signed in to change notification settings - Fork 614
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
[bazel] Add macros to build jni code and java tests #7693
base: 2027
Are you sure you want to change the base?
Conversation
Fork Sync: Update from parent repository
@@ -14,6 +14,7 @@ modifiableFileExclude { | |||
thirdparty/ | |||
\.patch$ | |||
gradlew | |||
BUILD.bazel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wpiformat was fighting buildifier when it comes to empty BUILD.bazel files
|
||
def wpilib_jni_java_library( | ||
name, | ||
native_libs = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
native_libs is unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now. I think it is fine to leave unused and populated in the files that use it
There are a couple other steps you can do to get the jar to automatically bring the jni.so library around with it that I have implemented in my mega-fork, but it requires that the code is built into a shared library which we are kicking down the road.
Fork Sync: Update 2027 branch
This adds the ability to build the JNI code, and a helper macro to build the code for java tests. This greatly increases the coverage of files built by bazel, and hits pretty much everything but the examples (covered by #7690), and things involving wpigui (that will be the next traunch of stuff after this lands and also gets up and running in the 2027 branch)
The JNI helper is slightly complicated because the policy in wpilib seems to be to include the auto-generated headers in the jni.cpp's. Luckily bazel gives you access to those generated files through a zip file. There are a couple other steps you can do to get the jar to automatically bring the jni.so library around with it that I have implemented in my mega-fork, but it requires that the code is built into a shared library which we are kicking down the road.
In addition, this creates a little helper function to easily build java unit tests. At the moment, because of the lack of shared libraries the tests are tempoarily getting built as a binary instead of a test so that they don't fail. In my mega-fork this macro also handles putting the shared libraries in a special spot so the test can find them, but again that will be a later problem to address.