Skip to content

Commit 1f2e4b8

Browse files
committed
Configuration for native image compilation.
1 parent e645fe2 commit 1f2e4b8

File tree

7 files changed

+567
-0
lines changed

7 files changed

+567
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: GraalVM Native Image builds
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
name: asu on ${{ matrix.os }}-${{ matrix.arch }}
6+
runs-on: ${{ matrix.label }}
7+
strategy:
8+
matrix:
9+
# See: https://docs.github.com/en/actions/concepts/runners/about-github-hosted-runners#overview-of-github-hosted-runners
10+
# ... and follow the links to the related Github repositories
11+
include:
12+
- label: ubuntu-latest
13+
os: linux
14+
arch: x86_64
15+
- label: ubuntu-24.04-arm
16+
os: linux
17+
arch: aarch64
18+
- label: windows-latest
19+
os: windows
20+
arch: x86_64
21+
- label: macos-13
22+
os: darwin
23+
arch: x86_64
24+
- label: macos-latest
25+
os: darwin
26+
arch: arm64
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: graalvm/setup-graalvm@v1
31+
with:
32+
java-version: '21'
33+
distribution: 'graalvm-community'
34+
github-token: ${{ secrets.GITHUB_TOKEN }}
35+
native-image-job-reports: 'true'
36+
37+
# Note that Graal v21 builds to the current architecture, and "--target" is not functional.
38+
# Therefore, we try to find runners that fit our targets (see above).
39+
- name: Build 'asu'
40+
run: ./gradlew nativeCompile
41+
42+
- name: Upload binary
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: asu-${{ matrix.os }}-${{ matrix.arch }}
46+
path: tools/asu/build/native/nativeCompile/asu*
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"resources": {
3+
"includes": [
4+
{
5+
"pattern": "META-INF/MANIFEST.MF"
6+
}
7+
]
8+
},
9+
"bundles": []
10+
}

tools/asu/build.gradle

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'org.springframework.boot' version "2.7.17"
33
id 'java'
44
id 'application'
5+
id 'org.graalvm.buildtools.native' version '0.10.6'
56
}
67

78
java {
@@ -18,6 +19,15 @@ dependencies {
1819
implementation project(':applesingle-api')
1920
}
2021

22+
jar {
23+
manifest {
24+
attributes(
25+
'Implementation-Title': 'applesingle',
26+
'Implementation-Version': "${project.version} (${new Date().format('yyyy-MM-dd HH:mm')})"
27+
)
28+
}
29+
}
30+
2131
application {
2232
mainClass = "io.github.applecommander.applesingle.tools.asu.Main"
2333
}
@@ -30,3 +40,13 @@ bootJar {
3040
)
3141
}
3242
}
43+
44+
graalvmNative {
45+
String osName = System.getProperty('os.name').toLowerCase().split()[0]
46+
String osArch = System.getProperty('os.arch').toLowerCase().split()[0]
47+
binaries {
48+
named("main") {
49+
imageName.set("asu-${osName}-${osArch}-${project.version}")
50+
}
51+
}
52+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Graal Native Image configuration
2+
3+
This is a mish-mash of manual and automatic code generation.
4+
5+
To _update_ the configurations, use:
6+
7+
```declarative
8+
-agentlib:native-image-agent=config-merge-dir=cli/src/main/resources/META-INF/native-image
9+
```
10+
11+
Please delete empty files and reformat the JSON!
12+
13+
When running the JAR from the command line. This particular pathing, suggests that it be run from the root of the project.
14+
15+
Note: With `asu` every subcommand should be executed to capture all the pieces!
16+
17+
For example:
18+
19+
```shell
20+
$ java -agentlib:native-image-agent=config-merge-dir=tools/asu/src/main/resources/META-INF/native-image \
21+
-jar tools/asu/build/libs/applesingle-tools-asu-1.4.0-DEV.jar \
22+
info api/src/test/resources/hello.applesingle.bin
23+
Real Name: -Unknown-
24+
ProDOS info:
25+
Access: 0xC3
26+
File Type: 0x06
27+
Auxtype: 0x0803
28+
File dates info:
29+
Creation: 2025-07-17T01:19:06Z
30+
Modification: 2025-07-17T01:19:06Z
31+
Access: 2025-07-17T01:19:06Z
32+
Backup: 2025-07-17T01:19:06Z
33+
Data Fork: Present, 2,912 bytes
34+
Resource Fork: Not present
35+
```
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[
2+
{
3+
"name": "java.lang.Boolean",
4+
"methods": [
5+
{
6+
"name": "getBoolean",
7+
"parameterTypes": [
8+
"java.lang.String"
9+
]
10+
}
11+
]
12+
},
13+
{
14+
"name": "java.lang.String",
15+
"methods": [
16+
{
17+
"name": "lastIndexOf",
18+
"parameterTypes": [
19+
"int"
20+
]
21+
},
22+
{
23+
"name": "substring",
24+
"parameterTypes": [
25+
"int"
26+
]
27+
}
28+
]
29+
},
30+
{
31+
"name": "java.lang.System",
32+
"methods": [
33+
{
34+
"name": "getProperty",
35+
"parameterTypes": [
36+
"java.lang.String"
37+
]
38+
},
39+
{
40+
"name": "setProperty",
41+
"parameterTypes": [
42+
"java.lang.String",
43+
"java.lang.String"
44+
]
45+
}
46+
]
47+
},
48+
{
49+
"name": "org.springframework.boot.loader.JarLauncher",
50+
"methods": [
51+
{
52+
"name": "main",
53+
"parameterTypes": [
54+
"java.lang.String[]"
55+
]
56+
}
57+
]
58+
}
59+
]

0 commit comments

Comments
 (0)