1# Copyright (c) 2024 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/graphic/graphic_2d/graphic_config.gni")
16
17group("textnapi") {
18  deps = [
19    ":text_napi",
20    ":text_napi_impl",
21  ]
22}
23
24config("text_config") {
25  include_dirs = [ "../text" ]
26}
27
28config("local_text") {
29  visibility = [ ":*" ]
30
31  include_dirs = [
32    "../text",
33    "../text/fontdescriptor_napi/include",
34    "../drawing",
35    "$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_text",
36    "$graphic_2d_root/rosen/modules/2d_graphics/include",
37    "$graphic_2d_root/interfaces/kits/napi/graphic/text/utils",
38    "$graphic_2d_root/rosen/modules/texgine/src",
39  ]
40}
41
42ohos_shared_library("text_napi") {
43  sources = [ "text_module.cpp" ]
44  configs = [
45    ":local_text",
46    ":text_config",
47  ]
48
49  sanitize = {
50    cfi = true
51    cfi_cross_dso = true
52    cfi_vcall_icall_only = true
53    debug = false
54  }
55
56  deps = [ ":text_napi_impl" ]
57
58  external_deps = [
59    "hilog:libhilog",
60    "napi:ace_napi",
61  ]
62
63  relative_install_dir = "module/graphics"
64  part_name = "graphic_2d"
65  subsystem_name = "graphic"
66}
67
68ohos_shared_library("text_napi_impl") {
69  sources = [
70    "enum_napi/text_enum_napi.cpp",
71    "fontcollection_napi/js_fontcollection.cpp",
72    "fontdescriptor_napi/src/js_fontdescriptor.cpp",
73    "js_text_init.cpp",
74    "line_typeset_napi/js_line_typeset.cpp",
75    "paragraph_builder_napi/js_paragraph_builder.cpp",
76    "paragraph_napi/js_paragraph.cpp",
77    "run_napi/js_run.cpp",
78    "text_line_napi/js_text_line.cpp",
79    "utils/napi_async_work.cpp",
80    "utils/napi_common.cpp",
81  ]
82
83  configs = [
84    ":local_text",
85    ":text_config",
86  ]
87
88  sanitize = {
89    cfi = true
90    cfi_cross_dso = true
91    cfi_vcall_icall_only = true
92    debug = false
93  }
94
95  deps = [
96    "$graphic_2d_root/interfaces/kits/napi/graphic/drawing:drawing_napi_impl",
97    "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics",
98    "$graphic_2d_root/rosen/modules/texgine:libtexgine_source",
99  ]
100
101  external_deps = [
102    "ability_runtime:abilitykit_native",
103    "ability_runtime:app_context",
104    "graphic_surface:surface",
105    "hilog:libhilog",
106    "napi:ace_napi",
107    "resource_management:global_resmgr",
108  ]
109
110  if (current_os == "ohos" || current_os == "ohos_ng") {
111    external_deps += [ "init:libbegetutil" ]
112    defines = [ "OHOS_TEXT_ENABLE" ]
113    cflags = [ "-fstack-protector-strong" ]
114    cflags_cc = [
115      "-fstack-protector-strong",
116      "-std=c++17",
117    ]
118  } else {
119    cflags_cc = [ "-std=c++17" ]
120  }
121
122  if (current_os == "mingw") {
123    defines += [ "WINDOWS_PLATFORM" ]
124  }
125
126  innerapi_tags = [ "platformsdk" ]
127  part_name = "graphic_2d"
128  subsystem_name = "graphic"
129}
130