Skip to content

Commit fa698b3

Browse files
authored
build JNI as workspace member (#88)
* put foo-jni at the same level as foo-ffi * create jni output directory * don't generate the rust JNI sources in the ci-script, just use the cargo build invocation to do it * refactor CI script traits to remove some complexity * allow certain things in the generated jni * add comment about the lints * merge the classes module * merge the enums * merge structs * merge interfaces * merge exceptions * merge primitives * get everything down to a single JNI module file * emit the jni code into OUT_DIR and use include! * build JNI library in cross matrix * remove bindings-aarch64 job and use cross matrix now that it can build Java * use cross for x64 linux * depend on documentation * swap 32-bit Linux for 64-bit * map the ARM_UNKNOWN_LINUX_GNUABIHF Rust triple to 'linux-arm' by default for .NET * support apple x64 in JNI * don't copy over libs that we won't attempt to load * use the existing platform definitions instead of strings * move this list of platforms to the ci-script since this is the only place it's used * run tests on macos
1 parent 5d0fe23 commit fa698b3

File tree

19 files changed

+440
-468
lines changed

19 files changed

+440
-468
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ jobs:
4444
path: |
4545
oo-bindgen/dependencies.json
4646
oo-bindgen/dependencies.txt
47-
# Run the unit tests on Windows and Linux
47+
# Run the unit tests on Windows, Linux, and MacOS
4848
test:
4949
strategy:
5050
fail-fast: false
5151
matrix:
5252
os:
5353
- ubuntu-latest
5454
- windows-latest
55+
- macos-latest
5556
rust:
5657
- stable
5758
- beta
@@ -104,8 +105,8 @@ jobs:
104105
with:
105106
command: clippy
106107
args: -- -D warnings
107-
# Build bindings on Linux x64 [64-bit Linux (kernel 2.6.32+, glibc 2.11+) (x86_64-unknown-linux-gnu)]
108-
bindings-linux:
108+
# Build documentation
109+
documentation:
109110
runs-on: ubuntu-latest
110111
steps:
111112
- name: Checkout
@@ -148,21 +149,6 @@ jobs:
148149
cp -a tests/bindings/dotnet/foo/doc ~/doc/dotnet
149150
cp -a tests/bindings/java/foo/target/apidocs ~/doc/java
150151
rm tests/bindings/c/generated/logo.png tests/bindings/c/generated/doxygen-awesome.css
151-
- name: Upload compiled FFI modules
152-
uses: actions/upload-artifact@v2
153-
with:
154-
name: ffi-modules
155-
path: tests/bindings/c/generated/x86_64-unknown-linux-gnu/lib
156-
- name: Upload C bindings
157-
uses: actions/upload-artifact@v2
158-
with:
159-
name: c-bindings
160-
path: tests/bindings/c/generated
161-
- name: Upload compiled Java bindings
162-
uses: actions/upload-artifact@v2
163-
with:
164-
name: ffi-modules
165-
path: tests/bindings/java/foo/src/main/resources
166152
- name: Upload documentation
167153
uses: actions/upload-artifact@v2
168154
with:
@@ -278,60 +264,6 @@ jobs:
278264
with:
279265
name: ffi-modules
280266
path: tests/bindings/java/foo/src/main/resources
281-
# Build bindings on Linux AArch64
282-
bindings-aarch64:
283-
runs-on: ubuntu-latest
284-
steps:
285-
- name: Checkout
286-
uses: actions/checkout@v2
287-
- name: Install Rust
288-
uses: actions-rs/toolchain@v1
289-
with:
290-
profile: minimal
291-
toolchain: stable
292-
target: aarch64-unknown-linux-gnu
293-
override: true
294-
- name: Caching
295-
uses: Swatinem/rust-cache@v1
296-
- name: Build
297-
uses: actions-rs/cargo@v1
298-
with:
299-
use-cross: true
300-
command: build
301-
args: --release --target aarch64-unknown-linux-gnu
302-
- name: C bindings
303-
uses: actions-rs/cargo@v1
304-
with:
305-
use-cross: true
306-
command: run
307-
args: --release --target aarch64-unknown-linux-gnu --bin foo-bindings -- --c --no-tests
308-
- name: .NET bindings
309-
uses: actions-rs/cargo@v1
310-
with:
311-
use-cross: true
312-
command: run
313-
args: --release --target aarch64-unknown-linux-gnu --bin foo-bindings -- --dotnet --no-tests
314-
- name: Java bindings
315-
uses: actions-rs/cargo@v1
316-
with:
317-
use-cross: true
318-
command: run
319-
args: --release --target aarch64-unknown-linux-gnu --bin foo-bindings -- --java --no-tests
320-
- name: Upload compiled FFI modules
321-
uses: actions/upload-artifact@v2
322-
with:
323-
name: ffi-modules
324-
path: tests/bindings/c/generated/aarch64-unknown-linux-gnu/lib
325-
- name: Upload C bindings
326-
uses: actions/upload-artifact@v2
327-
with:
328-
name: c-bindings
329-
path: tests/bindings/c/generated
330-
- name: Upload compiled Java bindings
331-
uses: actions/upload-artifact@v2
332-
with:
333-
name: ffi-modules
334-
path: tests/bindings/java/foo/src/main/resources
335267
# Cross-compilation for ARM devices and produce C bindings
336268
cross:
337269
strategy:
@@ -341,6 +273,8 @@ jobs:
341273
- arm-unknown-linux-gnueabi # ARMv6 Linux (kernel 3.2, glibc 2.17)
342274
- arm-unknown-linux-gnueabihf # ARMv6 Linux, hardfloat (kernel 3.2, glibc 2.17)
343275
- armv7-unknown-linux-gnueabihf # ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17)
276+
- aarch64-unknown-linux-gnu # ARM64 Linux (kernel 4.2, glibc 2.17+)
277+
- x86_64-unknown-linux-gnu # 64-bit Linux (kernel 2.6.32+, glibc 2.11+)
344278
runs-on: ubuntu-latest
345279
steps:
346280
- name: Checkout
@@ -364,19 +298,30 @@ jobs:
364298
use-cross: true
365299
command: run
366300
args: --release --target ${{ matrix.target }} --bin foo-bindings -- --c --no-tests
301+
- name: Java bindings
302+
uses: actions-rs/cargo@v1
303+
with:
304+
use-cross: true
305+
command: run
306+
args: --release --target ${{ matrix.target }} --bin foo-bindings -- --java --no-tests
367307
- name: Upload compiled FFI modules
368308
uses: actions/upload-artifact@v2
369309
with:
370310
name: ffi-modules
371311
path: tests/bindings/c/generated/${{ matrix.target }}/lib
312+
- name: Upload compiled Java bindings
313+
uses: actions/upload-artifact@v2
314+
with:
315+
name: ffi-modules
316+
path: tests/bindings/java/foo/src/main/resources
372317
- name: Upload C bindings
373318
uses: actions/upload-artifact@v2
374319
with:
375320
name: c-bindings
376321
path: tests/bindings/c/generated
377322
# Package all the generated bindings
378323
packaging:
379-
needs: [dependencies, bindings-linux, bindings-windows, bindings-macos, bindings-aarch64, cross]
324+
needs: [dependencies, documentation, bindings-windows, bindings-macos, cross]
380325
runs-on: ubuntu-latest
381326
steps:
382327
- name: Checkout

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ tests/bindings/dotnet/nupkg
2424
# Generated Java lib
2525
tests/bindings/java/.idea
2626
tests/bindings/java/foo
27-
tests/bindings/java/foo-jni
2827
tests/bindings/java/*/target
2928
tests/bindings/java/**/*.iml
29+
30+
# generated jni code
31+
tests/foo-ffi-java/src/generated

Cargo.lock

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ members = [
1212
"tests/foo-schema",
1313
"tests/foo-ffi",
1414
"tests/foo-bindings",
15+
"tests/foo-ffi-java",
1516
]

0 commit comments

Comments
 (0)