-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
926cee0
commit 2ede8bc
Showing
35 changed files
with
10,751 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
name: Java Bindings | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
description: 'The reference (branch/tag/commit) to checkout' | ||
required: false | ||
release-type: | ||
type: choice | ||
required: false | ||
default: 'none' | ||
description: 'Indicates whether we want to make a release and if which one' | ||
options: | ||
- release | ||
- none | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && 'manual' || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
name: Build - ${{ matrix.target }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- target: x86_64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
- target: aarch64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
- target: aarch64-apple-darwin | ||
os: ubuntu-latest | ||
- target: x86_64-apple-darwin | ||
os: ubuntu-latest | ||
- target: x86_64-pc-windows-gnu | ||
os: windows-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref || github.ref }} | ||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: 1.80.0 | ||
targets: ${{ matrix.target }} | ||
- name: Install cargo-binstall | ||
uses: taiki-e/install-action@cargo-binstall | ||
- name: Install Zig | ||
uses: goto-bus-stop/setup-zig@v2 | ||
with: | ||
version: 0.10.1 | ||
- name: Install cargo-zigbuild | ||
run: cargo binstall --no-confirm cargo-zigbuild | ||
- name: Run compile script | ||
run: | | ||
chmod +x .github/scripts/compile_all_targets_java.sh | ||
.github/scripts/compile_all_targets_java.sh ${{ matrix.target }} | ||
shell: bash | ||
- name: Upload dynamic libs | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.target }} | ||
path: bindings/java/java_code/src/main/resources/${{ matrix.target }} | ||
|
||
test: | ||
name: Test - ${{ matrix.target }} | ||
needs: build | ||
strategy: | ||
matrix: | ||
include: | ||
- target: x86_64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
- target: aarch64-unknown-linux-gnu | ||
os: linux-arm64 | ||
- target: x86_64-apple-darwin | ||
os: macos-13 | ||
- target: aarch64-apple-darwin | ||
os: macos-14 | ||
- target: x86_64-pc-windows-gnu | ||
os: windows-latest | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref || github.ref }} | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ matrix.target }} | ||
path: bindings/java/java_code/src/main/resources/${{ matrix.target }} | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
- name: Build with Gradle (no tests) | ||
run: ./gradlew build -x test | ||
working-directory: bindings/java/java_code | ||
- name: Run Gradle tests | ||
run: ./gradlew test --info --stacktrace --scan | ||
working-directory: bindings/java/java_code | ||
|
||
publish: | ||
name: Publish | ||
if: ${{ inputs.release-type != 'none' && github.event_name == 'workflow_dispatch' }} | ||
needs: [build, test] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref || github.ref }} | ||
|
||
- name: Download all artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: bindings/java/java_code/src/main/resources | ||
|
||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@v6 | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY_JAVA_PUBLISHING }} | ||
passphrase: ${{ secrets.GPG_PASSPHRASE_JAVA_PUBLISHING }} | ||
|
||
- name: Publish Java package to Maven Central | ||
working-directory: bindings/java/java_code | ||
env: | ||
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.CENTRAL_PORTAL_TOKEN_USERNAME }} | ||
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.CENTRAL_PORTAL_TOKEN_PASSWORD }} | ||
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE_JAVA_PUBLISHING }} | ||
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY_JAVA_PUBLISHING }} | ||
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY_JAVA_PUBLISHING }} | ||
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
./gradlew clean createJReleaserOutputDir jreleaserConfig build publish jreleaserFullRelease --stacktrace --info | ||
- name: JReleaser output | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: jreleaser-logs | ||
path: | | ||
bindings/java/java_code/build/jreleaser/trace.log | ||
bindings/java/java_code/build/jreleaser/output.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,19 @@ members = [ | |
"banderwagon", | ||
"ffi_interface", | ||
"bindings/c", | ||
"bindings/java/rust_code", | ||
"bindings/csharp/rust_code", | ||
] | ||
resolver = "2" | ||
|
||
[workspace.package] | ||
authors = ["Kevaundray Wedderburn <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT" | ||
version = "0.0.1" | ||
rust-version = "1.70" | ||
repository = "https://github.com/crate-crypto/rust-verkle" | ||
|
||
[profile.bench] | ||
debug = true | ||
opt-level = 3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Java | ||
|
||
## Overview | ||
|
||
This directory contains the bindings for the java gradle project. There are two sub directories, `java_code` and `rust_code`. | ||
|
||
- `rust_code` contains the FFI code that will be called by the Java code. | ||
|
||
It also contains code in the `build.rs` file that generates a C file which will indicate what the function signatures for these rust methods should look like based on the Java methods defined in `java_code`. | ||
|
||
- `java_code` contains the java code that will interface with the compiled rust code in `rust_code` and expose an API allowing java packages to execute DAS related methods. | ||
|
||
## Building | ||
|
||
There are two steps to building: | ||
|
||
- Building the dynamic library | ||
- Building the java code | ||
|
||
### Building the dynamic library | ||
|
||
These easiest way to build the dynamic library, is to call `scripts/compile.sh`. This is located at the root of the directory. Calling this script will compile the necessary code for your platform and copy the dynamic library into the relevant directory in `java_code`. This is the `resources` folder. | ||
|
||
Once the script has been called, one can view the code in `java_code` as being self-contained. | ||
|
||
### Building the Java code | ||
|
||
Once the dynamic library has been built and copied into `java_code`, the instructions to build the java codebase follows a regular gradle project: | ||
|
||
``` | ||
./gradlew build | ||
``` | ||
|
||
## Testing | ||
|
||
Given that we have successfully built the dynamic lib. To test, we can run: | ||
|
||
``` | ||
/gradlew test | ||
``` | ||
|
||
## Publishing | ||
|
||
The `.scripts/compile.sh` script will compile for your particular platform, however the released package will contain | ||
dynamic libraries for all relevant platforms, making the `JAR` file _universal_ in theory. | ||
|
||
## Supported Platforms | ||
|
||
We currently support: | ||
|
||
- Windows x86_64 | ||
- Linux (x86_64 and arm64) | ||
- Mac (x86_64 and arm64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
**.class | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
Oops, something went wrong.