1# Copyright (c) 2022 Huawei Device Co., Ltd.. All rights reserved.
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/graphic/graphic_2d/graphic_config.gni")
16import("$graphic_2d_root/rosen/modules/2d_engine/rosen_text/config.gni")
17
18if (enable_text_gine) {
19  config("rosen_text_public_config") {
20    include_dirs = [
21      "export",
22      "$graphic_2d_root/rosen/modules/2d_graphics/include",
23      "$graphic_2d_root/rosen/modules/2d_graphics/src",
24      "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing",
25      "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter",
26      "$rosen_root/modules/texgine/texgine_drawing/src",
27      "$graphic_2d_root/rosen/modules",
28      "$graphic_2d_root/rosen/modules/render_service_client",
29      "$graphic_2d_root/rosen/modules/render_service_client/core",
30      "$graphic_2d_root/rosen/modules/render_service_base",
31      "$graphic_2d_root/rosen/modules/render_service_base/include",
32      "$graphic_2d_root/rosen/modules/platform/image_native",
33    ]
34  }
35
36  defines = [ "USE_GRAPHIC_TEXT_GINE" ]
37
38  ohos_shared_library("rosen_text") {
39    include_dirs = [ "$graphic_2d_root/rosen/modules/2d_graphics/include" ]
40    deps = [ ":rosen_text_inner" ]
41    public_configs =
42        [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics_config" ]
43    platform = current_os
44    if (platform == "mingw") {
45      platform = "windows"
46    }
47
48    if (platform == "ohos") {
49      deps += [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics" ]
50    } else {
51      deps += [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics_new" ]
52    }
53
54    external_deps = [ "hilog:libhilog" ]
55
56    part_name = "graphic_2d"
57    subsystem_name = "graphic"
58  }
59
60  ohos_source_set("rosen_text_inner") {
61    if (use_texgine) {
62      public_deps = [ ":rosen_text_texgine" ]
63    } else if (use_skia_txt) {
64      public_deps = [ ":rosen_text_skia" ]
65    } else {
66      public_deps = [ ":rosen_text_txt" ]
67    }
68
69    part_name = "graphic_2d"
70    subsystem_name = "graphic"
71  }
72
73  ohos_source_set("rosen_text_texgine") {
74    public_configs = [ ":rosen_text_public_config" ]
75    public_external_deps = [ "bounds_checking_function:libsec_shared" ]
76
77    defines += [ "USE_GRAPHIC_TEXT_GINE" ]
78    cflags = [ "-std=c++17" ]
79
80    include_dirs = [ "$rosen_root/modules/render_service_base/include" ]
81
82    sources = [
83      "adapter/common/hm_symbol_txt.cpp",
84      "adapter/common/text_style.cpp",
85      "adapter/common/typography_style.cpp",
86      "adapter/texgine/convert.cpp",
87      "adapter/texgine/font_collection.cpp",
88      "adapter/texgine/typography.cpp",
89      "adapter/texgine/typography_create.cpp",
90    ]
91
92    if (defined(use_rosen_drawing) && use_rosen_drawing) {
93      defines += [ "USE_ROSEN_DRAWING" ]
94      if (rs_enable_gpu) {
95        defines += [ "RS_ENABLE_GPU" ]
96      }
97    }
98
99    deps = [ "$graphic_2d_root/rosen/modules/texgine:libtexgine_source" ]
100
101    part_name = "graphic_2d"
102    subsystem_name = "graphic"
103  }
104
105  ohos_source_set("rosen_text_txt") {
106    public_configs = [ ":rosen_text_public_config" ]
107    public_external_deps = [ "bounds_checking_function:libsec_shared" ]
108
109    include_dirs = [ "$rosen_root/modules/render_service_base/include" ]
110
111    defines += [
112      "USE_GRAPHIC_TEXT_GINE",
113      "WINDOWS_PLATFORM",
114    ]
115    cflags = [ "-std=c++17" ]
116
117    if (!defined(use_new_skia)) {
118      include_dirs += [ "$flutter_root/engine/flutter/third_party/txt/src" ]
119    }
120
121    sources = [
122      "adapter/common/hm_symbol_txt.cpp",
123      "adapter/common/text_style.cpp",
124      "adapter/common/typography_style.cpp",
125      "adapter/txt/convert.cpp",
126      "adapter/txt/font_collection.cpp",
127      "adapter/txt/typography.cpp",
128      "adapter/txt/typography_create.cpp",
129    ]
130
131    platform = current_os
132    if (platform == "mingw") {
133      platform = "windows"
134    }
135
136    if (defined(use_rosen_drawing) && use_rosen_drawing) {
137      defines += [ "USE_ROSEN_DRAWING" ]
138      if (rs_enable_gpu) {
139        defines += [ "RS_ENABLE_GPU" ]
140      }
141    }
142
143    external_deps = [ "skia:skia_canvaskit" ]
144
145    part_name = "graphic_2d"
146    subsystem_name = "graphic"
147  }
148
149  ohos_source_set("rosen_text_skia") {
150    public_configs = [ ":rosen_text_public_config" ]
151
152    if (!is_arkui_x) {
153      public_external_deps = [ "bounds_checking_function:libsec_shared" ]
154    }
155
156    include_dirs = [
157      "$rosen_root/modules/render_service_base/include",
158      "$rosen_root/modules/2d_engine/rosen_text/skia_txt",
159      "$rosen_root/modules/2d_engine/rosen_text/skia_txt/txt/src",
160    ]
161
162    if (is_arkui_x) {
163      include_dirs += [ "//third_party/bounds_checking_function/include" ]
164    }
165
166    defines += [
167      "USE_GRAPHIC_TEXT_GINE",
168      "WINDOWS_PLATFORM",
169    ]
170    cflags = [ "-std=c++17" ]
171
172    sources = [
173      "adapter/common/hm_symbol_txt.cpp",
174      "adapter/common/text_style.cpp",
175      "adapter/common/typography_style.cpp",
176      "adapter/skia_txt/convert.cpp",
177      "adapter/skia_txt/font_collection.cpp",
178      "adapter/skia_txt/run_impl.cpp",
179      "adapter/skia_txt/text_line_base.cpp",
180      "adapter/skia_txt/typography.cpp",
181      "adapter/skia_txt/typography_create.cpp",
182    ]
183
184    platform = current_os
185    if (platform == "mingw") {
186      platform = "windows"
187    }
188
189    if (defined(use_rosen_drawing) && use_rosen_drawing) {
190      defines += [
191        "USE_ROSEN_DRAWING",
192        "USE_SKIA_TXT",
193      ]
194      if (rs_enable_gpu) {
195        defines += [ "RS_ENABLE_GPU" ]
196      }
197    }
198    external_deps = [ "hilog:libhilog" ]
199    deps = [ "$graphic_2d_root/rosen/modules/texgine:libtexgine_source" ]
200    if (!(host_os == "linux" && host_cpu == "arm64")) {
201      deps += [ "./skia_txt:skia_libtxt_$platform" ]
202      external_deps += [ "skia:skia_canvaskit" ]
203    }
204
205    is_cross_platform =
206        current_os == "mac" || current_os == "mingw" || current_os == "linux" ||
207        current_os == "android" || current_os == "ios"
208
209    if (!is_cross_platform) {
210      external_deps += [ "hitrace:hitrace_meter" ]
211    }
212
213    part_name = "graphic_2d"
214    subsystem_name = "graphic"
215  }
216} else {
217  ## Build librosen_text.so
218  config("rosen_text_config") {
219    include_dirs = [ "$rosen_2d_engine_root" ]
220  }
221
222  ohos_shared_library("rosen_text") {
223    public_configs = [ ":rosen_text_config" ]
224
225    public_deps = [ "ui:rosen_text_ui" ]
226
227    part_name = "graphic_2d"
228    subsystem_name = "graphic"
229  }
230}
231