Skip to content

Commit

Permalink
Merge 8cbd485 into 8d12782
Browse files Browse the repository at this point in the history
  • Loading branch information
tareknaser authored Jun 24, 2024
2 parents 8d12782 + 8cbd485 commit d54ec31
Show file tree
Hide file tree
Showing 21 changed files with 670 additions and 165 deletions.
42 changes: 27 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ jobs:
- name: Install JDK
uses: actions/setup-java@v4.2.1
with:
distribution: 'temurin'
java-version: '22'
distribution: "temurin"
java-version: "22"

- name: Set up Gradle
uses: gradle/gradle-build-action@v3

- name: Java tests
run: |
cd fs-storage
make test-linux
run: gradle test
working-directory: ./java

windows:
name: Test on Windows
Expand All @@ -62,19 +64,24 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Build Release
run: cargo build --verbose --release

- name: Run tests
run: cargo test --workspace --verbose

- name: Install JDK
uses: actions/setup-java@v4.2.1
with:
distribution: 'temurin'
java-version: '22'
distribution: "temurin"
java-version: "22"

- name: Set up Gradle
uses: gradle/gradle-build-action@v3

- name: Java tests
run: |
cd fs-storage
make test-windows
run: gradle test
working-directory: ./java

mac-intel:
name: Test on macOS Intel
Expand All @@ -86,16 +93,21 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Build Release
run: cargo build --verbose --release

- name: Run tests
run: cargo test --workspace --verbose

- name: Install JDK
uses: actions/setup-java@v4.2.1
with:
distribution: 'temurin'
java-version: '22'
distribution: "temurin"
java-version: "22"

- name: Set up Gradle
uses: gradle/gradle-build-action@v3

- name: Java tests
run: |
cd fs-storage
make test-mac
run: gradle test
working-directory: ./java
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Development docs will come sometime.
**The Concept of the Framework**

The framework is supposed to help in solving the following problems:

1. Management of user data, stored as simple files on the disk, as well as various kinds of metadata: tags, scores, arbitrary properties like movie title or description. Such a metadata is persisted to filesystem for easier sync, backup and migration by any 3rd-party tool.
2. Sync of both user data and metadata, across all user devices in P2P fashion. Cache syncing might be implemented later, too.
3. Version tracking for user data: not only text-files, but also images, videos etc.
Expand Down Expand Up @@ -111,3 +112,7 @@ cargo flamegraph --bench index_build_benchmark -o index_build_benchmark.svg -- -
> - Run as superuser to enable DTrace. This can be achieved by using `cargo flamegraph --root ...`.
>
> For further details, please refer to https://github.com/flamegraph-rs/flamegraph?tab=readme-ov-file#dtrace-on-macos
## Bindings

`arks` includes support for Java bindings using the [`jni-rs`](https://github.com/jni-rs/jni-rs) crate, which uses the Java Native Interface (JNI) to allow Rust functions to be called from Java. The Java bindings are implemented as a Gradle project, located in the `java/` directory.
52 changes: 0 additions & 52 deletions fs-storage/Makefile

This file was deleted.

12 changes: 0 additions & 12 deletions fs-storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,3 @@ key2: value2
```bash
cargo run --example cli read /tmp/z
```

## Java Wrapper
```java
javac -h . FileStorage.java
javac FileStorage.java
LD_LIBRARY_PATH=<project-root-path>/target/debug && java FileStorage.java
```

## Steps to test Java Wrapper
```bash
cd tests && make test
```
2 changes: 1 addition & 1 deletion fs-storage/src/base_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use jnix::{FromJava, IntoJava};

#[derive(Debug, PartialEq, PartialOrd, Ord, Eq, Clone)]
#[cfg_attr(feature = "jni-bindings", derive(FromJava, IntoJava))]
#[jnix(class_name = "SyncStatus")]
#[jnix(class_name = "dev/arkbuilders/core/FileStorage$SyncStatus")]
/// Represents the synchronization status of the storage.
pub enum SyncStatus {
/// No synchronization needed.
Expand Down
20 changes: 11 additions & 9 deletions fs-storage/src/jni/file_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl FileStorage<String, String> {
}

#[no_mangle]
pub extern "system" fn Java_FileStorage_create<'local>(
pub extern "system" fn Java_dev_arkbuilders_core_FileStorage_create<'local>(
mut env: JNIEnv<'local>,
_class: JClass,
label: JString<'local>,
Expand All @@ -53,7 +53,7 @@ pub extern "system" fn Java_FileStorage_create<'local>(
}

#[no_mangle]
pub extern "system" fn Java_FileStorage_set<'local>(
pub extern "system" fn Java_dev_arkbuilders_core_FileStorage_set<'local>(
mut env: JNIEnv<'local>,
_class: JClass,
id: JString<'local>,
Expand All @@ -67,7 +67,7 @@ pub extern "system" fn Java_FileStorage_set<'local>(
}

