CW-1020 arm64 linux support (#2110)

* arm64 linux support * add missing dependencies to Dockerfile * run everything in docker to not break permissions * remove current linux dir * proper directory name * Clean up build script by removing .flatpak-builder directory flatpak before build process * account for arm64 in docs [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>

cyan committed Mar 31, 2025 at 07:19 UTC eab91de9f60e49ba85c7371692ab4391f989ae3f
10 files changed +177 -81
.github/workflows/pr_test_build_android.yml
+1 -1
@@ -9,7 +9,7 @@ jobs:
9 PR_test_build:
10 runs-on: linux-amd64
11 container:
12 - image: ghcr.io/cake-tech/cake_wallet:3.27.4-linux
12 + image: ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1
13 env:
14 STORE_PASS: test@cake_wallet
15 KEY_PASS: test@cake_wallet
.github/workflows/pr_test_build_linux.yml
+1 -4
@@ -9,7 +9,7 @@ jobs:
9 PR_test_build:
10 runs-on: linux-amd64
11 container:
12 - image: ghcr.io/cake-tech/cake_wallet:3.27.4-linux
12 + image: ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1
13 env:
14 STORE_PASS: test@cake_wallet
15 KEY_PASS: test@cake_wallet
@@ -22,9 +22,6 @@ jobs:
22 - /opt/cw_cache_linux/root/.pub-cache/:/root/.pub-cache
23 - /opt/cw_cache_linux/root/go/pkg:/root/go/pkg
24 - /opt/cw_cache_linux/opt/generic_cache:/opt/generic_cache
25 - strategy:
26 - matrix:
27 - api-level: [29]
25
26 steps:
27 - name: Fix github actions messing up $HOME...
.gitignore
+4 -4
@@ -186,6 +186,10 @@ ios/WowneroWallet.framework/WowneroWallet
186 ios/ZanoWallet.framework/ZanoWallet
187 *_libwallet2_api_c.dylib
188
189 +.flatpak-builder
190 +cake_wallet.flatpak
191 +flatpak-build/
192 +
193 # macOS
194 **/Flutter/ephemeral/
195 **/Pods/
@@ -204,7 +208,3 @@ ios/ZanoWallet.framework/ZanoWallet
208 **/linux/flutter/generated_plugin_registrant.cc
209 **/linux/flutter/generated_plugin_registrant.h
210 **/linux/flutter/generated_plugins.cmake
207 -
208 -cake_wallet.flatpak
209 -flatpak-build/
210 -export/
\ No newline at end of file
Dockerfile
+43 -14
@@ -1,5 +1,4 @@
1 -# docker build . -f Dockerfile -t ghcr.io/cake-tech/cake_wallet:3.27.4-linux
2 -# docker push ghcr.io/cake-tech/cake_wallet:3.27.4-linux
1 +# docker buildx build --push --pull --platform linux/amd64,linux/arm64 . -f Dockerfile -t ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1
2
3 # Heavily inspired by cirrusci images
4 # https://github.com/cirruslabs/docker-images-android/blob/master/sdk/tools/Dockerfile
@@ -7,7 +6,7 @@
6 # https://github.com/cirruslabs/docker-images-android/blob/master/sdk/34-ndk/Dockerfile
7 # https://github.com/cirruslabs/docker-images-flutter/blob/master/sdk/Dockerfile
8
10 -FROM --platform=linux/amd64 docker.io/debian:12
9 +FROM docker.io/debian:12
10
11 LABEL org.opencontainers.image.source=https://github.com/cake-tech/cake_wallet
12
@@ -60,11 +59,20 @@ RUN set -o xtrace \
59 ffmpeg network-manager x11-utils xvfb psmisc \
60 # aarch64-linux-gnu dependencies
61 g++-aarch64-linux-gnu gcc-aarch64-linux-gnu \
62 + # x86_64-linux-gnu dependencies
63 + g++-x86-64-linux-gnu gcc-x86-64-linux-gnu \
64 + # flatpak dependencies
65 + flatpak flatpak-builder binutils elfutils patch unzip xz-utils zstd \
66 && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
67 && sh -c 'echo "en_US.UTF-8 UTF-8" > /etc/locale.gen' \
68 && locale-gen \
69 && update-locale LANG=en_US.UTF-8
70
71 +ENV FLATPAK_RUNTIME_VERSION=24.08
72 +RUN flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo \
73 + && flatpak install -y flathub org.freedesktop.Platform//${FLATPAK_RUNTIME_VERSION} \
74 + && flatpak install -y flathub org.freedesktop.Sdk//${FLATPAK_RUNTIME_VERSION}
75 +
76 # Install nodejs for Github Actions
77 RUN curl -fsSL https://deb.nodesource.com/setup_23.x | bash - && \
78 apt-get install -y --no-install-recommends nodejs && \
@@ -74,14 +82,28 @@ RUN curl -fsSL https://deb.nodesource.com/setup_23.x | bash - && \
82 ENV PATH=${PATH}:/usr/local/go/bin:${HOME}/go/bin
83 ENV GOROOT=/usr/local/go
84 ENV GOPATH=${HOME}/go
77 -RUN wget https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz &&\
78 - rm -rf /usr/local/go &&\
79 - tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-amd64.tar.gz && \
85 +RUN ARCH=$(uname -m) && \
86 + if [ "$ARCH" = "x86_64" ]; then \
87 + wget https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz -O go.tar.gz; \
88 + elif [ "$ARCH" = "aarch64" ]; then \
89 + wget https://go.dev/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz -O go.tar.gz; \
90 + else \
91 + echo "Unsupported architecture: $ARCH"; exit 1; \
92 + fi && \
93 + rm -rf /usr/local/go && \
94 + tar -C /usr/local -xzf go.tar.gz && \
95 + rm go.tar.gz && \
96 go install golang.org/x/mobile/cmd/gomobile@latest && \
97 gomobile init
98
99 +RUN git config --global user.email "czarek@cakewallet.com" \
100 + && git config --global user.name "CakeWallet CI"
101 +
102 +
103 # Install Android SDK commandline tools and emulator
84 -RUN wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip -O android-sdk-tools.zip \
104 +RUN ARCH=$(uname -m) && \
105 + if [ "$ARCH" != "x86_64" ]; then exit 0; fi \
106 + && wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip -O android-sdk-tools.zip \
107 && mkdir -p ${ANDROID_HOME}/cmdline-tools/ \
108 && unzip -q android-sdk-tools.zip -d ${ANDROID_HOME}/cmdline-tools/ \
109 && mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest \
@@ -94,14 +116,17 @@ RUN wget -q https://dl.google.com/android/repository/commandlinetools-linux-${AN
116 && sdkmanager platform-tools \
117 && mkdir -p ${HOME}/.android \
118 && touch ${HOME}/.android/repositories.cfg \
97 - && git config --global user.email "czarek@cakewallet.com" \
98 - && git config --global user.name "CakeWallet CI"
119 +
120
121 # Handle emulator not being available on linux/arm64 (https://issuetracker.google.com/issues/227219818)
101 -RUN if [ $(uname -m) == "x86_64" ]; then sdkmanager emulator ; fi
122 +RUN ARCH=$(uname -m) && \
123 + if [ "$ARCH" != "x86_64" ]; then exit 0; fi \
124 + && sdkmanager emulator
125
126 # Pre-install extra Android SDK dependencies in order to not have to download them for each build
104 -RUN yes | sdkmanager \
127 +RUN ARCH=$(uname -m) && \
128 + if [ "$ARCH" != "x86_64" ]; then exit 0; fi \
129 + && yes | sdkmanager \
130 "platforms;android-$ANDROID_PLATFORM_VERSION" \
131 "build-tools;$ANDROID_BUILD_TOOLS_VERSION" \
132 "platforms;android-33" \
@@ -114,12 +139,16 @@ RUN yes | sdkmanager \
139
140 # Install extra NDK dependency for sp_scanner
141 ENV ANDROID_NDK_VERSION=27.2.12479018
117 -RUN yes | sdkmanager "ndk;$ANDROID_NDK_VERSION" \
142 +RUN ARCH=$(uname -m) && \
143 + if [ "$ARCH" != "x86_64" ]; then exit 0; fi \
144 + && yes | sdkmanager "ndk;$ANDROID_NDK_VERSION" \
145 "ndk;27.0.12077973"
146
147 # Install dependencies for tests
148 # Comes from https://github.com/ReactiveCircus/android-emulator-runner
122 -RUN yes | sdkmanager \
149 +RUN ARCH=$(uname -m) && \
150 + if [ "$ARCH" != "x86_64" ]; then exit 0; fi \
151 + && yes | sdkmanager \
152 "system-images;android-29;default;x86_64" \
153 "system-images;android-31;default;x86_64" \
154 "platforms;android-29" \
@@ -135,7 +164,7 @@ RUN (addgroup kvm || true) && \
164 ENV PATH=${HOME}/.cargo/bin:${PATH}
165 RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \
166 cargo install cargo-ndk && \
138 - for target in aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android x86_64-unknown-linux-gnu; \
167 + for target in aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu aarch64-unknown-linux-gnu; \
168 do \
169 rustup target add --toolchain stable $target; \
170 done
com.cakewallet.CakeWallet.yml
+2 -4
@@ -1,6 +1,6 @@
1 app-id: com.cakewallet.CakeWallet
2 runtime: org.freedesktop.Platform
3 -runtime-version: '22.08'
3 +runtime-version: '24.08'
4 sdk: org.freedesktop.Sdk
5 command: cake_wallet
6 separate-locales: false
@@ -15,8 +15,6 @@ finish-args:
15 modules:
16 - name: cake_wallet
17 buildsystem: simple
18 - only-arches:
19 - - x86_64
18 build-commands:
19 - "cp -R bundle /app/cake_wallet"
20 - "chmod +x /app/cake_wallet/cake_wallet"
@@ -28,7 +26,7 @@ modules:
26 - "cp com.cakewallet.CakeWallet.desktop /app/share/applications"
27 sources:
28 - type: dir
31 - path: build/linux/x64/release
29 + path: build/linux/current/release
30 - type: file
31 path: assets/images/cakewallet_icon_180.png
32 - type: file
docs/builds/ANDROID.md
+2 -4
@@ -8,8 +8,6 @@ You can find the latest instructions for installing Docker on your given OS on t
8
9 - <https://docs.docker.com/engine/install/>
10
11 -NOTE: If building on a Mac with an M-series CPU (arm64), you may encounter segmentation faults when building. If you do, simply retry the build.
12 -
11 ## Building Cake Wallet or Monero.com
12
13 ### Using the pre-built builder image
@@ -20,8 +18,8 @@ In order to build the latest version of Cake Wallet, simply run the following:
18 git clone --branch main https://github.com/cake-tech/cake_wallet.git
19 # NOTE: Replace `main` with the latest release tag available at https://github.com/cake-tech/cake_wallet/releases/latest.
20 cd cake_wallet
23 -# docker build -t ghcr.io/cake-tech/cake_wallet:main-linux . # Uncomment to build the docker image yourself instead of pulling it from the registry
24 -docker run -v$(pwd):$(pwd) -w $(pwd) -i --rm ghcr.io/cake-tech/cake_wallet:main-linux bash -x << EOF
21 +# docker build -t ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 . # Uncomment to build the docker image yourself instead of pulling it from the registry
22 +docker run -v$(pwd):$(pwd) -w $(pwd) -i --rm ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 bash -x << EOF
23 set -x -e
24 pushd scripts/android
25 source ./app_env.sh cakewallet
docs/builds/LINUX.md
+11 -39
@@ -20,8 +20,8 @@ In order to build the latest version of Cake Wallet, simply run the following:
20 git clone --branch main https://github.com/cake-tech/cake_wallet.git
21 # NOTE: Replace `main` with the latest release tag available at https://github.com/cake-tech/cake_wallet/releases/latest.
22 cd cake_wallet
23 -# docker build -t ghcr.io/cake-tech/cake_wallet:main-linux . # Uncomment to build the docker image yourself instead of pulling it from the registry
24 -docker run -v$(pwd):$(pwd) -w $(pwd) -i --rm ghcr.io/cake-tech/cake_wallet:main-linux bash -x << EOF
23 +# docker build -t ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 . # Uncomment to build the docker image yourself instead of pulling it from the registry
24 +docker run --privileged -v$(pwd):$(pwd) -w $(pwd) -i --rm ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 bash -x << EOF
25 set -x -e
26 pushd scripts
27 ./gen_android_manifest.sh
@@ -37,6 +37,13 @@ flutter clean
37 dart run tool/generate_localization.dart
38 dart run tool/generate_new_secrets.dart
39 flutter build linux
40 +cp -r build/linux/x64 build/linux/current
41 +# use line below if you are building on arm64
42 +# cp -r build/linux/arm64 build/linux/current
43 +# If you want to build flatpak you need --privileged flag
44 +flatpak-builder --force-clean flatpak-build com.cakewallet.CakeWallet.yml
45 +flatpak build-export export flatpak-build
46 +flatpak build-bundle export build/linux/current/cake_wallet.flatpak com.cakewallet.CakeWallet
47 EOF
48 ```
49
@@ -51,46 +58,11 @@ Building Linux application...
58 ✓ Built build/linux/x64/release/bundle/cake_wallet
59 ```
60
54 -Final builds can be found in `build/linux/x64/release/bundle/` as seen above.
55 -
56 -
57 -## Flatpak (optional)
58 -
59 -To package the built binaries as a flatpak, you need first to install `flatpak` and `flatpak-builder`:
60 -
61 -```bash
62 -sudo apt install flatpak flatpak-builder
63 -```
64 -
65 -Add the necessary Flathub:
66 -
67 -```bash
68 -flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
69 -```
70 -
71 -Then need to install freedesktop runtime and sdk:
72 -
73 -```bash
74 -flatpak install flathub org.freedesktop.Platform//22.08 org.freedesktop.Sdk//22.08
75 -```
76 -
77 -Next, build the flatpak bundle:
78 -
79 -```bash
80 -flatpak-builder --force-clean flatpak-build com.cakewallet.CakeWallet.yml
81 -```
82 -
83 -And then export bundle:
84 -
85 -```bash
86 -flatpak build-export export flatpak-build
87 -flatpak build-bundle export cake_wallet.flatpak com.cakewallet.CakeWallet
88 -```
61 +Final builds can be found in `build/linux/current/release/bundle/` as seen above.
62
90 -The Flatpak file, `cake_wallet.flatpak`, should be generated in the current directory.
63
64 To install the newly built Flatpak, run:
65
66 ```bash
95 -flatpak --user install cake_wallet.flatpak
67 +flatpak --user install build/linux/current/cake_wallet.flatpak
68 ```
linux/CMakeLists.txt
+1 -1
@@ -107,7 +107,7 @@ install(CODE "
107 set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
108 set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
109
110 -if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
110 +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
111 set(LIB_TRIPLET "aarch64-linux-gnu")
112 else()
113 set(LIB_TRIPLET "x86_64-linux-gnu")
scripts/linux/build_cake_release.sh new
+98
@@ -0,0 +1,98 @@
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:debian12-flutter3.27.4-go1.24.1"
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."
scripts/linux/build_monero_all.sh
+14 -10
@@ -10,15 +10,19 @@ cd "$(dirname "$0")"
10 for COIN in monero wownero;
11 do
12 pushd ../monero_c
13 - for target in x86_64-linux-gnu # aarch64-linux-gnu
14 - do
15 - if [[ -f "release/${COIN}/${target}_libwallet2_api_c.so" ]];
16 - then
17 - echo "file exist, not building monero_c for ${COIN}/$target.";
18 - else
19 - ./build_single.sh ${COIN} $target -j$MAKE_JOB_COUNT
20 - unxz -f ../monero_c/release/${COIN}/${target}_libwallet2_api_c.so.xz
21 - fi
22 - done
13 + # Determine target architecture based on system architecture
14 + if [[ $(uname -m) == "arm64" || $(uname -m) == "aarch64" ]]; then
15 + target="aarch64-linux-gnu"
16 + else
17 + target="x86_64-linux-gnu"
18 + fi
19 +
20 + if [[ -f "release/${COIN}/${target}_libwallet2_api_c.so" ]];
21 + then
22 + echo "file exist, not building monero_c for ${COIN}/$target.";
23 + else
24 + ./build_single.sh ${COIN} $target -j$MAKE_JOB_COUNT
25 + unxz -f ../monero_c/release/${COIN}/${target}_libwallet2_api_c.so.xz
26 + fi
27 popd
28 done
\ No newline at end of file