forked from WikiDeck/wikideck
- scripts/build-randomx-android.sh: NDK cross-build of the pinned native/ engine (light mode) for arm64-v8a and x86_64, packaged as jniLibs/<abi>/libwikideck_randomx.so - MinerPlugin.java (Capacitor "WikiDeckMiner"): runs engine processes over the line protocol, on-device self-test, and halts on background, battery saver, thermal, hot or low battery. Never receives wallet keys. - src/mobile-miner.ts: template -> mine -> sign -> submit loop in the WebView, byte-identical to consensus miningBlob/mintId (tests/mobile-mining-miner.test.ts) - src/MobileMiningPanel.tsx: consent, intensity (1 thread default; Max = 4 only while charging), live hashrate/status; testnet-only (disabled on mainnet builds) - docs/night2/MOBILE_MINING.md: how it works, safeguards, measured hashrate, store policies (sideload APK only), options for Eric No protocol, consensus or server changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.7 KiB
Bash
Executable File
36 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Cross-compile the pinned native RandomX engine (native/, RandomX v1.2.1) for the Android app.
|
|
# Output: android/app/src/main/jniLibs/<abi>/libwikideck_randomx.so, an executable named like a
|
|
# library so Android extracts it to nativeLibraryDir, where an app may exec it (docs/night2/MOBILE_MINING.md).
|
|
#
|
|
# Needs ANDROID_HOME with an NDK (ndk;<version>) and CMake 3.24+ (cmake;<version>, or cmake on PATH).
|
|
# ABIS="x86_64 arm64-v8a" JOBS=2 sh scripts/build-randomx-android.sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
: "${ANDROID_HOME:?set ANDROID_HOME}"
|
|
ABIS="${ABIS:-arm64-v8a x86_64}"
|
|
JOBS="${JOBS:-2}"
|
|
API="${ANDROID_API:-24}"
|
|
NDK="${ANDROID_NDK_HOME:-$(ls -d "$ANDROID_HOME"/ndk/* 2>/dev/null | sort -V | tail -n1)}"
|
|
[ -f "$NDK/build/cmake/android.toolchain.cmake" ] || { echo "No NDK under $ANDROID_HOME/ndk" >&2; exit 1; }
|
|
CMAKE_DIR="$(ls -d "$ANDROID_HOME"/cmake/* 2>/dev/null | sort -V | tail -n1 || true)"
|
|
[ -n "$CMAKE_DIR" ] && PATH="$CMAKE_DIR/bin:$PATH"
|
|
command -v cmake >/dev/null || { echo "cmake not found" >&2; exit 1; }
|
|
GEN=""
|
|
command -v ninja >/dev/null && GEN="-G Ninja"
|
|
|
|
for abi in $ABIS; do
|
|
build="native/build-android-$abi"
|
|
# shellcheck disable=SC2086
|
|
cmake -S native -B "$build" $GEN \
|
|
-DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \
|
|
-DANDROID_ABI="$abi" -DANDROID_PLATFORM="android-$API" \
|
|
-DCMAKE_BUILD_TYPE=Release -DWIKIDECK_RANDOMX_TESTS=OFF
|
|
cmake --build "$build" --config Release --target wikideck-randomx --parallel "$JOBS"
|
|
out="android/app/src/main/jniLibs/$abi"
|
|
mkdir -p "$out"
|
|
cp "$build/wikideck-randomx" "$out/libwikideck_randomx.so"
|
|
"$NDK"/toolchains/llvm/prebuilt/*/bin/llvm-strip "$out/libwikideck_randomx.so"
|
|
ls -l "$out/libwikideck_randomx.so"
|
|
done
|