diff --git a/tools/3xhead_flutter_hooks.sh b/tools/3xhead_flutter_hooks.sh index a075705206d..cb4219a16fc 100755 --- a/tools/3xhead_flutter_hooks.sh +++ b/tools/3xhead_flutter_hooks.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # # Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file # for details. All rights reserved. Use of this source code is governed by a @@ -12,11 +12,14 @@ # (run inside the root of a flutter engine checkout) set -e -if [ ! -e src/third_party/dart ]; then - echo "$0: error: "\ - "This script must be run from the root of a flutter engine checkout" >&2 - exit 1 -fi + +DIR=$(dirname -- "$(which -- "$0")") +. $DIR/patches/utils.sh + +ensure_in_checkout_root + +# Apply patches to the Flutter Framework if needed. +src/third_party/dart/tools/patches/flutter-flutter/apply.sh # Apply patches to the Flutter Engine if needed. src/third_party/dart/tools/patches/flutter-engine/apply.sh diff --git a/tools/patches/flutter-engine/apply.sh b/tools/patches/flutter-engine/apply.sh index b449af1d9f0..d1105a50f19 100755 --- a/tools/patches/flutter-engine/apply.sh +++ b/tools/patches/flutter-engine/apply.sh @@ -19,13 +19,13 @@ # (run inside the root of a flutter engine checkout) set -e -if [ ! -e src/third_party/dart ]; then - echo "$0: error: "\ - "This script must be run from the root of a flutter engine checkout" >&2 - exit 1 -fi -pinned_dart_sdk=$(grep -E "'dart_revision':.*" src/flutter/DEPS | - sed -E "s/.*'([^']*)',/\1/") + +DIR=$(dirname -- "$(which -- "$0")") +. $DIR/../utils.sh + +ensure_in_checkout_root + +pinned_dart_sdk=$(get_pinned_dart_version) need_runhooks=false patch=src/third_party/dart/tools/patches/flutter-engine/${pinned_dart_sdk}.flutter.patch if [ -e "$patch" ]; then diff --git a/tools/patches/flutter-engine/create.sh b/tools/patches/flutter-engine/create.sh index d9bc6fdab58..15dad921ed5 100755 --- a/tools/patches/flutter-engine/create.sh +++ b/tools/patches/flutter-engine/create.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # # Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file # for details. All rights reserved. Use of this source code is governed by a @@ -15,13 +15,13 @@ # (run inside the root of a flutter engine checkout) set -e -if [ ! -e src/third_party/dart ]; then - echo "$0: error: "\ - "This script must be run from the root of a flutter engine checkout" >&2 - exit 1 -fi -pinned_dart_sdk=$(grep -E "'dart_revision':.*" src/flutter/DEPS | - sed -E "s/.*'([^']*)',/\1/") + +DIR=$(dirname -- "$(which -- "$0")") +. $DIR/../utils.sh + +ensure_in_checkout_root + +pinned_dart_sdk=$(get_pinned_dart_version) patch=src/third_party/dart/tools/patches/flutter-engine/$pinned_dart_sdk.patch rm -f src/third_party/dart/tools/patches/flutter-engine/*.patch (cd src/flutter && git diff) > $patch diff --git a/tools/patches/flutter-flutter/15f2b92cce916982b7dd8ce658bbf2a465c06ba4.patch b/tools/patches/flutter-flutter/15f2b92cce916982b7dd8ce658bbf2a465c06ba4.patch new file mode 100644 index 00000000000..00aee001347 --- /dev/null +++ b/tools/patches/flutter-flutter/15f2b92cce916982b7dd8ce658bbf2a465c06ba4.patch @@ -0,0 +1,59 @@ +diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart +index 821cb475b..c85da65b7 100644 +--- a/packages/flutter/lib/src/painting/text_style.dart ++++ b/packages/flutter/lib/src/painting/text_style.dart +@@ -822,7 +822,7 @@ class TextStyle extends Diagnosticable { + fontStyle: fontStyle, + fontFamily: fontFamily, + fontSize: (fontSize ?? _defaultFontSize) * textScaleFactor, +- lineHeight: height, ++ height: height, + maxLines: maxLines, + ellipsis: ellipsis, + locale: locale, +diff --git a/packages/flutter/lib/src/rendering/error.dart b/packages/flutter/lib/src/rendering/error.dart +index 03ab64749..a8552b37b 100644 +--- a/packages/flutter/lib/src/rendering/error.dart ++++ b/packages/flutter/lib/src/rendering/error.dart +@@ -95,7 +95,7 @@ class RenderErrorBox extends RenderBox { + + /// The paragraph style to use when painting [RenderErrorBox] objects. + static ui.ParagraphStyle paragraphStyle = ui.ParagraphStyle( +- lineHeight: 1.0, ++ height: 1.0, + ); + + @override +diff --git a/packages/flutter/test/painting/text_style_test.dart b/packages/flutter/test/painting/text_style_test.dart +index 4d65194e9..f26570aec 100644 +--- a/packages/flutter/test/painting/text_style_test.dart ++++ b/packages/flutter/test/painting/text_style_test.dart +@@ -169,22 +169,22 @@ void main() { + expect(ts2.toString(), 'TextStyle(color: Color(0xff00ff00), decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: FontWeight.w800, fontStyle: unspecified, textBaseline: unspecified, fontFamily: unspecified, fontFamilyFallback: unspecified, fontSize: 10.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 100.0x, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified)'); + + final ui.ParagraphStyle ps2 = s2.getParagraphStyle(textAlign: TextAlign.center); +- expect(ps2, equals(ui.ParagraphStyle(textAlign: TextAlign.center, fontWeight: FontWeight.w800, fontSize: 10.0, lineHeight: 100.0))); +- expect(ps2.toString(), 'ParagraphStyle(textAlign: TextAlign.center, textDirection: unspecified, fontWeight: FontWeight.w800, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 10.0, lineHeight: 100.0x, ellipsis: unspecified, locale: unspecified)'); ++ expect(ps2, equals(ui.ParagraphStyle(textAlign: TextAlign.center, fontWeight: FontWeight.w800, fontSize: 10.0, height: 100.0))); ++ expect(ps2.toString(), 'ParagraphStyle(textAlign: TextAlign.center, textDirection: unspecified, fontWeight: FontWeight.w800, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 10.0, height: 100.0x, ellipsis: unspecified, locale: unspecified)'); + final ui.ParagraphStyle ps5 = s5.getParagraphStyle(); +- expect(ps5, equals(ui.ParagraphStyle(fontWeight: FontWeight.w700, fontSize: 12.0, lineHeight: 123.0))); +- expect(ps5.toString(), 'ParagraphStyle(textAlign: unspecified, textDirection: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 12.0, lineHeight: 123.0x, ellipsis: unspecified, locale: unspecified)'); ++ expect(ps5, equals(ui.ParagraphStyle(fontWeight: FontWeight.w700, fontSize: 12.0, height: 123.0))); ++ expect(ps5.toString(), 'ParagraphStyle(textAlign: unspecified, textDirection: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 12.0, height: 123.0x, ellipsis: unspecified, locale: unspecified)'); + }); + + + test('TextStyle with text direction', () { + final ui.ParagraphStyle ps6 = const TextStyle().getParagraphStyle(textDirection: TextDirection.ltr); + expect(ps6, equals(ui.ParagraphStyle(textDirection: TextDirection.ltr, fontSize: 14.0))); +- expect(ps6.toString(), 'ParagraphStyle(textAlign: unspecified, textDirection: TextDirection.ltr, fontWeight: unspecified, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 14.0, lineHeight: unspecified, ellipsis: unspecified, locale: unspecified)'); ++ expect(ps6.toString(), 'ParagraphStyle(textAlign: unspecified, textDirection: TextDirection.ltr, fontWeight: unspecified, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 14.0, height: unspecified, ellipsis: unspecified, locale: unspecified)'); + + final ui.ParagraphStyle ps7 = const TextStyle().getParagraphStyle(textDirection: TextDirection.rtl); + expect(ps7, equals(ui.ParagraphStyle(textDirection: TextDirection.rtl, fontSize: 14.0))); +- expect(ps7.toString(), 'ParagraphStyle(textAlign: unspecified, textDirection: TextDirection.rtl, fontWeight: unspecified, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 14.0, lineHeight: unspecified, ellipsis: unspecified, locale: unspecified)'); ++ expect(ps7.toString(), 'ParagraphStyle(textAlign: unspecified, textDirection: TextDirection.rtl, fontWeight: unspecified, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 14.0, height: unspecified, ellipsis: unspecified, locale: unspecified)'); + }); + + test('TextStyle using package font', () { diff --git a/tools/patches/flutter-flutter/apply.sh b/tools/patches/flutter-flutter/apply.sh new file mode 100755 index 00000000000..47043f05e13 --- /dev/null +++ b/tools/patches/flutter-flutter/apply.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +# for details. All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. +# +# This script applies a patch, if available, to the Flutter Framework. Only a +# patch is applied for the particular engine.version the flutter framework is +# using. +# +# Usage: src/third_party/dart/tools/patches/flutter-flutter/apply.sh +# (run inside the root of a flutter checkout) + +set -e + +DIR=$(dirname -- "$(which -- "$0")") +. $DIR/../utils.sh + +ensure_in_checkout_root + +pinned_engine_version=$(get_pinned_flutter_engine_version) +patch=src/third_party/dart/tools/patches/flutter-flutter/${pinned_engine_version}.patch +if [ -e "$patch" ]; then + (cd flutter && git apply ../$patch) +fi diff --git a/tools/patches/flutter-flutter/create.sh b/tools/patches/flutter-flutter/create.sh new file mode 100755 index 00000000000..f0f8511186d --- /dev/null +++ b/tools/patches/flutter-flutter/create.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +# for details. All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. +# +# This script produces a patch to the Flutter Framework from the local +# uncommitted changes in the current engine checkout. +# +# Usage: src/third_party/dart/tools/patches/flutter-flutter/create.sh +# (run inside the root of a flutter engine checkout) + +set -e + +DIR=$(dirname -- "$(which -- "$0")") +. $DIR/../utils.sh + +ensure_in_checkout_root + +pinned_engine_version=$(get_pinned_flutter_engine_version) +patch=src/third_party/dart/tools/patches/flutter-flutter/$pinned_engine_version.patch +rm -f src/third_party/dart/tools/patches/flutter-flutter/*.patch +(cd flutter && git diff) > $patch +if [ ! -s $patch ]; then + rm $patch +fi diff --git a/tools/patches/utils.sh b/tools/patches/utils.sh new file mode 100644 index 00000000000..99e6dce0f3a --- /dev/null +++ b/tools/patches/utils.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +# for details. All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. + +die { + echo "$0: error: "\ + "This script must be run from the root of a flutter engine checkout "\ + "(containing src/flutter/ and flutter/)" >&2 + exit 1 +} + +ensure_in_checkout_root { + set -e + if [ ! -e src/third_party/dart ]; then + die + fi + + if [ ! -e flutter ]; then + die + fi +} + +get_pinned_dart_version { + pinned_dart_sdk=$(grep -E "'dart_revision':.*" src/flutter/DEPS | + sed -E "s/.*'([^']*)',/\1/") + echo -n $pinned_dart_sdk +} + +get_pinned_flutter_engine_version { + pinned_engine_version=$(cat flutter/bin/internal/engine.version | sed 's/[[:space:]]//') + echo -n $pinned_engine_version +}