From 12053d00ea93299dc5c25cb2f6daae3c7fde5ebc Mon Sep 17 00:00:00 2001 From: Alexander Biggs Date: Mon, 27 Sep 2021 20:53:02 -0400 Subject: [PATCH] [fuchsia] Small shell scripts for workflow. (flutter/engine#28823) --- .../fuchsia/devshell/branch_from_fuchsia.sh | 30 +++++++++++++++++++ .../tools/fuchsia/devshell/lib/vars.sh | 9 ++++++ .../tools/fuchsia/devshell/sync_to_fuchsia.sh | 21 +++++++++++++ 3 files changed, 60 insertions(+) create mode 100755 engine/src/flutter/tools/fuchsia/devshell/branch_from_fuchsia.sh create mode 100755 engine/src/flutter/tools/fuchsia/devshell/sync_to_fuchsia.sh diff --git a/engine/src/flutter/tools/fuchsia/devshell/branch_from_fuchsia.sh b/engine/src/flutter/tools/fuchsia/devshell/branch_from_fuchsia.sh new file mode 100755 index 00000000000..ab548d0219c --- /dev/null +++ b/engine/src/flutter/tools/fuchsia/devshell/branch_from_fuchsia.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +### Starts a new branch from Fuchsia's checkout of the Flutter engine. +### This is necessary to avoid skew between the version of the Dart VM used in +### the flutter_runner and the version of the Dart SDK and VM used by the +### Flutter toolchain. See +### https://github.com/flutter/flutter/wiki/Compiling-the-engine#important-dart-version-synchronization-on-fuchsia +### for more details. +### +### Example: +### $ ./branch_from_fuchsia.sh my_new_feature_branch + +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? + +ensure_fuchsia_dir + +engine-info "Syncing to Fuchsia's checkout of the Flutter engine." +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/sync_to_fuchsia.sh || exit $? + +engine-info "Creating new branch '$1'." +git checkout -b $1 +if [ $? -ne 0 ] +then + engine-error "Failed to create new branch '$1'. Restoring previous checkout." + git checkout - + exit $? +fi diff --git a/engine/src/flutter/tools/fuchsia/devshell/lib/vars.sh b/engine/src/flutter/tools/fuchsia/devshell/lib/vars.sh index e77b1313163..44467f8d728 100644 --- a/engine/src/flutter/tools/fuchsia/devshell/lib/vars.sh +++ b/engine/src/flutter/tools/fuchsia/devshell/lib/vars.sh @@ -29,6 +29,15 @@ function engine-is-stderr-tty { [[ -t 2 ]] } +# engine-info prints a line to stderr with a green INFO: prefix. +function engine-info { + if engine-is-stderr-tty; then + echo -e >&2 "\033[1;32mINFO:\033[0m $*" + else + echo -e >&2 "INFO: $*" + fi +} + # engine-error prints a line to stderr with a red ERROR: prefix. function engine-error { if engine-is-stderr-tty; then diff --git a/engine/src/flutter/tools/fuchsia/devshell/sync_to_fuchsia.sh b/engine/src/flutter/tools/fuchsia/devshell/sync_to_fuchsia.sh new file mode 100755 index 00000000000..cb7fe78b41b --- /dev/null +++ b/engine/src/flutter/tools/fuchsia/devshell/sync_to_fuchsia.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +### Checks out the version of Flutter engine in your Fuchsia source tree. +### This is necessary to avoid skew between the version of the Dart VM used in +### the flutter_runner and the version of the Dart SDK and VM used by the +### Flutter toolchain. See +### https://github.com/flutter/flutter/wiki/Compiling-the-engine#important-dart-version-synchronization-on-fuchsia +### for more details. +### +### Example: +### $ ./sync_to_fuchsia.sh + +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? + +ensure_fuchsia_dir + +fuchsia_flutter_git_revision="$(cat $FUCHSIA_DIR/integration/jiri.lock | grep -A 1 "\"package\": \"flutter/fuchsia\"" | grep "git_revision" | tr ":" "\n" | sed -n 3p | tr "\"" "\n" | sed -n 1p)" +git checkout $fuchsia_flutter_git_revision