#[no_mangle]
pub extern "system" fn Java_FileStorage_remove<'local>(
pub extern "system" fn Java_dev_arkbuilders_core_FileStorage_remove<'local>(
mut env: JNIEnv<'local>,
_class: JClass,
id: JString<'local>,
Expand All @@ -86,7 +86,9 @@ pub extern "system" fn Java_FileStorage_remove<'local>(
// type and returns it.
#[no_mangle]
#[allow(non_snake_case)]
pub extern "system" fn Java_FileStorage_syncStatus<'env>(
pub extern "system" fn Java_dev_arkbuilders_core_FileStorage_syncStatus<
'env,
>(
env: jnix::jni::JNIEnv<'env>,
_this: jnix::jni::objects::JObject<'env>,
file_storage_ptr: jnix::jni::sys::jlong,
Expand All @@ -104,7 +106,7 @@ pub extern "system" fn Java_FileStorage_syncStatus<'env>(
}

#[no_mangle]
pub extern "system" fn Java_FileStorage_sync(
pub extern "system" fn Java_dev_arkbuilders_core_FileStorage_sync(
mut env: JNIEnv<'_>,
_class: JClass,
file_storage_ptr: jlong,
Expand All @@ -118,7 +120,7 @@ pub extern "system" fn Java_FileStorage_sync(
}

#[no_mangle]
pub extern "system" fn Java_FileStorage_readFS(
pub extern "system" fn Java_dev_arkbuilders_core_FileStorage_readFS(
mut env: JNIEnv<'_>,
_class: JClass,
file_storage_ptr: jlong,
Expand Down Expand Up @@ -171,7 +173,7 @@ pub extern "system" fn Java_FileStorage_readFS(
}

#[no_mangle]
pub extern "system" fn Java_FileStorage_writeFS(
pub extern "system" fn Java_dev_arkbuilders_core_FileStorage_writeFS(
mut env: JNIEnv<'_>,
_class: JClass,
file_storage_ptr: jlong,
Expand All @@ -187,7 +189,7 @@ pub extern "system" fn Java_FileStorage_writeFS(
#[allow(clippy::suspicious_doc_comments)]
///! Safety: The FileStorage instance is dropped after this call
#[no_mangle]
pub extern "system" fn Java_FileStorage_erase(
pub extern "system" fn Java_dev_arkbuilders_core_FileStorage_erase(
mut env: JNIEnv<'_>,
_class: JClass,
file_storage_ptr: jlong,
Expand All @@ -202,7 +204,7 @@ pub extern "system" fn Java_FileStorage_erase(
}

#[no_mangle]
pub extern "system" fn Java_FileStorage_merge(
pub extern "system" fn Java_dev_arkbuilders_core_FileStorage_merge(
mut env: JNIEnv<'_>,
_class: JClass,
file_storage_ptr: jlong,
Expand Down
1 change: 0 additions & 1 deletion fs-storage/tests/.gitignore

This file was deleted.

61 changes: 0 additions & 61 deletions fs-storage/tests/FileStorage.java

This file was deleted.

11 changes: 0 additions & 11 deletions fs-storage/tests/SyncStatus.java

This file was deleted.

9 changes: 9 additions & 0 deletions java/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

5 changes: 5 additions & 0 deletions java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
Loading

0 comments on commit d54ec31

Please sign in to comment.