Skip to content

Build RISC-V engine, RISC-V gen_snapshots #371

Build RISC-V engine, RISC-V gen_snapshots

Build RISC-V engine, RISC-V gen_snapshots #371

Workflow file for this run

name: Build flutter engine and dart AOT compiler
on:
push:
tags:
- 'flutter/stable/*'
- 'flutter/beta/*'
pull_request:
branches: [ ci ]
repository_dispatch:
workflow_dispatch:
workflow_call:
defaults:
# Use bash by default for all jobs, regardless of OS,
# so we can use the same commands for windows.
run:
shell: bash
env:
XZ_DEFAULTS: "-T 0"
GCLIENT_PY3: 1
DEPOT_TOOLS_UPDATE: 0
DEPOT_TOOLS_WIN_TOOLCHAIN: 0
jobs:
resolve-version:
name: 'Resolve relevant flutter versions'
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.resolve.outputs.first-semver }}
hash: ${{ steps.resolve.outputs.flutter-hash }}
channel: ${{ steps.resolve.outputs.channel }}
steps:
- uses: actions/checkout@v4
- name: Resolve flutter hash & SDK version
id: resolve
env:
GIT_BASECMD: "git -c gc.autoDetach=false -c core.pager=cat -c safe.bareRepository=all"
FLUTTER_REPO: "https://github.com/flutter/flutter.git"
run: |
if ${{ startsWith(github.ref, 'refs/pull/') }}; then
CHANNEL="pr"
else
CHANNEL="$(echo "$GITHUB_REF" | cut -d/ -f4)"
fi
echo "channel=$CHANNEL" >> $GITHUB_OUTPUT
echo "is-stable=$(test "$CHANNEL" = "stable" && echo true || echo false)" >> $GITHUB_OUTPUT
echo "is-beta=$(test "$CHANNEL" = "beta" && echo true || echo false)" >> $GITHUB_OUTPUT
# read the flutter.version file to find the flutter hash
# that we're building for
FLUTTER_HASH=$(cat flutter.version.$CHANNEL | tr -dc [:xdigit:])
# Get all (full-qualified) tags that point to the engine commit
# e.g. refs/tags/2.10.0-0.0.pre.0
REFS=$($GIT_BASECMD ls-remote --tags "$FLUTTER_REPO" "$FLUTTER_HASH" | cut -f2)
# Extract the tag names from the full-qualified refs
# e.g. 2.10.0-0.0.pre.0
TAGS=$(echo "$REFS" | cut -d/ -f3 | sort -V)
# Extract the first tag
FIRST_TAG=$(echo "$TAGS" | head -n1)
# Serialize the tags to JSON
TAGS_JSON="$(echo "$TAGS" | jq -ncMR '[inputs]')"
echo "first-semver=$FIRST_TAG" >> $GITHUB_OUTPUT
echo "flutter-hash=$FLUTTER_HASH" >> $GITHUB_OUTPUT
populate-engine-src-cache:
name: 'Prepopulate engine source cache'
runs-on: ${{ matrix.os }}
needs: resolve-version
strategy:
matrix:
os:
- ubuntu-latest
- macos-13
- windows-latest
steps:
- uses: actions/checkout@v4
- run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- uses: actions/cache/restore@v4
id: cache-lookup
with:
path: flutter
key: flutter-${{ needs.resolve-version.outputs.hash }}-${{ runner.os }}-${{ runner.arch }}
lookup-only: true
- name: Install depot tools
id: cache-depot-tools
if: steps.cache-lookup.outputs.cache-hit != 'true'
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/depot_tools
key: ${{ runner.os }}-${{ runner.arch }}-depot-tools
- name: Clone depot_tools (if not cached)
if: steps.cache-lookup.outputs.cache-hit != 'true' && steps.cache-depot-tools.outputs.cache-hit != 'true'
working-directory: ${{ github.workspace }}
run: |
git clone --depth 1 \
https://chromium.googlesource.com/chromium/tools/depot_tools.git \
./depot_tools
- name: Setup depot_tools
if: steps.cache-lookup.outputs.cache-hit != 'true'
run: |
echo $GITHUB_WORKSPACE/depot_tools >> $GITHUB_PATH
- name: Print depot_tools debug info
if: steps.cache-lookup.outputs.cache-hit != 'true'
run: |
echo path:
echo $PATH
echo
echo which python3:
which python3
echo
echo python3 version:
python3 --version
- name: Bootstrap flutter environment
if: steps.cache-lookup.outputs.cache-hit != 'true'
run: |
mkdir -p flutter
cp dot-gclient.py flutter/.gclient
- name: Install flutter sources
if: steps.cache-lookup.outputs.cache-hit != 'true'
working-directory: flutter
env:
DEPOT_TOOLS_UPDATE: 1
run: |
gclient sync --no-history --shallow --revision .@${{ needs.resolve-version.outputs.semver }} -R -D
- name: Install linux arm sysroot
if: steps.cache-lookup.outputs.cache-hit != 'true' && runner.os == 'Linux'
working-directory: flutter/engine/src/build/linux/sysroot_scripts
run: |
./install-sysroot.py --arch=arm
./install-sysroot.py --arch=arm64
./install-sysroot.py --arch=amd64
- name: Delete unneeded dependencies
if: steps.cache-lookup.outputs.cache-hit != 'true'
working-directory: flutter/engine/
run: |
rm -rf src/fuchsia
- name: Prune git history
if: steps.cache-lookup.outputs.cache-hit != 'true'
working-directory: flutter
run: |
for FILE in $(find . -type d -name .git)
do
pushd "$FILE/.."
git rev-parse HEAD > .git/shallow
git tag -d $(git tag -l) || true
for ref in $(git for-each-ref --format="%(refname)")
do
git update-ref -d "$ref"
done
git remote remove origin
git reflog expire --expire=all --all
git gc --prune=all
popd
done
- uses: actions/cache/save@v4
if: steps.cache-lookup.outputs.cache-hit != 'true'
env:
ZSTD_CLEVEL: 12
with:
path: flutter
key: flutter-${{ needs.resolve-version.outputs.hash }}-${{ runner.os }}-${{ runner.arch }}
load-matrix:
name: 'Generate build matrix'
runs-on: ubuntu-latest
container:
image: dart:3.4
outputs:
matrix: ${{ steps.load-matrix.outputs.matrix }}
steps:
# checkout
- uses: actions/checkout@v4
- working-directory: workflow_tool
run: |
dart pub get
# execute the workflow_tool to generate the matrix and store in matrix output variable
- name: Load matrix
working-directory: workflow_tool
id: load-matrix
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "matrix<<$EOF" >> "$GITHUB_OUTPUT"
dart run bin/workflow_tool.dart >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Test load matrix
run: |
apt-get update && apt-get install -y jq
echo "::group::raw matrix"
echo '${{ steps.load-matrix.outputs.matrix }}'
echo "::endgroup::"
echo "::group::jq prettify matrix"
echo '${{ steps.load-matrix.outputs.matrix }}' | jq .
echo "::endgroup::"
echo "::group::parsed & serialized matrix"
echo '${{ toJson(fromJson(steps.load-matrix.outputs.matrix)) }}'
echo "::endgroup::"
echo "::group::jq prettify parsed & serialized matrix"
echo '${{ toJson(fromJson(steps.load-matrix.outputs.matrix)) }}' | jq .
echo "::endgroup::"
build:
name: ${{ matrix.job-name }}
runs-on: ${{ matrix.os }}
needs: [ resolve-version, populate-engine-src-cache, load-matrix ]
strategy:
matrix:
include: ${{ fromJson(needs.load-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Log engine version & Build config
run: |
echo '*** flutter commit hash: ***'
echo ${{ needs.resolve-version.outputs.hash }}
echo '*** flutter version: ***'
echo ${{ needs.resolve-version.outputs.semver }}
echo '*** runner config: ***'
echo matrix.os: ${{ matrix.os }}
echo matrix.os-nice: ${{ matrix.os-nice }}
echo runner.os: ${{ runner.os }}
echo runner.arch: ${{ runner.arch }}
echo '*** target config: ***'
echo artifact name: ${{ matrix.artifact-name }}
echo cpu: ${{ matrix.cpu }}
echo arm-cpu: ${{ matrix.arm-cpu }}
echo arm-tune: ${{ matrix.arm-tune }}
echo '*** engine config: ***'
echo build-engine: ${{ matrix.build-engine }}
echo flavor: ${{ matrix.flavor }}
echo runtime-mode: ${{ matrix.runtime-mode }}
echo unoptimized: ${{ matrix.unoptimized }}
echo split debug symbols: ${{ matrix.split-debug-symbols }}
echo no-stripped: ${{ matrix.nostripped }}
echo '*** gen_snapshot config: ***'
echo flavor: ${{ matrix.flavor }}
echo runtime-mode: ${{ matrix.runtime-mode }}
echo build-arm-gen-snapshot: ${{ matrix.build-arm-gen-snapshot }}
echo build-arm64-gen-snapshot: ${{ matrix.build-arm64-gen-snapshot }}
echo build-x64-gen-snapshot: ${{ matrix.build-x64-gen-snapshot }}
echo build-riscv64-gen-snapshot: ${{ matrix.build-riscv64-gen-snapshot }}
echo arm-gen-snapshot-path: ${{ matrix.arm-gen-snapshot-path }}
echo arm64-gen-snapshot-path: ${{ matrix.arm64-gen-snapshot-path }}
echo x64-gen-snapshot-path: ${{ matrix.x64-gen-snapshot-path }}
echo riscv64-gen-snapshot-path: ${{ matrix.riscv64-gen-snapshot-path }}
echo build-universal: ${{ matrix.build-universal }}
echo "GITHUB_WORKSPACE_UNIX=$(realpath .)" >> $GITHUB_ENV
echo "BUILD_DIR=$(realpath .)/flutter/engine/src/out/build" >> $GITHUB_ENV
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
# The engine scripts don't provide a sysroot for RISC-V 64,
# so we rely on the headers/libs provided by the gcc-riscv64-linux-gnu
# cross toolchain.
if ${{ matrix.build-riscv64-gen-snapshot || (matrix.build-engine && matrix.cpu == 'riscv64') }}; then
sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
fi
- name: Install dependencies (MacOS)
if: runner.os == 'macOS'
run: |
brew install ninja
- name: Install dependencies (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install ninja
- name: Cache depot tools
id: cache-depot-tools
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/depot_tools
key: ${{ runner.os }}-${{ runner.arch }}-depot-tools
- name: Clone depot tools
if: steps.cache-depot-tools.outputs.cache-hit != 'true'
working-directory: ${{ github.workspace }}
run: |
git clone --depth 1 \
https://chromium.googlesource.com/chromium/tools/depot_tools.git \
./depot_tools
- name: add depot_tools to path (unix)
if: runner.os != 'Windows'
run: |
echo "${{ github.workspace }}/depot_tools" >> $GITHUB_PATH
- name: add depot_tools to path (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
echo "${{ github.workspace }}\depot_tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Run gclient --version
env:
DEPOT_TOOLS_UPDATE: 1
run: |
gclient --version
- name: Download cached engine sources
uses: actions/cache/restore@v4
id: cache
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 10
with:
path: flutter
key: flutter-${{ needs.resolve-version.outputs.hash }}-${{ runner.os }}-${{ runner.arch }}
fail-on-cache-miss: true
- name: Apply patches
working-directory: flutter
# use git apply instead of git am to avoid `Committer identity unknown` error
run: |
echo Applying patches...
git apply $GITHUB_WORKSPACE_UNIX/patches/*.patch
git status
if [ -d "$GITHUB_WORKSPACE_UNIX/dart-patches" ]; then
pushd engine/src/flutter/third_party/dart
git apply $GITHUB_WORKSPACE_UNIX/dart-patches/*.patch
git status
popd
fi
if [ -d "$GITHUB_WORKSPACE_UNIX/abseil-patches" ]; then
pushd engine/src/flutter/third_party/abseil-cpp
git am $GITHUB_WORKSPACE_UNIX/abseil-patches/*.patch
git status
popd
fi
# This can't be done in the prepopulate step since on MacOS, it depends
# on a buildroot patch.
#
# We actually don't need the sysroots to build the gen_snapshots,
# but configuring will fail if they're missing.
#
# That's why the RISC-V gen_snapshots build fine, even though it
# doesn't have a sysroot.
- name: Download linux sysroot
working-directory: flutter/engine/src/build/linux/sysroot_scripts
if: matrix.cpu && matrix.cpu != 'riscv64' && runner.os == 'macOS'
timeout-minutes: 5
run: |
./install-sysroot.py --arch=${{ matrix.cpu == 'x64' && 'amd64' || matrix.cpu }}
- name: Configure engine
working-directory: flutter/engine/src
run: |
./flutter/tools/gn \
${{ matrix.runtime-mode && format('--runtime-mode {0}', matrix.runtime-mode) || '' }} \
${{ matrix.cpu && '--target-os linux' || '' }} \
${{ matrix.cpu && format('--linux-cpu {0}', matrix.cpu) || '' }} \
--arm-float-abi hard \
--target-dir build \
--embedder-for-target \
--disable-desktop-embeddings \
--no-build-glfw-shell \
--no-build-embedder-examples \
--no-enable-unittests \
--no-goma \
${{ matrix.unoptimized && '--unoptimized' || ''}} \
${{ matrix.nostripped && '--no-stripped' || ''}} \
${{ matrix.arm-cpu && format('--gn-args ''arm_cpu="{0}"''', matrix.arm-cpu) || '' }} \
${{ matrix.arm-tune && format('--gn-args ''arm_tune="{0}"''', matrix.arm-tune) || '' }}
- name: Build engine
working-directory: flutter/engine/src/out/build
run: |
ninja \
${{ matrix.build-engine && 'libflutter_engine.so' || '' }} \
${{ matrix.build-x64-gen-snapshot && matrix.x64-gen-snapshot-path || '' }} \
${{ matrix.build-arm-gen-snapshot && matrix.arm-gen-snapshot-path || '' }} \
${{ matrix.build-arm64-gen-snapshot && matrix.arm64-gen-snapshot-path || '' }} \
${{ matrix.build-riscv64-gen-snapshot && matrix.riscv64-gen-snapshot-path || '' }} \
${{ matrix.build-universal && 'flutter_embedder.h icudtl.dat' || '' }}
- name: Add flutter.version and dart-sdk.version file
if: matrix.build-universal
run: |
pushd $GITHUB_WORKSPACE_UNIX/flutter
git rev-parse HEAD > $BUILD_DIR/flutter.version
popd
pushd $GITHUB_WORKSPACE_UNIX/flutter/engine/src/flutter/third_party/dart
git rev-parse HEAD > $BUILD_DIR/dart-sdk.version
popd
- name: Split debug symbols
if: matrix.build-engine && matrix.split-debug-symbols
working-directory: ${{ github.workspace }}/flutter/engine/src/out/build/
run: |
OBJCOPY="$GITHUB_WORKSPACE_UNIX/flutter/engine/src/flutter/buildtools/linux-x64/clang/bin/llvm-objcopy"
$OBJCOPY --only-keep-debug libflutter_engine.so libflutter_engine.dbgsyms
$OBJCOPY --strip-debug libflutter_engine.so
$OBJCOPY --add-gnu-debuglink=libflutter_engine.dbgsyms libflutter_engine.so
- name: Package engine
if: matrix.build-engine
run: |
mkdir -p pkg-engine
pushd pkg-engine
cp $BUILD_DIR/libflutter_engine.so .
tar -cJvf ../engine-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz *
- name: Package engine debug symbols
if: matrix.build-engine && matrix.split-debug-symbols
run: |
mkdir -p pkg-engine-dbgsyms
pushd pkg-engine-dbgsyms
cp \
$BUILD_DIR/compile_commands.json \
$BUILD_DIR/libflutter_engine.dbgsyms \
.
tar -cJvf ../engine-dbgsyms-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz *
- name: Package x64 gen_snapshot
if: matrix.build-x64-gen-snapshot
run: |
mkdir -p pkg-x64-gen-snapshot
pushd pkg-x64-gen-snapshot
cp $BUILD_DIR/${{ matrix.x64-gen-snapshot-path }} $BUILD_DIR/compile_commands.json .
tar -cJvf ../gen-snapshot-${{ runner.os }}-X64-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz *
- name: Package arm gen_snapshot
if: matrix.build-arm-gen-snapshot
run: |
mkdir -p pkg-arm-gen-snapshot
pushd pkg-arm-gen-snapshot
cp $BUILD_DIR/${{ matrix.arm-gen-snapshot-path }} $BUILD_DIR/compile_commands.json .
tar -cJvf ../gen-snapshot-${{ runner.os }}-ARM-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz *
- name: Package arm64 gen_snapshot
if: matrix.build-arm64-gen-snapshot
run: |
mkdir -p pkg-arm64-gen-snapshot
pushd pkg-arm64-gen-snapshot
cp $BUILD_DIR/${{ matrix.arm64-gen-snapshot-path }} $BUILD_DIR/compile_commands.json .
tar -cJvf ../gen-snapshot-${{ runner.os }}-ARM64-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz *
- name: Package riscv64 gen_snapshot
if: matrix.build-riscv64-gen-snapshot
run: |
mkdir -p pkg-riscv64-gen-snapshot
pushd pkg-riscv64-gen-snapshot
cp $BUILD_DIR/${{ matrix.riscv64-gen-snapshot-path }} $BUILD_DIR/compile_commands.json .
tar -cJvf ../gen-snapshot-${{ runner.os }}-RISCV64-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz *
- name: Package universal artifacts
if: matrix.build-universal
run: |
mkdir -p pkg-universal
pushd pkg-universal
cp \
$BUILD_DIR/icudtl.dat \
$BUILD_DIR/flutter_embedder.h \
$BUILD_DIR/flutter.version \
$BUILD_DIR/dart-sdk.version \
.
tar -cJvf ../universal.tar.xz *
- name: Upload x64 gen_snapshot
if: matrix.build-x64-gen-snapshot
uses: actions/upload-artifact@v4
with:
name: gen-snapshot-${{ runner.os }}-X64-${{ matrix.artifact-name }}-${{ matrix.flavor }}
path: pkg-x64-gen-snapshot/*
- name: Upload x64 gen_snapshot (.tar.xz)
if: matrix.build-x64-gen-snapshot
uses: actions/upload-artifact@v4
with:
name: gen-snapshot-${{ runner.os }}-X64-${{ matrix.artifact-name }}-${{ matrix.flavor }}-tar-xz
path: gen-snapshot-${{ runner.os }}-X64-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz
- name: Upload arm gen_snapshot
if: matrix.build-arm-gen-snapshot
uses: actions/upload-artifact@v4
with:
name: gen-snapshot-${{ runner.os }}-ARM-${{ matrix.artifact-name }}-${{ matrix.flavor }}
path: pkg-arm-gen-snapshot/*
- name: Upload arm gen_snapshot (.tar.xz)
if: matrix.build-arm-gen-snapshot
uses: actions/upload-artifact@v4
with:
name: gen-snapshot-${{ runner.os }}-ARM-${{ matrix.artifact-name }}-${{ matrix.flavor }}-tar-xz
path: gen-snapshot-${{ runner.os }}-ARM-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz
- name: Upload arm64 gen_snapshot
if: matrix.build-arm64-gen-snapshot
uses: actions/upload-artifact@v4
with:
name: gen-snapshot-${{ runner.os }}-ARM64-${{ matrix.artifact-name }}-${{ matrix.flavor }}
path: pkg-arm64-gen-snapshot/*
- name: Upload arm64 gen_snapshot (.tar.xz)
if: matrix.build-arm64-gen-snapshot
uses: actions/upload-artifact@v4
with:
name: gen-snapshot-${{ runner.os }}-ARM64-${{ matrix.artifact-name }}-${{ matrix.flavor }}-tar-xz
path: gen-snapshot-${{ runner.os }}-ARM64-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz
- name: Upload riscv64 gen_snapshot
if: matrix.build-riscv64-gen-snapshot
uses: actions/upload-artifact@v4
with:
name: gen-snapshot-${{ runner.os }}-RISCV64-${{ matrix.artifact-name }}-${{ matrix.flavor }}
path: pkg-riscv64-gen-snapshot/*
- name: Upload riscv64 gen_snapshot (.tar.xz)
if: matrix.build-riscv64-gen-snapshot
uses: actions/upload-artifact@v4
with:
name: gen-snapshot-${{ runner.os }}-RISCV64-${{ matrix.artifact-name }}-${{ matrix.flavor }}-tar-xz
path: gen-snapshot-${{ runner.os }}-RISCV64-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz
- name: Upload engine
if: matrix.build-engine
uses: actions/upload-artifact@v4
with:
name: engine-${{ matrix.artifact-name }}-${{ matrix.flavor }}
path: pkg-engine/*
- name: Upload engine (.tar.xz)
if: matrix.build-engine
uses: actions/upload-artifact@v4
with:
name: engine-${{ matrix.artifact-name }}-${{ matrix.flavor }}-tar-xz
path: engine-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz
- name: Upload engine debug symbols
if: matrix.build-engine
uses: actions/upload-artifact@v4
with:
name: engine-dbgsyms-${{ matrix.artifact-name }}-${{ matrix.flavor }}
path: pkg-engine-dbgsyms/*
- name: Upload engine debug symbols (.tar.xz)
if: matrix.build-engine
uses: actions/upload-artifact@v4
with:
name: engine-dbgsyms-${{ matrix.artifact-name }}-${{ matrix.flavor }}-tar-xz
path: engine-dbgsyms-${{ matrix.artifact-name }}-${{ matrix.flavor }}.tar.xz
- name: Upload universal artifacts
if: matrix.build-universal
uses: actions/upload-artifact@v4
with:
name: universal
path: pkg-universal/*
- name: Upload universal artifacts (.tar.xz)
if: matrix.build-universal
uses: actions/upload-artifact@v4
with:
name: universal-tar-xz
path: universal.tar.xz
package:
name: 'Package artifacts for old engine binaries repo'
runs-on: ubuntu-latest
needs: [build, resolve-version]
strategy:
matrix:
artifact-name:
- armv7-generic
- aarch64-generic
steps:
- uses: actions/checkout@v4
- name: Log engine version & Build config
run: |
echo *** engine version: ***
echo ${{ needs.resolve-version.outputs.hash }}
echo '*** config: ***'
echo artifact name: ${{ matrix.artifact-name }}
- uses: actions/download-artifact@v4
with:
name: universal
path: universal
- uses: actions/download-artifact@v4
with:
name: engine-${{ matrix.artifact-name }}-debug_unopt
path: debug_unopt
- uses: actions/download-artifact@v4
with:
name: engine-${{ matrix.artifact-name }}-debug
path: debug
- uses: actions/download-artifact@v4
with:
name: engine-${{ matrix.artifact-name }}-profile
path: profile
- uses: actions/download-artifact@v4
with:
name: engine-${{ matrix.artifact-name }}-release
path: release
- uses: actions/download-artifact@v4
with:
name: gen-snapshot-Linux-X64-${{ matrix.artifact-name }}-profile
path: linux-gen-snapshot-profile
- uses: actions/download-artifact@v4
with:
name: gen-snapshot-Linux-X64-${{ matrix.artifact-name }}-release
path: linux-gen-snapshot-release
- uses: actions/download-artifact@v4
with:
name: gen-snapshot-macOS-X64-${{ matrix.artifact-name }}-profile
path: macos-gen-snapshot-profile
- uses: actions/download-artifact@v4
with:
name: gen-snapshot-macOS-X64-${{ matrix.artifact-name }}-release
path: macos-gen-snapshot-release
- name: Package artifacts
run: |
mkdir -p pkg
pushd pkg
mv ../debug_unopt/libflutter_engine.so ./libflutter_engine.so.debug_unopt
mv ../debug/libflutter_engine.so ./libflutter_engine.so.debug
mv ../profile/libflutter_engine.so ./libflutter_engine.so.profile
mv ../release/libflutter_engine.so ./libflutter_engine.so.release
mv ../universal/flutter_embedder.h ./flutter_embedder.h
mv ../universal/icudtl.dat ./icudtl.dat
mv ../universal/flutter.version ./flutter.version
mv ../universal/dart-sdk.version ./dart-sdk.version
# We previously copied <build-dir>/clang_x64/gen_snapshot to <build-dir>/gen_snapshot,
# so we don't need the clang_x64 part here.
mv ../linux-gen-snapshot-profile/gen_snapshot ./gen_snapshot_linux_x64_profile
mv ../linux-gen-snapshot-release/gen_snapshot ./gen_snapshot_linux_x64_release
mv ../macos-gen-snapshot-profile/gen_snapshot ./gen_snapshot_macos_x64_profile
mv ../macos-gen-snapshot-release/gen_snapshot ./gen_snapshot_macos_x64_release
# The github actions artifact uploader/downloader don't keep the file permissions, so we need to mak
# the binaries executable again.
# We tar the files afterwards though, which keeps the permissions.
chmod +x ./libflutter_engine.so* ./gen_snapshot*
tar -cJvf ../${{ matrix.artifact-name }}.tar.xz *
popd
# Show the complete file tree, and print all metadata (permissions, owner, group, filesize, last modification date)
- name: Show file tree
run: |
sudo apt-get install -y tree
tree -apugshDF
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: |
pkg/flutter.version
pkg/dart-sdk.version
pkg/flutter_embedder.h
pkg/icudtl.dat
pkg/libflutter_engine.so.debug_unopt
pkg/libflutter_engine.so.debug
pkg/libflutter_engine.so.profile
pkg/libflutter_engine.so.release
pkg/gen_snapshot_linux_x64_profile
pkg/gen_snapshot_linux_x64_release
pkg/gen_snapshot_macos_x64_profile
pkg/gen_snapshot_macos_x64_release
build-app:
name: 'Build test app'
runs-on: ${{ matrix.os }}
needs: [resolve-version, build]
if: false
strategy:
matrix:
os:
- macos-13
- ubuntu-latest
- windows-latest
artifact-name:
- armv7-generic
- aarch64-generic
- x64-generic
- pi3
- pi3-64
- pi4
- pi4-64
- riscv64-generic
flavor:
- debug_unopt
- debug
- profile
- release
exclude:
- artifact-name: pi3
flavor: debug_unopt
- artifact-name: pi3
flavor: debug
- artifact-name: pi3-64
flavor: debug_unopt
- artifact-name: pi3-64
flavor: debug
- artifact-name: pi4
flavor: debug_unopt
- artifact-name: pi4
flavor: debug
- artifact-name: pi4-64
flavor: debug_unopt
- artifact-name: pi4-64
flavor: debug
include:
- flavor: debug_unopt
runtime-mode: debug
is-aot: false
runtime-mode-flags: '--debug-unoptimized'
- flavor: debug
runtime-mode: debug
is-aot: false
runtime-mode-flags: '--debug'
- flavor: profile
runtime-mode: profile
is-aot: true
runtime-mode-flags: '--profile'
- flavor: release
runtime-mode: release
is-aot: true
runtime-mode-flags: '--release'
- artifact-name: pi3
arch: armv7
generic-arch-artifact-name: armv7-generic
target-flags: '--arch=arm --cpu=pi3'
- artifact-name: pi3-64
arch: aarch64
generic-arch-artifact-name: aarch64-generic
target-flags: '--arch=arm64 --cpu=pi3'
- artifact-name: pi4
arch: armv7
generic-arch-artifact-name: armv7-generic
target-flags: '--arch=arm --cpu=pi4'
- artifact-name: pi4-64
arch: aarch64
generic-arch-artifact-name: aarch64-generic
target-flags: '--arch=arm64 --cpu=pi4'
- artifact-name: armv7-generic
arch: armv7
generic-arch-artifact-name: armv7-generic
target-flags: '--arch=arm --cpu=generic'
- artifact-name: aarch64-generic
arch: aarch64
generic-arch-artifact-name: aarch64-generic
target-flags: '--arch=arm64 --cpu=pi3'
- artifact-name: x64-generic
arch: x64
generic-arch-artifact-name: x64-generic
target-flags: '--arch=x64'
- os: macos-13
gen-snapshot-name: 'gen_snapshot'
- os: ubuntu-latest
gen-snapshot-name: 'gen_snapshot'
- os: windows-latest
gen-snapshot-name: 'gen_snapshot.exe'
steps:
- uses: actions/checkout@v4
# TODO: Use the exact flutter version here
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: ${{ needs.resolve-version.outputs.semver }}
cache: true
- name: Determine flutter SDK path
run: |
FLUTTER_SDK_PATH=$(dirname $(dirname $(which flutter)))
echo flutter sdk path: "$FLUTTER_SDK_PATH"
echo "FLUTTER_SDK_PATH=$FLUTTER_SDK_PATH" >> $GITHUB_ENV
- name: Install flutterpi_tool
run: |
flutter pub global activate flutterpi_tool
- uses: actions/download-artifact@v4
with:
name: universal
path: universal
- uses: actions/download-artifact@v4
with:
name: engine-${{ matrix.artifact-name }}-${{ matrix.flavor }}
path: engine
- uses: actions/download-artifact@v4
if: ${{ matrix.is-aot }}
with:
name: gen-snapshot-${{ runner.os }}-${{ runner.arch }}-${{ matrix.generic-arch-artifact-name }}-${{ matrix.flavor }}
path: gen-snapshot
# Seems like this is necessary. Maybe it's not if we use a tar-file instead.
- name: Make binaries executable
run: |
chmod +x \
./engine/libflutter_engine.so \
${{ matrix.is-aot && format('./gen-snapshot/{0}', matrix.gen-snapshot-name) || '' }}
# Show the complete file tree, and print all metadata (permissions, owner, group, filesize, last modification date)
- name: Show file tree
if: runner.os == 'Linux'
run: |
sudo apt-get install -y tree
tree -apugshDF
- working-directory: test_app
if: false
run: |
flutter pub get
flutter build bundle
cp ../engine/libflutter_engine.so build/flutter_assets/libflutter_engine.so
cp ../universal/icudtl.dat build/flutter_assets/
- name: Build AOT bundle
if: matrix.is-aot && false
working-directory: test_app
run: |
$FLUTTER_SDK_PATH/bin/cache/dart-sdk/bin/dart \
$FLUTTER_SDK_PATH/bin/cache/dart-sdk/bin/snapshots/frontend_server.dart.snapshot \
--sdk-root $FLUTTER_SDK_PATH/bin/cache/artifacts/engine/common/flutter_patched_sdk${{ matrix.runtime-mode == 'release' && '_product' || '' }} \
--target=flutter \
--aot --tfa \
-Ddart.vm.product=${{ matrix.runtime-mode == 'release' && 'true' || 'false' }} \
-Ddart.vm.profile=${{ matrix.runtime-mode == 'profile' && 'true' || 'false' }} \
--packages .dart_tool/package_config.json \
--output-dill build/kernel_snapshot.dill \
--verbose \
--depfile build/kernel_snapshot.d \
package:test_app/main.dart
../gen-snapshot/${{ matrix.gen-snapshot-name }} \
--deterministic \
--snapshot_kind=app-aot-elf \
--elf=build/flutter_assets/app.so \
--strip \
${{ matrix.arch == 'armv7' && '--sim-use-hardfp' || '' }} \
--verbose \
build/kernel_snapshot.dill
- name: Copy asset bundle
if: false
run: |
cp -r test_app/build/flutter_assets app-assets
rm -rf test_app/build
- name: run `pub get`
working-directory: test_app
run: |
flutter pub get
# The Flutter Tool supports Bash on Windows, but dart global executables do not.
# We need to either invoke flutterpi_tool using `flutterpi_tool.bat` if we're on Bash & Windows,
# or we use powershell.
# I opted for powershell because that seemed like the safer option.
- name: Build test_app using flutterpi_tool (Unix)
if: runner.os != 'Windows'
working-directory: test_app
run: |
flutterpi_tool \
build ${{ matrix.target-flags }} ${{ matrix.runtime-mode-flags }} \
--verbose \
--github-artifacts-repo ${{ github.repository }} \
--github-artifacts-runid ${{ github.run_id }} \
--github-artifacts-auth-token ${{ secrets.GITHUB_TOKEN }}
- name: Build test_app using flutterpi_tool (Windows)
if: runner.os == 'Windows'
working-directory: test_app
shell: pwsh
run: |
flutterpi_tool `
build ${{ matrix.target-flags }} ${{ matrix.runtime-mode-flags }} `
--verbose `
--github-artifacts-repo ${{ github.repository }} `
--github-artifacts-runid ${{ github.run_id }} `
--github-artifacts-auth-token ${{ secrets.GITHUB_TOKEN }}
- name: Package app assets
working-directory: test_app
run: |
cp -r build/flutter_assets ../app-assets
- name: Upload app assets
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-${{ matrix.artifact-name }}-${{ matrix.flavor }}-app-assets
path: app-assets
test-app:
name: 'Test app on a Raspberry Pi'
runs-on: ${{ matrix.runner }}
needs: [build-app]
if: false
strategy:
matrix:
os:
- Linux
- macOS
- Windows
artifact-name:
# - pi3
- pi3-64
# - pi4
- pi4-64
# - armv7-generic
- aarch64-generic
# - x64-generic
- riscv64-generic
flavor:
- debug_unopt
- debug
- profile
- release
exclude:
- artifact-name: pi3-64
flavor: debug_unopt
- artifact-name: pi3-64
flavor: debug
- artifact-name: pi4-64
flavor: debug_unopt
- artifact-name: pi4-64
flavor: debug
include:
- flavor: debug_unopt
runtime-mode: debug
- flavor: debug
runtime-mode: debug
- flavor: profile
runtime-mode: profile
- flavor: release
runtime-mode: release
# - artifact-name: pi3
# runner: pi4-32
- artifact-name: pi3-64
runner: pi4-64
# - artifact-name: pi4
# runner: pi4-32
- artifact-name: pi4-64
runner: pi4-64
# - artifact-name: armv7-generic
# runner: pi4-32
- artifact-name: aarch64-generic
runner: pi4-64
# - artifact-name: x64-generic
# runner: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.artifact-name }}-${{ matrix.flavor }}-app-assets
path: app
- uses: actions/checkout@v4
with:
repository: ardera/flutter-pi
path: flutter-pi
- name: Install dependencies
if: runner.environment == 'github-hosted'
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdrm-dev libgbm-dev fonts-liberation fontconfig libsystemd-dev libinput-dev libudev-dev libxkbcommon-dev
- name: Configure
working-directory: flutter-pi
run: |
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -S. -Bbuild
- name: Build
working-directory: flutter-pi/build
run: ninja
# The app should quit with exit code 0 by itself.
- name: Run app
timeout-minutes: 3
run: |
flutter-pi/build/flutter-pi \
${{ (matrix.runtime-mode == 'release' && '--release') || (matrix.runtime-mode == 'profile' && '--profile') || '' }} \
--dummy-display --dummy-display-size 800,600 \
app
push-old-repo:
name: 'Push binaries to old engine binaries repo'
runs-on: ubuntu-latest
needs: [resolve-version, package]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: ardera/flutter-engine-binaries-for-arm
token: ${{ secrets.OLD_ENGINE_BINARIES_REPO_TOKEN }}
path: engine-binaries
ref: main
- uses: actions/download-artifact@v4
with:
name: armv7-generic
path: engine-binaries/arm
- uses: actions/download-artifact@v4
with:
name: aarch64-generic
path: engine-binaries/arm64
- working-directory: engine-binaries
run: |
mv arm/flutter_embedder.h flutter_embedder.h
rm arm64/flutter_embedder.h
rm arm/*.debug_unopt
rm arm64/*.debug_unopt
- name: Commit new stable engine version
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
cwd: ./engine-binaries
message: 'update engine binaries for flutter ${{ needs.resolve-version.outputs.semver }}'
tag: engine_${{ needs.resolve-version.outputs.hash }} --force
tag_push: '--force'
push: ${{ startsWith(github.ref, 'refs/tags/flutter/stable/') }}
release:
name: 'Publish release'
runs-on: ubuntu-latest
needs: [resolve-version, package]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: all-artifacts
- run: |
mkdir -p release-files
mv all-artifacts/*-tar-xz/* release-files/
# Show the complete file tree, and print all metadata (permissions, owner, group, filesize, last modification date)
- name: Show file tree
run: |
sudo apt-get install -y tree
tree -apugshDF
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/flutter/')
with:
name: ${{ needs.resolve-version.outputs.semver }}
body: |
| name | info | reference |
| - | - | - |
| flutter channel | ${{ needs.resolve-version.outputs.channel }} | |
| flutter version | ${{ needs.resolve-version.outputs.semver }} | [flutter/flutter@`${{ needs.resolve-version.outputs.semver }}`](https://github.com/flutter/flutter/tree/${{ needs.resolve-version.outputs.semver }}) |
fail_on_unmatched_files: true
files: |
release-files/*
prerelease: ${{ ! startsWith(github.ref, 'refs/tags/flutter/stable') }}