From 229e5b9a1d63f15418a6deeccd02c0cc95c085ff Mon Sep 17 00:00:00 2001 From: godofredoc Date: Wed, 23 Feb 2022 19:35:20 -0800 Subject: [PATCH] Generate fonts in the expected location. (flutter/engine#31575) * Generate fonts in the expected location. Fonts-subset is generated directly in out/../zip_archives but the final destination is expected to be inside a folder like linux-x64. This PR generates the file directly in the expected path. Bug: https://github.com/flutter/flutter/issues/81855 * Fix font zip tests. * Revert changes to run_tests.py * Update host_os_cpu_name variable to report darwin for mac. * Fix variable names. * Calculate prebuilts path using mac instead of darwin. * Add platform to fontset path. * Fix platforms map. * Add debugging. * Add win32 to the map of artifact locations. * Use full_platform_name instead of host_os_name. * Use x32 for windows font binaries. * Fix paths for debug version in windows. * Use x64 for win32. * Remove additional logging. * Add linux2 to map of platforms. --- engine/src/flutter/build/archives/BUILD.gn | 2 +- engine/src/flutter/common/config.gni | 21 ++++++++++++------- engine/src/flutter/tools/font-subset/BUILD.gn | 2 +- engine/src/flutter/tools/font-subset/test.py | 17 +++++++++++++-- engine/src/flutter/web_sdk/BUILD.gn | 2 +- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/engine/src/flutter/build/archives/BUILD.gn b/engine/src/flutter/build/archives/BUILD.gn index 672a08d9dda..1afec65862c 100644 --- a/engine/src/flutter/build/archives/BUILD.gn +++ b/engine/src/flutter/build/archives/BUILD.gn @@ -1,7 +1,7 @@ import("//flutter/build/zip_bundle.gni") zip_bundle("artifacts") { - output = "$host_os_cpu_name/artifacts.zip" + output = "$full_platform_name/artifacts.zip" deps = [ "//flutter/flutter_frontend_server:frontend_server", "//flutter/lib/snapshot:generate_snapshot_bin", diff --git a/engine/src/flutter/common/config.gni b/engine/src/flutter/common/config.gni index 18b8fa63850..45e3cc962e5 100644 --- a/engine/src/flutter/common/config.gni +++ b/engine/src/flutter/common/config.gni @@ -68,14 +68,14 @@ if (is_ios || is_mac) { # A combo of host os name and cpu is used in several locations to # generate the names of the archived artifacts. -_host_os_name = host_os -if (_host_os_name == "mac") { - _host_os_name = "macos" -} else if (_host_os_name == "win" || _host_os_name == "winuwp") { - _host_os_name = "windows" +_platform_name = host_os +if (_platform_name == "mac") { + _platform_name = "darwin" +} else if (_platform_name == "win" || _platform_name == "winuwp") { + _platform_name = "windows" } -host_os_cpu_name = "$_host_os_name-$host_cpu" +full_platform_name = "$_platform_name-$host_cpu" # Prebuilt Dart SDK location @@ -87,8 +87,15 @@ if (flutter_prebuilt_dart_sdk) { _target_os_name = "windows" } + _host_os_name = host_os + if (_host_os_name == "mac") { + _host_os_name = "macos" + } else if (_host_os_name == "win" || _host_os_name == "winuwp") { + _host_os_name = "windows" + } + _target_prebuilt_dart_sdk_config = "$_target_os_name-$target_cpu" - _host_prebuilt_dart_sdk_config = "$host_os_cpu_name" + _host_prebuilt_dart_sdk_config = "$_host_os_name-$host_cpu" _target_prebuilt_dart_sdk_archive = "//flutter/prebuilts/dartsdk-$_target_prebuilt_dart_sdk_config-release.zip" _host_prebuilt_dart_sdk_archive = "//flutter/prebuilts/dartsdk-$_host_prebuilt_dart_sdk_config-release.zip" diff --git a/engine/src/flutter/tools/font-subset/BUILD.gn b/engine/src/flutter/tools/font-subset/BUILD.gn index c6c1486a150..ef647fff570 100644 --- a/engine/src/flutter/tools/font-subset/BUILD.gn +++ b/engine/src/flutter/tools/font-subset/BUILD.gn @@ -41,7 +41,7 @@ generated_file("_font-subset-license") { } zip_bundle("font-subset") { - output = "font-subset.zip" + output = "${full_platform_name}/font-subset.zip" font_subset_bin = "font-subset" if (is_win) { diff --git a/engine/src/flutter/tools/font-subset/test.py b/engine/src/flutter/tools/font-subset/test.py index 977dec352be..fe49e67465e 100755 --- a/engine/src/flutter/tools/font-subset/test.py +++ b/engine/src/flutter/tools/font-subset/test.py @@ -14,6 +14,19 @@ import subprocess import sys from zipfile import ZipFile + +# Dictionary to map the platform name to the output directory +# of the font artifacts. +PLATFORM_2_PATH = { + 'darwin': 'darwin-x64', + 'linux': 'linux-x64', + 'linux2': 'linux-x64', + 'cygwin': 'windows-x64', + 'win': 'windows-x64', + 'win32': 'windows-x64', +} + + SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, '..', '..', '..')) MATERIAL_TTF = os.path.join(SCRIPT_DIR, 'fixtures', 'MaterialIcons-Regular.ttf') @@ -21,10 +34,10 @@ IS_WINDOWS = sys.platform.startswith(('cygwin', 'win')) EXE = '.exe' if IS_WINDOWS else '' BAT = '.bat' if IS_WINDOWS else '' FONT_SUBSET = os.path.join(SRC_DIR, 'out', 'host_debug', 'font-subset' + EXE) -FONT_SUBSET_ZIP = os.path.join(SRC_DIR, 'out', 'host_debug', 'zip_archives', 'font-subset.zip') +FONT_SUBSET_ZIP = os.path.join(SRC_DIR, 'out', 'host_debug', 'zip_archives', PLATFORM_2_PATH.get(sys.platform, ''), 'font-subset.zip') if not os.path.isfile(FONT_SUBSET): FONT_SUBSET = os.path.join(SRC_DIR, 'out', 'host_debug_unopt', 'font-subset' + EXE) - FONT_SUBSET_ZIP = os.path.join(SRC_DIR, 'out', 'host_debug_unopt', 'zip_archives', 'font-subset.zip') + FONT_SUBSET_ZIP = os.path.join(SRC_DIR, 'out', 'host_debug_unopt', 'zip_archives', PLATFORM_2_PATH.get(sys.platform, ''), 'font-subset.zip') if not os.path.isfile(FONT_SUBSET): raise Exception('Could not locate font-subset%s in host_debug or host_debug_unopt - build before running this script.' % EXE) diff --git a/engine/src/flutter/web_sdk/BUILD.gn b/engine/src/flutter/web_sdk/BUILD.gn index 96688bbad0e..d285b7e1f9b 100644 --- a/engine/src/flutter/web_sdk/BUILD.gn +++ b/engine/src/flutter/web_sdk/BUILD.gn @@ -568,7 +568,7 @@ _kernel_worker("flutter_dartdevc_kernel_sdk_outline_sound") { # Archives Flutter Web SDK if (!is_fuchsia) { zip_bundle("flutter_web_sdk_archive") { - output = "flutter-web-sdk-${host_os_cpu_name}.zip" + output = "flutter-web-sdk-${full_platform_name}.zip" deps = [ ":flutter_dartdevc_canvaskit_html_kernel_sdk", ":flutter_dartdevc_canvaskit_html_kernel_sdk_sound",