fix(ci): bridge Flutter linux-arm64 gen_snapshot using qemu wrapper

This commit is contained in:
2026-09-13 22:30:22 +02:00
parent 3c8ab00991
commit ac395dad07
2 changed files with 44 additions and 2 deletions
+22 -1
View File
@@ -21,7 +21,7 @@ jobs:
container: container:
image: ghcr.io/cirruslabs/flutter:3.19.3 image: ghcr.io/cirruslabs/flutter:3.19.3
steps: steps:
- name: Setup Node.js 20 & Git for Actions - name: Setup Node.js 20 & ARM64 Flutter Engine
run: | run: |
ARCH=$(uname -m) ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; else NODE_ARCH="x64"; fi if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; else NODE_ARCH="x64"; fi
@@ -30,6 +30,27 @@ jobs:
git config --global --add safe.directory "$GITHUB_WORKSPACE" git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global --add safe.directory '*' git config --global --add safe.directory '*'
# On Linux ARM64, Flutter engine lacks native linux-arm64 gen_snapshot cross-compilers.
# We install qemu-user-static and generate thin wrappers to run the linux-x64 gen_snapshot seamlessly.
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
echo "Setting up ARM64 Flutter gen_snapshot wrappers via QEMU..."
apt-get update -qq && apt-get install -y -qq qemu-user-static
QEMU_BIN=$(command -v qemu-x86_64-static || command -v qemu-x86_64)
flutter precache --android
for dir in /sdks/flutter/bin/cache/artifacts/engine/android-*; do
if [ -d "$dir/linux-x64" ]; then
mkdir -p "$dir/linux-arm64"
cat << EOF > "$dir/linux-arm64/gen_snapshot"
#!/bin/sh
SCRIPT_DIR="\$(cd "\$(dirname "\$0")" && pwd)"
exec $QEMU_BIN "\$SCRIPT_DIR/../linux-x64/gen_snapshot" "\$@"
EOF
chmod +x "$dir/linux-arm64/gen_snapshot"
echo "Configured gen_snapshot wrapper for $(basename "$dir")"
fi
done
fi
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4
+22 -1
View File
@@ -21,7 +21,7 @@ jobs:
container: container:
image: ghcr.io/cirruslabs/flutter:3.19.3 image: ghcr.io/cirruslabs/flutter:3.19.3
steps: steps:
- name: Setup Node.js 20 & Git for Actions - name: Setup Node.js 20 & ARM64 Flutter Engine
run: | run: |
ARCH=$(uname -m) ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; else NODE_ARCH="x64"; fi if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; else NODE_ARCH="x64"; fi
@@ -30,6 +30,27 @@ jobs:
git config --global --add safe.directory "$GITHUB_WORKSPACE" git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global --add safe.directory '*' git config --global --add safe.directory '*'
# On Linux ARM64, Flutter engine lacks native linux-arm64 gen_snapshot cross-compilers.
# We install qemu-user-static and generate thin wrappers to run the linux-x64 gen_snapshot seamlessly.
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
echo "Setting up ARM64 Flutter gen_snapshot wrappers via QEMU..."
apt-get update -qq && apt-get install -y -qq qemu-user-static
QEMU_BIN=$(command -v qemu-x86_64-static || command -v qemu-x86_64)
flutter precache --android
for dir in /sdks/flutter/bin/cache/artifacts/engine/android-*; do
if [ -d "$dir/linux-x64" ]; then
mkdir -p "$dir/linux-arm64"
cat << EOF > "$dir/linux-arm64/gen_snapshot"
#!/bin/sh
SCRIPT_DIR="\$(cd "\$(dirname "\$0")" && pwd)"
exec $QEMU_BIN "\$SCRIPT_DIR/../linux-x64/gen_snapshot" "\$@"
EOF
chmod +x "$dir/linux-arm64/gen_snapshot"
echo "Configured gen_snapshot wrapper for $(basename "$dir")"
fi
done
fi
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4