Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ jobs:
run: |
make aw-server-rust

- name: Check that jniLibs present
- name: Check that jniLibs present and valid ELF
run: |
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
python3 scripts/check-jnilibs.py

- name: Upload jniLibs artifact
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -205,9 +205,9 @@ jobs:
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ env.NDK_VERSION }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }}
fail-on-cache-miss: false

- name: Check that jniLibs present
- name: Check that jniLibs present and valid ELF
run: |
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
python3 scripts/check-jnilibs.py

- name: Verify versionName matches tag
if: startsWith(github.ref, 'refs/tags/v') # only on runs triggered from tag
Expand Down Expand Up @@ -289,9 +289,9 @@ jobs:
name: jniLibs
path: mobile/src/main/jniLibs/

- name: Check that jniLibs present
- name: Check that jniLibs present and valid ELF
run: |
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
python3 scripts/check-jnilibs.py

# Test
- name: Test
Expand Down
7 changes: 7 additions & 0 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ android {
applicationIdSuffix ".debug"
jniDebuggable true
renderscriptDebuggable true
// Limit debug APK to modern ABIs used by CI emulators and physical devices.
// armeabi-v7a debug Rust binaries are very large and can corrupt the CI
// artifact when disk space is tight; they aren't needed for x86_64 emulator
// runs or any arm64-v8a device released since ~2014.
ndk {
abiFilters 'arm64-v8a', 'x86_64'
}
}
}
compileOptions {
Expand Down
62 changes: 62 additions & 0 deletions scripts/check-jnilibs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
import os
import struct
import sys


ABIS = ["arm64-v8a", "armeabi-v7a", "x86", "x86_64"]
LIB_NAME = "libaw_server.so"


def check_lib(abi):
path = os.path.join("mobile", "src", "main", "jniLibs", abi, LIB_NAME)
if not os.path.exists(path):
print(f"MISSING {path}", file=sys.stderr)
return False

fsize = os.path.getsize(path)
with open(path, "rb") as f:
header = f.read(64)

if header[:4] != b"\x7fELF":
print(f"NOT_ELF {path}", file=sys.stderr)
return False

if len(header) < 64:
print(
f"CORRUPT {path}: file too small for ELF header "
f"({len(header)} bytes)",
file=sys.stderr,
)
return False

e_class = header[4] # 1=32-bit, 2=64-bit
if e_class == 1:
e_shoff = struct.unpack("<I", header[32:36])[0]
elif e_class == 2:
e_shoff = struct.unpack("<Q", header[40:48])[0]
else:
print(f"CORRUPT {path}: unknown ELF class {e_class}", file=sys.stderr)
return False

if e_shoff != 0 and e_shoff >= fsize:
print(
f"CORRUPT {path}: section header past EOF "
f"(e_shoff=0x{e_shoff:x}, size={fsize})",
file=sys.stderr,
)
return False

print(f"OK {abi}/{LIB_NAME} ({fsize:,} bytes)")
return True


def main():
ok = True
for abi in ABIS:
ok = check_lib(abi) and ok
return 0 if ok else 1


if __name__ == "__main__":
sys.exit(main())
Loading