-
Notifications
You must be signed in to change notification settings - Fork 212
java_library: output JNI headers generated by javac
#2525
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
java_library: output JNI headers generated by javac
#2525
Conversation
rules/java_rules.build_defs
Outdated
| javac_flags = CONFIG.JAVAC_TEST_FLAGS if test_only else CONFIG.JAVAC_FLAGS | ||
| javac_flags = '-g -encoding utf8 ' + javac_flags | ||
| javac_flags = '-h _jni -g -encoding utf8 ' + javac_flags |
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.
There doesn't seem to be any significant overhead in invoking the compiler with -h even when the JNI headers aren't needed (at least not compared with the time it takes to generate the class files).
rules/java_rules.build_defs
Outdated
| javac_cmd, | ||
| "find _jni -type f -name '*.h' | sort", |
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 should be safe because javac only ever outputs on stderr by default, so it shouldn't mess up the post-build output collection.
|
Thanks! Would you mind please opening this against https://github.com/please-build/java-rules instead? Those plugin repos are where future development of language-specific rules will happen. I have a couple of comments too but let's pick the conversation up there :) |
4377be5 to
e44cd56
Compare
Will do - I noticed a couple of CI failures in here that I didn't see over there, so I'll fix those, then force-push equivalent changes to please-build/java-rules#13. |
e44cd56 to
bc14739
Compare
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.
b2a6703 to
4d0a354
Compare
|
This issue has been automatically marked as stale because it has not had any recent activity in the past 90 days. It will be closed if no further activity occurs. If you require additional support, please reply to this message. Thank you for your contributions. |
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.