Skip to content
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

Restrict ffi access #7

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# EVER-SDK for Java

[![JDK version](https://img.shields.io/badge/Java-21-green.svg)](https://shields.io/)
[![JDK version](https://img.shields.io/badge/Java-22-green.svg)](https://shields.io/)
[![SDK version](https://img.shields.io/badge/EVER%20SDK-v1.45.0-orange)](https://github.com/tonlabs/ever-sdk)
[![License](https://img.shields.io/badge/License-Apache%202.0-brown.svg)](https://shields.io/)

Expand Down Expand Up @@ -31,7 +31,7 @@ that is based on this binding for easier work with TVM blockchains.

#### Prerequisites

* Install **JDK 21** ([link](https://adoptium.net/temurin/releases?version=20))
* Install **JDK 22** ([link](https://adoptium.net/temurin/releases?version=20))

#### Add java4ever to your Maven of Gradle setup:

Expand Down Expand Up @@ -70,13 +70,13 @@ To use custom one, specify it in buildNew() method:
```java
EverSdkContext ctx = EverSdkContext.builder()
.setConfigJson(configJson)
.buildNew(new AbsolutePathLoader(Path.of("\home\ton\lib\libton_client.so")));
.buildNew(new AbsolutePathLoader(Path.of("/home/ton/lib/libton_client.so")));
```

Variants of loading ton_client lib:
* `AbsolutePathLoader.ofSystemEnv("TON_CLIENT_LIB")` - path from Environment variable
* `AbsolutePathLoader.ofUserDir("libton_client.so")` - file from ~ (user home)
* `new AbsolutePathLoader(Path.of("\home\ton\lib\libton_client.so"))` - any absolute path
* `new AbsolutePathLoader(Path.of("/home/ton/lib/libton_client.so"))` - any absolute path
* `new JavaLibraryPathLoader("ton_client");` - gets library from java.library.path JVM argument

### Calling EVER-SDK methods
Expand Down
19 changes: 8 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,48 +149,45 @@ tasks.register('generateFfmApiBridge') {
workingDir "${projectDir}"
executable jextractPath
standardOutput = stdout;
args "--source", "${projectDir}/jextract/ton_client.h", "--output", "${projectDir}/src/gen/java", "--target-package", "tech.deplant.java4ever.binding.ffi", "--header-class-name", "ton_client"
args "--output", "${projectDir}/src/gen/java", "--target-package", "tech.deplant.java4ever.binding.ffi", "--header-class-name", "ton_client", "${projectDir}/jextract/ton_client.h"
}
stdout.toString().trim()
println "FFM API generation ended."
}

tasks.withType(Javadoc).configureEach {
javadocTool = javaToolchains.javadocToolFor {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(22)
}
failOnError false
options.addBooleanOption('html5', true)
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
options.addBooleanOption('-enable-preview', true)
options.addStringOption('-release', '21')
options.addStringOption('-release', '22')
options.addBooleanOption('-ignore-source-errors', true)
options.addStringOption('Xdoclint:none', '-quiet')
}

tasks.withType(JavaCompile).configureEach {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_22
targetCompatibility = JavaVersion.VERSION_22
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(22)
}
options.compilerArgs += "--enable-preview"
}

tasks.withType(JavaExec).configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(22)
}
jvmArgs += "--enable-preview"
jvmArgs += "--enable-native-access=java4ever.binding"
}

tasks.withType(Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(22)
}
useJUnitPlatform()
jvmArgs += "--enable-preview"
jvmArgs += "--enable-native-access=ALL-UNNAMED"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.java.installations.fromEnv=JAVA_HOME
org.gradle.java.installations.auto-detect=true
org.gradle.java.installations.auto-download=false
# product version
v_version=3.0.4-SNAPSHOT
v_version=3.0.5-SNAPSHOT
# dependencies
junitVersion=5.10.1
jpingVersion=0.0.3
Expand Down
Loading
Loading