graal conf
This commit is contained in:
79
README.md
79
README.md
@@ -37,6 +37,85 @@ tasks.withType<JavaExec>().configureEach {
|
||||
}
|
||||
```
|
||||
|
||||
## GraalVM Native Image Consumer
|
||||
|
||||
`jlibghostty` ships GraalVM reachability metadata at:
|
||||
|
||||
```text
|
||||
META-INF/native-image/dev.jlibghostty/jlibghostty/reachability-metadata.json
|
||||
```
|
||||
|
||||
That metadata registers the FFM downcalls used by this library and includes the bundled native library resource. GraalVM 25 enables Native Image FFM support by default, but the build still needs native access:
|
||||
|
||||
```sh
|
||||
native-image --enable-native-access=ALL-UNNAMED ...
|
||||
```
|
||||
|
||||
If your app uses the module path, prefer:
|
||||
|
||||
```sh
|
||||
native-image --enable-native-access=dev.jlibghostty ...
|
||||
```
|
||||
|
||||
For a Nix-built downstream project, the usual shape is:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
jlibghostty.url = "path:/home/anon/Dev/jlibghostty";
|
||||
};
|
||||
|
||||
outputs = { nixpkgs, jlibghostty, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
jlib = jlibghostty.packages.${system}.jlibghostty;
|
||||
in {
|
||||
packages.${system}.default = pkgs.stdenvNoCC.mkDerivation {
|
||||
pname = "my-native-app";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.graalvmPackages.graalvm-ce
|
||||
pkgs.gradle
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
export GRADLE_USER_HOME=$TMPDIR/gradle
|
||||
gradle --offline -PjlibghosttyMavenRepo=${jlib}/maven installDist
|
||||
native-image \
|
||||
--enable-native-access=ALL-UNNAMED \
|
||||
-cp build/install/my-app/lib/'*' \
|
||||
-o my-app \
|
||||
com.example.Main
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/bin"
|
||||
cp my-app "$out/bin/"
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
In that downstream Gradle build:
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = uri(providers.gradleProperty("jlibghosttyMavenRepo").get())
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("dev.jlibghostty:jlibghostty:0.1.0-SNAPSHOT")
|
||||
}
|
||||
```
|
||||
|
||||
If the app runs on the module path, use:
|
||||
|
||||
```sh
|
||||
|
||||
Reference in New Issue
Block a user