@@ -10,32 +10,65 @@ permissions:
1010
1111jobs :
1212 build-natives :
13- name : Build natives for ${{ matrix.platform }}- ${{ matrix.arch }}
13+ name : Natives ${{ matrix.platform-id }} ( ${{ matrix.variant }})
1414 strategy :
15+ fail-fast : false
1516 matrix :
1617 include :
1718 - os : ubuntu-latest
18- platform : linux
19- arch : x64
19+ platform-id : linux-x64
2020 lib : libflecs.so
21+ variant : release
22+
23+ - os : ubuntu-24.04-arm
24+ platform-id : linux-aarch64
25+ lib : libflecs.so
26+ variant : release
27+
28+ - os : windows-latest
29+ platform-id : windows-x64
30+ lib : flecs.dll
31+ variant : release
32+
33+ - os : macos-13
34+ platform-id : macos-x64
35+ lib : libflecs.dylib
36+ variant : release
37+
38+ - os : macos-latest
39+ platform-id : macos-aarch64
40+ lib : libflecs.dylib
41+ variant : release
42+
43+ - os : ubuntu-latest
44+ platform-id : linux-x64
45+ lib : libflecs.so
46+ variant : debug
47+
48+ - os : ubuntu-24.04-arm
49+ platform-id : linux-aarch64
50+ lib : libflecs.so
51+ variant : debug
52+
2153 - os : windows-latest
22- platform : windows
23- arch : x64
54+ platform-id : windows-x64
2455 lib : flecs.dll
25- - os : macos-15
26- platform : macos
27- arch : x64
56+ variant : debug
57+
58+ - os : macos-13
59+ platform-id : macos-x64
2860 lib : libflecs.dylib
61+ variant : debug
62+
2963 - os : macos-latest
30- platform : macos
31- arch : aarch64
64+ platform-id : macos-aarch64
3265 lib : libflecs.dylib
66+ variant : debug
3367
3468 runs-on : ${{ matrix.os }}
3569
3670 steps :
37- - name : Checkout code
38- uses : actions/checkout@v4
71+ - uses : actions/checkout@v4
3972
4073 - name : Set up JDK 25
4174 uses : actions/setup-java@v4
@@ -51,45 +84,43 @@ jobs:
5184
5285 - name : Install GCC (Windows)
5386 if : runner.os == 'Windows'
54- run : choco install mingw -y
87+ uses : msys2/setup-msys2@v2
88+ with :
89+ msystem : MINGW64
90+ install : mingw-w64-x86_64-gcc
5591
5692 - name : Grant execute permission for gradlew
5793 if : runner.os != 'Windows'
5894 run : chmod +x gradlew
5995
60- - name : Build natives
61- run : ./gradlew compileFlecsNative -PNATIVE_ARCH=${{ matrix.platform }}-${{ matrix.arch }}
96+ - name : Compile native (${{ matrix.variant }})
97+ run : >
98+ ./gradlew
99+ compileFlecsNative-${{ matrix.platform-id }}-${{ matrix.variant }}
100+ -PNATIVE_ARCH=${{ matrix.platform-id }}
62101 shell : bash
63102
64- - name : Verify native library was built
103+ - name : Verify native library
104+ shell : bash
65105 run : |
66- FILE_PATH="build/resources/main/natives/${{ matrix.platform }}-${{ matrix.arch }}/${{ matrix.lib }}"
67- echo "Checking for native library at $FILE_PATH..."
68-
69- if [ ! -f "$FILE_PATH" ]; then
70- echo "Error: Native library not found!"
71- exit 1
106+ FILE="build/natives/${{ matrix.platform-id }}/${{ matrix.variant }}/${{ matrix.lib }}"
107+ echo "Checking $FILE ..."
108+ if [ ! -f "$FILE" ]; then
109+ echo "❌ Not found: $FILE"; exit 1
72110 fi
73-
74- FILE_SIZE=$(wc -c < "$FILE_PATH")
75- MIN_SIZE=102400
76-
77- echo "File size: $FILE_SIZE bytes"
78-
79- if [ "$FILE_SIZE" -lt "$MIN_SIZE" ]; then
80- echo "Error: File size is too small ($FILE_SIZE bytes). Expected at least $MIN_SIZE bytes."
81- exit 1
111+ SIZE=$(wc -c < "$FILE")
112+ echo "Size: $SIZE bytes"
113+ if [ "$SIZE" -lt 102400 ]; then
114+ echo "❌ Too small ($SIZE bytes, expected ≥ 102400)"; exit 1
82115 fi
116+ echo "✅ OK"
117+ ls -lh "$FILE"
83118
84- echo "✓ File exists and size is valid."
85- ls -la "$FILE_PATH"
86- shell : bash
87-
88- - name : Upload natives artifact
119+ - name : Upload native artifact
89120 uses : actions/upload-artifact@v4
90121 with :
91- name : natives -${{ matrix.platform }}-${{ matrix.arch }}
92- path : build/resources/main/ natives/${{ matrix.platform }}- ${{ matrix.arch }}/${{ matrix.lib }}
122+ name : native -${{ matrix.platform-id }}-${{ matrix.variant }}
123+ path : build/natives/${{ matrix.platform-id }}/ ${{ matrix.variant }}/${{ matrix.lib }}
93124 retention-days : 1
94125
95126 publish :
@@ -98,58 +129,96 @@ jobs:
98129 runs-on : ubuntu-latest
99130
100131 steps :
101- - name : Checkout code
102- uses : actions/checkout@v4
132+ - uses : actions/checkout@v4
103133
104134 - name : Set up JDK 25
105135 uses : actions/setup-java@v4
106136 with :
107137 java-version : ' 25'
108138 distribution : ' temurin'
109139
110- - name : Download all natives
140+ - name : Download all native artifacts
111141 uses : actions/download-artifact@v4
112142 with :
143+ pattern : native-*
113144 path : downloaded-natives
145+ merge-multiple : false
114146
115- - name : Debug downloaded artifacts
116- run : |
117- echo "Downloaded artifacts structure:"
118- find downloaded-natives -type f
119-
120- - name : Organize natives
147+ - name : Place natives in build/natives/
148+ shell : bash
121149 run : |
122- mkdir -p src/main/resources/natives
123-
124- for artifact_dir in downloaded-natives/natives-*/; do
125- platform_arch=$(basename "$artifact_dir" | sed 's/^natives-//')
126- echo "Processing $platform_arch..."
127- mkdir -p "src/main/resources/natives/$platform_arch"
128- cp "$artifact_dir"/* "src/main/resources/natives/$platform_arch/"
150+ # Structure attendue par les tâches jarNatives-* :
151+ # build/natives/<platform-id>/<variant>/<libName>
152+ echo "=== Downloaded artifacts ==="
153+ find downloaded-natives -type f | sort
154+
155+ for artifact_dir in downloaded-natives/native-*/; do
156+ # artifact_dir = downloaded-natives/native-linux-x64-release/
157+ basename=$(basename "$artifact_dir") # native-linux-x64-release
158+ rest=${basename#native-} # linux-x64-release
159+ variant=${rest##*-} # release (ou debug)
160+ platform=${rest%-$variant} # linux-x64
161+
162+ dest="build/natives/$platform/$variant"
163+ mkdir -p "$dest"
164+ cp "$artifact_dir"/* "$dest/"
165+ echo "✅ $platform/$variant → $dest"
129166 done
130167
131- echo "Final native libraries structure:"
132- find src/main/resources/natives -type f
168+ echo ""
169+ echo "=== Final tree ==="
170+ find build/natives -type f | sort
133171
134172 - name : Grant execute permission for gradlew
135173 run : chmod +x gradlew
136174
137- - name : Build final JAR with all natives
138- run : ./gradlew jar -x compileFlecsNative
175+ - name : Build JAR (API + processor, sans natifs embarqués)
176+ run : ./gradlew jar sourcesJar javadocJar -x compileFlecsNative -x extractFlecs -x downloadFlecs
177+
178+ - name : Build all native JARs
179+ run : ./gradlew $(./gradlew tasks --quiet | grep "^jarNatives-" | awk '{print $1}' | tr '\n' ' ')
139180
140181 - name : Verify JAR contents
182+ shell : bash
141183 run : |
142184 VERSION=${GITHUB_REF_NAME#v}
143- echo "Verifying JAR for version $VERSION..."
144- echo ""
145- echo "All natives in JAR:"
146- jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/" | sort
185+ JAR="build/libs/flecs-java-$VERSION.jar"
186+
187+ echo "=== Main JAR: $JAR ==="
188+ jar tf "$JAR" | grep "natives/" | sort && echo "(no natives expected)" || true
189+
147190 echo ""
191+ echo "=== Native JARs ==="
192+ for f in build/libs/flecs-java-$VERSION-natives-*.jar; do
193+ echo "--- $f ---"
194+ jar tf "$f" | grep "natives/"
195+ done
148196
149- jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/linux-x64/libflecs.so" && echo "✓ Linux x64" || echo "✗ Linux x64 MISSING"
150- jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/windows-x64/flecs.dll" && echo "✓ Windows x64" || echo "✗ Windows x64 MISSING"
151- jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/macos-x64/libflecs.dylib" && echo "✓ macOS x64" || echo "✗ macOS x64 MISSING"
152- jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/macos-aarch64/libflecs.dylib" && echo "✓ macOS ARM64" || echo "✗ macOS ARM64 MISSING"
197+ echo ""
198+ echo "Verifying all expected classifiers..."
199+ EXPECTED=(
200+ "natives-linux-x64"
201+ "natives-linux-aarch64"
202+ "natives-windows-x64"
203+ "natives-macos-x64"
204+ "natives-macos-aarch64"
205+ "natives-linux-x64-debug"
206+ "natives-linux-aarch64-debug"
207+ "natives-windows-x64-debug"
208+ "natives-macos-x64-debug"
209+ "natives-macos-aarch64-debug"
210+ )
211+ ALL_OK=true
212+ for classifier in "${EXPECTED[@]}"; do
213+ f="build/libs/flecs-java-$VERSION-$classifier.jar"
214+ if [ -f "$f" ]; then
215+ echo "✅ $classifier"
216+ else
217+ echo "❌ $classifier — MISSING"
218+ ALL_OK=false
219+ fi
220+ done
221+ $ALL_OK || exit 1
153222
154223 - name : Publish to Maven Central
155224 env :
0 commit comments