| 1 | #!/bin/bash |
| 2 | |
| 3 | # build_cake_release.sh - Script to build Cake Wallet for Linux |
| 4 | # Usage: ./build_cake_release.sh --amd64 [--arm64] [--app=cakewallet|monero.com] |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | |
| 9 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 10 | cd "$SCRIPT_DIR" |
| 11 | |
| 12 | |
| 13 | # Default values |
| 14 | BUILD_AMD64=false |
| 15 | BUILD_ARM64=false |
| 16 | APP_TYPE="cakewallet" |
| 17 | DOCKER_IMAGE="ghcr.io/cake-tech/cake_wallet:debian13-flutter3.41.9-ndkr28-go1.24.1-ruststablenightly" |
| 18 | |
| 19 | # Parse arguments |
| 20 | for arg in "$@" |
| 21 | do |
| 22 | case $arg in |
| 23 | --amd64) |
| 24 | BUILD_AMD64=true |
| 25 | shift |
| 26 | ;; |
| 27 | --arm64) |
| 28 | BUILD_ARM64=true |
| 29 | shift |
| 30 | ;; |
| 31 | --app=*) |
| 32 | APP_TYPE="${arg#*=}" |
| 33 | shift |
| 34 | ;; |
| 35 | *) |
| 36 | echo "Unknown argument: $arg" |
| 37 | echo "Usage: ./build_cake_release.sh --amd64 [--arm64] [--app=cakewallet|monero.com]" |
| 38 | exit 1 |
| 39 | ;; |
| 40 | esac |
| 41 | done |
| 42 | |
| 43 | cd ../.. |
| 44 | |
| 45 | # Validate arguments |
| 46 | if [[ "$BUILD_AMD64" == "false" && "$BUILD_ARM64" == "false" ]]; then |
| 47 | echo "Error: At least one architecture (--amd64 or --arm64) must be specified." |
| 48 | echo "Usage: ./build_cake_release.sh --amd64 [--arm64] [--app=cakewallet|monero.com]" |
| 49 | exit 1 |
| 50 | fi |
| 51 | |
| 52 | if [[ "$APP_TYPE" != "cakewallet" && "$APP_TYPE" != "monero.com" ]]; then |
| 53 | echo "Error: App type must be either 'cakewallet' or 'monero.com'" |
| 54 | echo "Usage: ./build_cake_release.sh --amd64 [--arm64] [--app=cakewallet|monero.com]" |
| 55 | exit 1 |
| 56 | fi |
| 57 | |
| 58 | # Function to build for a specific architecture |
| 59 | build_for_arch() { |
| 60 | local arch=$1 |
| 61 | local flutter_arch=$2 |
| 62 | echo "Building $APP_TYPE for Linux ($arch)" |
| 63 | |
| 64 | docker run --privileged -v$(pwd):$(pwd) -w $(pwd) -i --rm --platform linux/$arch $DOCKER_IMAGE bash -x << EOF |
| 65 | set -x -e |
| 66 | pushd scripts |
| 67 | ./gen_android_manifest.sh |
| 68 | popd |
| 69 | pushd scripts/linux |
| 70 | source ./app_env.sh $APP_TYPE |
| 71 | ./app_config.sh |
| 72 | ./build_monero_all.sh |
| 73 | popd |
| 74 | flutter clean |
| 75 | ./model_generator.sh |
| 76 | dart run tool/generate_localization.dart |
| 77 | flutter build linux |
| 78 | rm -rf build/linux/current |
| 79 | cp -r build/linux/$flutter_arch build/linux/current |
| 80 | rm -rf .flatpak-builder |
| 81 | flatpak-builder --force-clean flatpak-build com.cakewallet.CakeWallet.yml |
| 82 | flatpak build-export export flatpak-build |
| 83 | flatpak build-bundle export build/linux/current/cake_wallet.flatpak com.cakewallet.CakeWallet |
| 84 | cp build/linux/current/cake_wallet.flatpak build/linux/$flutter_arch/ |
| 85 | EOF |
| 86 | } |
| 87 | |
| 88 | # Build for specified architectures |
| 89 | echo "Building $APP_TYPE for Linux" |
| 90 | if [[ "$BUILD_AMD64" == "true" ]]; then |
| 91 | build_for_arch "amd64" "x64" |
| 92 | fi |
| 93 | |
| 94 | if [[ "$BUILD_ARM64" == "true" ]]; then |
| 95 | build_for_arch "arm64" "arm64" |
| 96 | fi |
| 97 | |
| 98 | echo "Build process completed." |