Files
hash-wallet/scripts/android/build_mwebd.sh
T
309ad1836e use ffi for mweb (#2456)
* chore: add ffi and ffigen dependencies to pubspec.yaml

* refactor: replace method channel with FFI implementation for MWeb module

* fix: correct `cd` command in build_mwebd.sh script

* chore: add go.sum file with dependency checksums

* fix: ensure ANDROID_NDK_VERSION is set before building and dynamically update NDK_BIN path

* fix: update NDK_BIN path to dynamically detect platform in build_mwebd.sh script

* refactor: remove unused mwebd dependencies and clean up CwMwebPlugin code

* Update scripts/android/build_mwebd.sh

Co-authored-by: cyan <cyjan@mrcyjanek.net>

* refactor: replace iOS MoneroWallet framework with Mwebd.xcframework and clean up plugin implementation [skip-ci]

* fix: mwebd ffi ios

* refactor: update MWebFfi class to use non-nullable `lib` and improve address debug logging

* chore: remove unused iOS/Android build scripts for mwebd

* refactor: replace mweb.so with libmweb.so, use sync methods in MWebFfi, and update iOS/Android frameworks/scripts accordingly

* chore: unify mwebd build process in workflows, remove unused gomobile init command

---------

Co-authored-by: cyan <cyjan@mrcyjanek.net>
2025-09-12 16:13:00 +03:00

49 lines
1.8 KiB
Bash
Executable File

if [[ "$1" == "--dont-install" ]]; then
echo "Skipping Go installation as per --dont-install flag"
else
# install go > 1.24:
wget https://go.dev/dl/go1.24.1.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.24.1.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:~/go/bin
fi
cd ../../cw_mweb/go
if [[ "x$ANDROID_NDK_VERSION" == "x" ]];
then
echo "ANDROID_NDK_VERSION is missing, please declare it before building"
echo "You have these versions installed on your system currently:"
ls ${ANDROID_HOME}/ndk/ | cat | awk '{ print "- " $1 }'
echo "echo > ~/.zprofile"
echo "echo 'export ANDROID_NDK_VERSION=..... > ~/.zprofile"
exit 1
fi
export ANDROID_OUT=../android/src/main/jniLibs
export ANDROID_SDK="${HOME}/Library/Android/sdk"
export NDK_BIN="${ANDROID_HOME}/ndk/${ANDROID_NDK_VERSION}/toolchains/llvm/prebuilt/$(uname | tr '[:upper:]' '[:lower:]')-x86_64/bin"
# Compile for x86_64 architecture and place the binary file in the android/src/main/jniLibs/x86_64 folder
CGO_ENABLED=1 \
GOOS=android \
GOARCH=amd64 \
CC=${NDK_BIN}/x86_64-linux-android21-clang \
go build -buildmode=c-shared -o ${ANDROID_OUT}/x86_64/libmweb.so .
# Compile for arm64 architecture and place the binary file in the android/src/main/jniLibs/arm64-v8a folder
CGO_ENABLED=1 \
GOOS=android \
GOARCH=arm64 \
CC=${NDK_BIN}/aarch64-linux-android21-clang \
go build -buildmode=c-shared -o ${ANDROID_OUT}/arm64-v8a/libmweb.so .
# Compile for armv7a architecture and place the binary file in the android/src/main/jniLibs/armeabi-v7a folder
CGO_ENABLED=1 \
GOOS=android \
GOARCH=arm \
CC=${NDK_BIN}/armv7a-linux-androideabi21-clang \
go build -buildmode=c-shared -o ${ANDROID_OUT}/armeabi-v7a/libmweb.so .
cd ../
dart run ffigen --config ffigen_config.yaml