Skip to content

Commit 042d73b

Browse files
Merge pull request #5 from dashpay/sixteen-kb-pagesize
support 16kb pagesize
2 parents cdaebb1 + 1b9fbb2 commit 042d73b

File tree

8 files changed

+475
-96
lines changed

8 files changed

+475
-96
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Build and Verify 16KB Page Size Alignment
2+
3+
on:
4+
push:
5+
branches: [ master, main, develop ]
6+
pull_request:
7+
branches: [ master, main, develop ]
8+
9+
jobs:
10+
build-and-verify:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: recursive
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '17'
23+
distribution: 'temurin'
24+
25+
- name: Setup Android SDK
26+
uses: android-actions/setup-android@v3
27+
28+
- name: Cache Gradle packages
29+
uses: actions/cache@v4
30+
with:
31+
path: |
32+
~/.gradle/caches
33+
~/.gradle/wrapper
34+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
35+
restore-keys: |
36+
${{ runner.os }}-gradle-
37+
38+
- name: Grant execute permission for gradlew
39+
run: chmod +x gradlew
40+
41+
- name: Build with Gradle
42+
run: ./gradlew build
43+
44+
- name: Verify 16KB Page Size Alignment
45+
run: |
46+
echo "🔍 Checking 16KB page size alignment of 64-bit native libraries..."
47+
48+
# Function to check alignment of a shared library
49+
check_alignment() {
50+
local lib_path="$1"
51+
local lib_name=$(basename "$lib_path")
52+
53+
echo "Checking $lib_name..."
54+
55+
# Use llvm-readelf from NDK to check alignment
56+
local ndk_path="$ANDROID_NDK_ROOT"
57+
local readelf="$ndk_path/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readelf"
58+
59+
if [ ! -f "$readelf" ]; then
60+
echo "❌ Error: llvm-readelf not found at $readelf"
61+
return 1
62+
fi
63+
64+
# Check LOAD segments alignment
65+
local alignments=$($readelf -l "$lib_path" | grep "LOAD" | awk '{print $NF}')
66+
67+
local all_aligned=true
68+
for alignment in $alignments; do
69+
# Convert hex to decimal
70+
local decimal_alignment=$((alignment))
71+
local kb_alignment=$((decimal_alignment / 1024))
72+
73+
echo " Segment alignment: $alignment ($decimal_alignment bytes = ${kb_alignment}KB)"
74+
75+
if [ $decimal_alignment -ne 16384 ]; then
76+
echo " ❌ Not 16KB aligned (expected 0x4000 = 16384 bytes)"
77+
all_aligned=false
78+
else
79+
echo " ✅ 16KB aligned"
80+
fi
81+
done
82+
83+
if [ "$all_aligned" = true ]; then
84+
echo "✅ $lib_name is properly 16KB aligned"
85+
return 0
86+
else
87+
echo "❌ $lib_name has incorrect alignment"
88+
return 1
89+
fi
90+
}
91+
92+
# Find all .so files in build outputs (64-bit architectures only)
93+
echo "Finding 64-bit native libraries in build outputs..."
94+
so_files=$(find . -path "*/build/intermediates/cxx/*/obj/*/*.so" -type f | grep -E "(Release|RelWithDebInfo)" | grep -E "(arm64-v8a|x86_64)" | head -20)
95+
96+
if [ -z "$so_files" ]; then
97+
echo "❌ No native libraries found in build outputs"
98+
exit 1
99+
fi
100+
101+
echo "Found native libraries:"
102+
echo "$so_files"
103+
echo
104+
105+
# Check alignment for each library
106+
all_libs_aligned=true
107+
for so_file in $so_files; do
108+
if ! check_alignment "$so_file"; then
109+
all_libs_aligned=false
110+
fi
111+
echo
112+
done
113+
114+
# Summary
115+
echo "📊 Alignment Verification Summary:"
116+
if [ "$all_libs_aligned" = true ]; then
117+
echo "🎉 All native libraries are properly 16KB aligned!"
118+
echo "✅ This build is compatible with 16KB page size devices"
119+
else
120+
echo "❌ Some libraries are not properly aligned"
121+
echo "💡 Ensure you're using Android Gradle Plugin 8.5.1+ and target SDK 35+"
122+
exit 1
123+
fi
124+
125+
- name: Verify AAR Contents
126+
run: |
127+
echo "🔍 Verifying AAR files contain native libraries..."
128+
129+
# Find AAR files
130+
aar_files=$(find . -name "*.aar" -path "*/build/outputs/aar/*" -type f)
131+
132+
if [ -z "$aar_files" ]; then
133+
echo "❌ No AAR files found"
134+
exit 1
135+
fi
136+
137+
echo "Found AAR files:"
138+
for aar in $aar_files; do
139+
echo "📦 $(basename $aar)"
140+
141+
# Check if AAR contains native libraries
142+
native_libs=$(unzip -l "$aar" | grep -E "jni/.*\.so$" | wc -l)
143+
144+
if [ $native_libs -gt 0 ]; then
145+
echo " ✅ Contains $native_libs native libraries"
146+
echo " 📋 Native library details:"
147+
unzip -l "$aar" | grep -E "jni/.*\.so$" | awk '{print " " $4}'
148+
else
149+
echo " ℹ️ No native libraries (library may be pure Java/Kotlin)"
150+
fi
151+
echo
152+
done
153+
154+
- name: Upload build artifacts
155+
uses: actions/upload-artifact@v4
156+
if: always()
157+
with:
158+
name: build-outputs
159+
path: |
160+
**/build/outputs/aar/*.aar
161+
**/build/intermediates/cxx/*/obj/*/*.so
162+
retention-days: 7
163+
164+
- name: Upload lint reports
165+
uses: actions/upload-artifact@v4
166+
if: always()
167+
with:
168+
name: lint-reports
169+
path: |
170+
**/build/reports/lint-results-*.html
171+
retention-days: 7

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
/captures
77
/local.properties
88
.externalNativeBuild
9-
.cxx
9+
.cxx
10+
.java-version

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
DashJ BLS for Android
1+
# DashJ BLS for Android
22

33
```bash
44
git submodule update --init --recursive
55
./gradlew build
66
```
77

8-
Publish to Maven Local
8+
### Publish to Maven Local
99
```
1010
./gradlew publishToMavenLocal
1111
```
12-
Publish to Maven Central
13-
```
12+
13+
### Publish to Maven Central
14+
15+
To deploy to the maven repository:
16+
```bash
17+
./gradlew clean
1418
./gradlew publish
19+
./gradlew jreleaserDeploy
1520
```

build.gradle

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.5.20'
4+
ext.kotlin_version = '2.1.20'
55
repositories {
66
mavenLocal()
77
mavenCentral()
88
google()
9+
gradlePluginPortal() // Required for JReleaser plugin
910
}
1011
dependencies {
11-
classpath 'com.android.tools.build:gradle:7.2.2'
12+
classpath 'com.android.tools.build:gradle:8.5.1'
1213
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13-
14-
//classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
1514
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
16-
// NOTE: Do not place your application dependencies here; they belong
17-
// in the individual module build.gradle files
1815
}
1916
}
2017

0 commit comments

Comments
 (0)