1# Copyright (c) 2021 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/ohos.gni") 15import("//foundation/arkui/ace_engine/ace_config.gni") 16import("//third_party/flutter/flutter_config.gni") 17 18config("thirdparty_lib_txt_config") { 19 cflags_cc = [ 20 "-Wno-implicit-fallthrough", 21 "-fvisibility-inlines-hidden", 22 "-Os", 23 ] 24} 25 26template("thirdparty_lib_txt") { 27 forward_variables_from(invoker, "*") 28 29 ohos_source_set(target_name) { 30 part_name = flutter_part 31 subsystem_name = flutter_subsystem 32 defines += invoker.defines 33 cflags_cc += invoker.cflags_cc 34 35 configs = [ 36 "$ace_flutter_engine_root/icu:icu_config_$platform", 37 "$ace_flutter_engine_root:flutter_config", 38 ":thirdparty_lib_txt_config", 39 ] 40 if (platform == "android") { 41 configs += [ "$ace_root/build:reduce_eh_frame_config" ] 42 } 43 44 sources = [ 45 "$flutter_root/engine/flutter/third_party/txt/src/log/log.cc", 46 "$flutter_root/engine/flutter/third_party/txt/src/minikin/CmapCoverage.cpp", 47 "$flutter_root/engine/flutter/third_party/txt/src/minikin/Emoji.cpp", 48 "$flutter_root/engine/flutter/third_party/txt/src/minikin/FontCollection.cpp", 49 "$flutter_root/engine/flutter/third_party/txt/src/minikin/FontFamily.cpp", 50 "$flutter_root/engine/flutter/third_party/txt/src/minikin/FontLanguage.cpp", 51 "$flutter_root/engine/flutter/third_party/txt/src/minikin/FontLanguageListCache.cpp", 52 "$flutter_root/engine/flutter/third_party/txt/src/minikin/FontUtils.cpp", 53 "$flutter_root/engine/flutter/third_party/txt/src/minikin/GraphemeBreak.cpp", 54 "$flutter_root/engine/flutter/third_party/txt/src/minikin/HbFontCache.cpp", 55 "$flutter_root/engine/flutter/third_party/txt/src/minikin/Hyphenator.cpp", 56 "$flutter_root/engine/flutter/third_party/txt/src/minikin/Layout.cpp", 57 "$flutter_root/engine/flutter/third_party/txt/src/minikin/LayoutUtils.cpp", 58 "$flutter_root/engine/flutter/third_party/txt/src/minikin/LineBreaker.cpp", 59 "$flutter_root/engine/flutter/third_party/txt/src/minikin/Measurement.cpp", 60 "$flutter_root/engine/flutter/third_party/txt/src/minikin/MinikinFont.cpp", 61 "$flutter_root/engine/flutter/third_party/txt/src/minikin/MinikinInternal.cpp", 62 "$flutter_root/engine/flutter/third_party/txt/src/minikin/SparseBitSet.cpp", 63 "$flutter_root/engine/flutter/third_party/txt/src/minikin/WordBreaker.cpp", 64 "$flutter_root/engine/flutter/third_party/txt/src/txt/asset_font_manager.cc", 65 "$flutter_root/engine/flutter/third_party/txt/src/txt/font_asset_provider.cc", 66 "$flutter_root/engine/flutter/third_party/txt/src/txt/font_collection.cc", 67 "$flutter_root/engine/flutter/third_party/txt/src/txt/font_features.cc", 68 "$flutter_root/engine/flutter/third_party/txt/src/txt/font_skia.cc", 69 "$flutter_root/engine/flutter/third_party/txt/src/txt/paint_record.cc", 70 "$flutter_root/engine/flutter/third_party/txt/src/txt/paragraph_builder.cc", 71 "$flutter_root/engine/flutter/third_party/txt/src/txt/paragraph_builder_txt.cc", 72 "$flutter_root/engine/flutter/third_party/txt/src/txt/paragraph_style.cc", 73 "$flutter_root/engine/flutter/third_party/txt/src/txt/paragraph_txt.cc", 74 "$flutter_root/engine/flutter/third_party/txt/src/txt/placeholder_run.cc", 75 "$flutter_root/engine/flutter/third_party/txt/src/txt/styled_runs.cc", 76 "$flutter_root/engine/flutter/third_party/txt/src/txt/test_font_manager.cc", 77 "$flutter_root/engine/flutter/third_party/txt/src/txt/text_decoration.cc", 78 "$flutter_root/engine/flutter/third_party/txt/src/txt/text_shadow.cc", 79 "$flutter_root/engine/flutter/third_party/txt/src/txt/text_style.cc", 80 "$flutter_root/engine/flutter/third_party/txt/src/txt/typeface_font_asset_provider.cc", 81 "$flutter_root/engine/flutter/third_party/txt/src/utils/JenkinsHash.cpp", 82 ] 83 84 deps = [ 85 "$ace_flutter_engine_root:flutter_engine_fml_$platform", 86 "$ace_flutter_engine_root/icu:ace_libicu_$platform", 87 "$ace_flutter_engine_root/skia:ace_skia_$platform", 88 ] 89 90 if (platform == "ohos") { 91 if (defined(oem_commercial_build) && oem_commercial_build) { 92 sources += [ "$flutter_root/engine/flutter/third_party/txt/src/txt/platform_android.cc" ] 93 } else { 94 sources += [ "$flutter_root/engine/flutter/third_party/txt/src/txt/platform_ohos.cc" ] 95 } 96 } else if (platform == "windows") { 97 sources += 98 [ "$flutter_root/engine/flutter/third_party/txt/src/txt/platform.cc" ] 99 if (use_mingw_win) { 100 defines += [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_WIN" ] 101 } 102 deps += [ "$ace_flutter_engine_root/harfbuzz:ace_libharfbuzz_$platform" ] 103 } else if (platform == "mac" || platform == "ios") { 104 cflags = [ "-DNS_FORMAT_ARGUMENT(A)=" ] 105 sources += [ 106 "$flutter_root/engine/flutter/third_party/txt/src/txt/platform_mac.mm", 107 ] 108 deps += [ "$ace_flutter_engine_root/harfbuzz:ace_libharfbuzz_$platform" ] 109 if (use_mac) { 110 defines += [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC" ] 111 } 112 if (defined(enable_gn_2021)) { 113 frameworks = [ 114 # AppKit symbols NSFontWeightXXX may be dlsym'ed. 115 "AppKit.framework", 116 "ApplicationServices.framework", 117 "OpenGL.framework", 118 ] 119 } else { 120 libs = [ 121 # AppKit symbols NSFontWeightXXX may be dlsym'ed. 122 "AppKit.framework", 123 "ApplicationServices.framework", 124 "OpenGL.framework", 125 ] 126 } 127 } else if (platform == "android") { 128 sources += [ "$flutter_root/engine/flutter/third_party/txt/src/txt/platform_android.cc" ] 129 } else if (platform == "linux") { 130 sources += [ "$flutter_root/engine/flutter/third_party/txt/src/txt/platform_linux.cc" ] 131 if (use_linux) { 132 defines += [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_LINUX" ] 133 } 134 deps += [ "$ace_flutter_engine_root/harfbuzz:ace_libharfbuzz_$platform" ] 135 } 136 } 137} 138 139foreach(item, ace_platforms) { 140 thirdparty_lib_txt("thirdparty_lib_txt_" + item.name) { 141 platform = item.name 142 defines = [] 143 cflags_cc = [] 144 config = { 145 } 146 147 if (defined(item.config)) { 148 config = item.config 149 } 150 151 if (defined(config.defines)) { 152 defines = config.defines 153 } 154 155 if (defined(config.cflags_cc)) { 156 cflags_cc = config.cflags_cc 157 } 158 } 159} 160