Skip to content

Commit

Permalink
Generate fonts in the expected location. (flutter#31575)
Browse files Browse the repository at this point in the history
* 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: flutter/flutter#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.
  • Loading branch information
godofredoc authored Feb 24, 2022
1 parent 36021fa commit cfc692b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build/archives/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
21 changes: 14 additions & 7 deletions common/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tools/font-subset/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 15 additions & 2 deletions tools/font-subset/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,30 @@
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')
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)

Expand Down
2 changes: 1 addition & 1 deletion web_sdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit cfc692b

Please sign in to comment.