@@ -10,32 +10,67 @@ 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-latest
34+ platform-id : macos-x64
35+ lib : libflecs.dylib
36+ variant : release
37+ compiler_target : x86_64-apple-macos10.15
38+
39+ - os : macos-latest
40+ platform-id : macos-aarch64
41+ lib : libflecs.dylib
42+ variant : release
43+
44+ - os : ubuntu-latest
45+ platform-id : linux-x64
46+ lib : libflecs.so
47+ variant : debug
48+
49+ - os : ubuntu-24.04-arm
50+ platform-id : linux-aarch64
51+ lib : libflecs.so
52+ variant : debug
53+
2154 - os : windows-latest
22- platform : windows
23- arch : x64
55+ platform-id : windows-x64
2456 lib : flecs.dll
25- - os : macos-15
26- platform : macos
27- arch : x64
57+ variant : debug
58+
59+ - os : macos-latest
60+ platform-id : macos-x64
2861 lib : libflecs.dylib
62+ variant : debug
63+ compiler_target : x86_64-apple-macos10.15
64+
2965 - os : macos-latest
30- platform : macos
31- arch : aarch64
66+ platform-id : macos-aarch64
3267 lib : libflecs.dylib
68+ variant : debug
3369
3470 runs-on : ${{ matrix.os }}
3571
3672 steps :
37- - name : Checkout code
38- uses : actions/checkout@v4
73+ - uses : actions/checkout@v4
3974
4075 - name : Set up JDK 25
4176 uses : actions/setup-java@v4
@@ -51,45 +86,48 @@ jobs:
5186
5287 - name : Install GCC (Windows)
5388 if : runner.os == 'Windows'
54- run : choco install mingw -y
89+ uses : msys2/setup-msys2@v2
90+ with :
91+ msystem : MINGW64
92+ install : mingw-w64-x86_64-gcc
5593
5694 - name : Grant execute permission for gradlew
5795 if : runner.os != 'Windows'
5896 run : chmod +x gradlew
5997
60- - name : Build natives
61- run : ./gradlew compileFlecsNative -PNATIVE_ARCH=${{ matrix.platform }}-${{ matrix.arch }}
98+ - name : Compile native (${{ matrix.variant }})
6299 shell : bash
63-
64- - name : Verify native library was built
65100 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
72- 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
101+ EXTRA_ARGS=""
102+ if [ -n "${{ matrix.compiler_target }}" ]; then
103+ EXTRA_ARGS="-PCOMPILER_TARGET=${{ matrix.compiler_target }}"
82104 fi
105+ ./gradlew \
106+ compileFlecsNative-${{ matrix.platform-id }}-${{ matrix.variant }} \
107+ -PNATIVE_ARCH=${{ matrix.platform-id }} \
108+ $EXTRA_ARGS
83109
84- echo "✓ File exists and size is valid."
85- ls -la "$FILE_PATH"
110+ - name : Verify native library
86111 shell : bash
112+ run : |
113+ FILE="build/natives/${{ matrix.platform-id }}/${{ matrix.variant }}/${{ matrix.lib }}"
114+ echo "Checking $FILE ..."
115+ if [ ! -f "$FILE" ]; then
116+ echo "❌ Not found: $FILE"; exit 1
117+ fi
118+ SIZE=$(wc -c < "$FILE")
119+ echo "Size: $SIZE bytes"
120+ if [ "$SIZE" -lt 102400 ]; then
121+ echo "❌ Too small ($SIZE bytes, expected ≥ 102400)"; exit 1
122+ fi
123+ echo "✅ OK"
124+ ls -lh "$FILE"
87125
88- - name : Upload natives artifact
126+ - name : Upload native artifact
89127 uses : actions/upload-artifact@v4
90128 with :
91- name : natives -${{ matrix.platform }}-${{ matrix.arch }}
92- path : build/resources/main/ natives/${{ matrix.platform }}- ${{ matrix.arch }}/${{ matrix.lib }}
129+ name : native -${{ matrix.platform-id }}-${{ matrix.variant }}
130+ path : build/natives/${{ matrix.platform-id }}/ ${{ matrix.variant }}/${{ matrix.lib }}
93131 retention-days : 1
94132
95133 publish :
@@ -98,58 +136,93 @@ jobs:
98136 runs-on : ubuntu-latest
99137
100138 steps :
101- - name : Checkout code
102- uses : actions/checkout@v4
139+ - uses : actions/checkout@v4
103140
104141 - name : Set up JDK 25
105142 uses : actions/setup-java@v4
106143 with :
107144 java-version : ' 25'
108145 distribution : ' temurin'
109146
110- - name : Download all natives
147+ - name : Download all native artifacts
111148 uses : actions/download-artifact@v4
112149 with :
150+ pattern : native-*
113151 path : downloaded-natives
152+ merge-multiple : false
114153
115- - name : Debug downloaded artifacts
116- run : |
117- echo "Downloaded artifacts structure:"
118- find downloaded-natives -type f
119-
120- - name : Organize natives
154+ - name : Place natives in build/natives/
155+ shell : bash
121156 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/"
157+ echo "=== Downloaded artifacts ==="
158+ find downloaded-natives -type f | sort
159+
160+ for artifact_dir in downloaded-natives/native-*/; do
161+ basename=$(basename "$artifact_dir")
162+ rest=${basename#native-}
163+ variant=${rest##*-}
164+ platform=${rest%-$variant}
165+
166+ dest="build/natives/$platform/$variant"
167+ mkdir -p "$dest"
168+ cp "$artifact_dir"/* "$dest/"
169+ echo "✅ $platform/$variant → $dest"
129170 done
130171
131- echo "Final native libraries structure:"
132- find src/main/resources/natives -type f
172+ echo ""
173+ echo "=== Final tree ==="
174+ find build/natives -type f | sort
133175
134176 - name : Grant execute permission for gradlew
135177 run : chmod +x gradlew
136178
137- - name : Build final JAR with all natives
138- run : ./gradlew jar -x compileFlecsNative
179+ - name : Build JAR (API + processor, sans natifs embarqués)
180+ run : ./gradlew jar sourcesJar javadocJar -x compileFlecsNative -x extractFlecs -x downloadFlecs
181+
182+ - name : Build all native JARs
183+ run : ./gradlew $(./gradlew tasks --quiet | grep "^jarNatives-" | awk '{print $1}' | tr '\n' ' ')
139184
140185 - name : Verify JAR contents
186+ shell : bash
141187 run : |
142188 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
189+ JAR="build/libs/flecs-java-$VERSION.jar"
190+
191+ echo "=== Main JAR: $JAR ==="
192+ jar tf "$JAR" | grep "natives/" | sort && echo "(no natives expected)" || true
193+
147194 echo ""
195+ echo "=== Native JARs ==="
196+ for f in build/libs/flecs-java-$VERSION-natives-*.jar; do
197+ echo "--- $f ---"
198+ jar tf "$f" | grep "natives/"
199+ done
148200
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"
201+ echo ""
202+ echo "Verifying all expected classifiers..."
203+ EXPECTED=(
204+ "natives-linux-x64"
205+ "natives-linux-aarch64"
206+ "natives-windows-x64"
207+ "natives-macos-x64"
208+ "natives-macos-aarch64"
209+ "natives-linux-x64-debug"
210+ "natives-linux-aarch64-debug"
211+ "natives-windows-x64-debug"
212+ "natives-macos-x64-debug"
213+ "natives-macos-aarch64-debug"
214+ )
215+ ALL_OK=true
216+ for classifier in "${EXPECTED[@]}"; do
217+ f="build/libs/flecs-java-$VERSION-$classifier.jar"
218+ if [ -f "$f" ]; then
219+ echo "✅ $classifier"
220+ else
221+ echo "❌ $classifier — MISSING"
222+ ALL_OK=false
223+ fi
224+ done
225+ $ALL_OK || exit 1
153226
154227 - name : Publish to Maven Central
155228 env :
0 commit comments