After implementing a much more extensive Java native module than what currently exists in the tests, I found shortcomings. 1. You need to be able to pass multiple Java files. 2. Meson needs more information to better track the generated native headers. 3. Meson wasn't tracking the header files generated from inner classes. This new function should fix all the issues the old function had with room to grow should more functionality need to be added. What I implemented here in this new function is essentially what I have done in the Heterogeneous-Memory Storage Engine's Java bindings.pull/10044/head
parent
7702d46dd1
commit
18147b91ff
5 changed files with 127 additions and 6 deletions
@ -0,0 +1,34 @@ |
||||
## Deprecated `java.generate_native_header()` in favor of the new `java.generate_native_headers()` |
||||
|
||||
`java.generate_native_header()` was only useful for the most basic of |
||||
situations. It didn't take into account that in order to generate native |
||||
headers, you had to have all the referenced Java files. It also didn't take |
||||
into account inner classes. Do not use this function from `0.62.0` onward. |
||||
|
||||
`java.generate_native_headers()` has been added as a replacement which should account for the previous function's shortcomings. |
||||
|
||||
```java |
||||
// Outer.java |
||||
|
||||
package com.mesonbuild; |
||||
|
||||
public class Outer { |
||||
private static native void outer(); |
||||
|
||||
public static class Inner { |
||||
private static native void inner(); |
||||
} |
||||
} |
||||
``` |
||||
|
||||
With the above file, an invocation would look like the following: |
||||
|
||||
```meson |
||||
java = import('java') |
||||
|
||||
native_headers = java.generate_native_headers( |
||||
'Outer.java', |
||||
package: 'com.mesonbuild', |
||||
classes: ['Outer', 'Outer.Inner'] |
||||
) |
||||
``` |
@ -1,2 +1,3 @@ |
||||
native_header = javamod.generate_native_header('JdkTest.java', package: 'com.mesonbuild') |
||||
native_headers = javamod.generate_native_headers( |
||||
'JdkTest.java', package: 'com.mesonbuild', classes: ['JdkTest']) |
||||
native_header_includes = include_directories('.') |
||||
|
Loading…
Reference in new issue