blob: 189d7e76347f407d1e5c23a819915115e199323d [file] [log] [blame]
#!/bin/bash
#
# Usage:
# sync_engine_artifacts_to_commit.sh <engine_commit>
#
# Prerequisites:
# 1. $ENGINE_DIR is set to the src/ directory of your flutter/engine checkout.
# 2. $FUCHSIA_EMBEDDER_DIR is set to your flutter-embedder.git checkout.
# 3. $DEPOT_TOOLS is set to your depot_tools directory.
# 4. You don't have any uncommited changes to your Engine code.
# Returns true if colors are supported.
function is-stderr-tty {
[[ -t 2 ]]
}
# Prints a line to stderr with a green INFO: prefix.
function echo-info {
if is-stderr-tty; then
echo -e >&2 "\033[1;32mINFO:\033[0m $*"
else
echo -e >&2 "INFO: $*"
fi
}
engine_revision=$1
pushd "${ENGINE_DIR}"
echo-info "Syncing ${ENGINE_DIR}/flutter to ${engine_revision}..."
pushd flutter
git checkout "${engine_revision}"
popd
echo-info "Syncing ${ENGINE_DIR} dependencies..."
gclient sync -D
buildroot_fix=c7deba3773ed645c29f4518cc3990bc02f0f53cd
pushd build
if ! git merge-base --is-ancestor "${buildroot_fix}" HEAD
then
echo-info "Cherry-picking https://github.com/flutter/buildroot/pull/552 into ${ENGINE_DIR}/build to fix embedder build for Fuchsia..."
git remote add akbiggs https://github.com/akbiggs/buildroot
git fetch akbiggs
git cherry-pick -c "${buildroot_fix}"
fi
popd
jit_snapshot_fix=d79531e15a1b04d5e68c7ad87775cb594727d7b0
pushd flutter
if ! git merge-base --is-ancestor "${jit_snapshot_fix}" HEAD
then
echo-info "Cherry-picking https://github.com/flutter/engine/pull/33189 into ${ENGINE_DIR}/flutter to work around JIT snapshot loading issue..."
git remote add akbiggs https://github.com/akbiggs/engine
git fetch akbiggs
git cherry-pick -c "${jit_snapshot_fix}"
fi
popd
# Fail on any error.
# We start failing here because the previous commands throw errors even
# when things are fine.
set -e
echo-info "Building the Flutter Engine embedding for Fuchsia (libflutter_engine.so)..."
"${ENGINE_DIR}"/flutter/tools/gn --fuchsia --embedder-for-target --unopt
out_dir="${ENGINE_DIR}"/out/fuchsia_debug_unopt_x64
"${DEPOT_TOOLS}"/ninja -C "${out_dir}"
echo-info "Copying Flutter Engine artifacts to ${FUCHSIA_EMBEDDER_DIR}/src/embedder..."
cp "${out_dir}"/libflutter_engine.so "${FUCHSIA_EMBEDDER_DIR}"/src/embedder/libflutter_engine.so
cp "${ENGINE_DIR}"/flutter/shell/platform/embedder/embedder.h "${FUCHSIA_EMBEDDER_DIR}"/src/embedder/embedder.h
echo "${engine_revision}" > "${FUCHSIA_EMBEDDER_DIR}"/src/embedder/engine_revision
echo-info "Done! Engine artifacts updated to ${engine_revision}."
popd