-
Notifications
You must be signed in to change notification settings - Fork 5
java_library: output JNI headers generated by javac
#13
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
base: master
Are you sure you want to change the base?
java_library: output JNI headers generated by javac
#13
Conversation
|
(This is a mirror of thought-machine/please#2525.) |
The Java compiler outputs header files for Java sources that use the Java Native Interface (JNI), but there's currently no way for them to be consumed by the native-code components that depend on them, preventing them from being built. Provide the JNI headers as outputs of `java_library` when `cc_hdrs` is required. This allows native-code JNI components written in C/C++ to be built by including the `java_library` target as a dependency.
4f503e8 to
8565012
Compare
|
|
||
| def _jni_header_outputs(name, output): | ||
| for hdr_path in output: | ||
| if hdr_path != "": |
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.
This is just to guard against the command outputting \n when no headers are generated.
| }, | ||
| cmd = " && ".join([ | ||
| "mkdir -p _jni", | ||
| f"{javac_cmd} -h _jni >/dev/null 2>&1", |
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.
Silencing the output of javac here as a precaution because it's possible to instruct javac to output to stdout instead of stderr using a command line option (i.e. via javac_flags) - it's an edge case, but one that'll break this target if it's used. The main target will still show compilation errors for the class files.
The Java compiler outputs header files for Java sources that use the Java Native Interface (JNI), but there's currently no way for them to be consumed by the native-code components that depend on them, preventing them from being built.
Provide the JNI headers as outputs of
java_librarywhencc_hdrsis required. This allows native-code JNI components written in C/C++ to be built by including thejava_librarytarget as a dependency.