1# Copyright (c) 2023 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
17is_ok = true
18
19## Build libtexgine.so {{{
20config("libtexgine_config") {
21  visibility = [ ":*" ]
22
23  cflags = [
24    "-Wall",
25    "-Werror",
26    "-g3",
27    "-std=c++17",
28  ]
29
30  include_dirs = [
31    "src",
32    "export",
33  ]
34}
35
36config("libtexgine_public_config") {
37  include_dirs = [
38    "export",
39    "texgine_drawing",
40    "$graphic_2d_root/rosen/modules/render_service_base/include",
41    "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter",
42    "$graphic_2d_root/rosen/modules/2d_graphics/include",
43    "$graphic_2d_root/rosen/modules/2d_graphics/src",
44    "$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_text",
45  ]
46  if (is_arkui_x) {
47    include_dirs += [ "//third_party/icu/icu4c/source/common" ]
48  }
49}
50
51ohos_source_set("libtexgine_source") {
52  if (is_ok) {
53    sources = [
54      "src/font_config.cpp",
55      "src/font_descriptor_cache.cpp",
56      "src/font_descriptor_mgr.cpp",
57      "src/font_parser.cpp",
58      "src/opentype_parser/cmap_table_parser.cpp",
59      "src/opentype_parser/name_table_parser.cpp",
60      "src/opentype_parser/opentype_basic_type.cpp",
61      "src/opentype_parser/post_table_parser.cpp",
62      "src/opentype_parser/ranges.cpp",
63      "src/utils/exlog.cpp",
64      "src/utils/logger.cpp",
65    ]
66
67    configs = [
68      ":libtexgine_config",
69      "//build/config/compiler:exceptions",
70      "//build/config/compiler:rtti",
71    ]
72
73    public_configs = [ ":libtexgine_public_config" ]
74
75    platform = current_os
76    if (platform == "mingw") {
77      platform = "windows"
78    }
79
80    public_deps = [ "texgine_drawing:libtexgine_drawing" ]
81
82    defines = []
83    external_deps = []
84    if (is_arkui_x) {
85      defines += [ "CROSS_PLATFORM" ]
86      public_deps += [ "//third_party/jsoncpp:jsoncpp_static" ]
87    }
88    if (defined(use_rosen_drawing) && use_rosen_drawing) {
89      defines += [ "USE_ROSEN_DRAWING" ]
90      if (rs_enable_gpu) {
91        defines += [ "RS_ENABLE_GPU" ]
92      }
93    }
94    if (enable_text_gine) {
95      defines += [ "USE_GRAPHIC_TEXT_GINE" ]
96    }
97    if (is_arkui_x) {
98      deps = [
99        "//third_party/bounds_checking_function:libsec_static",
100        "//third_party/cJSON:cjson_static",
101      ]
102    } else {
103      external_deps += [ "bounds_checking_function:libsec_static" ]
104    }
105
106    if (platform == "ohos") {
107      defines += [
108        "BUILD_NON_SDK_VER",
109        "OHOS_TEXT_ENABLE",
110      ]
111
112      if (logger_enable_scope) {
113        defines += [ "LOGGER_ENABLE_SCOPE" ]
114      }
115
116      if (texgine_enable_debug_log) {
117        defines += [ "TEXGINE_ENABLE_DEBUGLOG" ]
118      }
119
120      external_deps += [
121        "cJSON:cjson_static",
122        "c_utils:utils",
123        "hilog:libhilog",
124        "hitrace:hitrace_meter",
125      ]
126
127      public_deps +=
128          [ "$graphic_2d_root/rosen/build/icu:rosen_libicu_$platform" ]
129    } else {
130      if (platform == "mac") {
131        defines += [ "BUILD_SDK_MAC" ]
132        public_deps += [
133          "$graphic_2d_root/rosen/build/harfbuzz:rosen_libharfbuzz_$platform",
134        ]
135      } else {
136        public_deps +=
137            [ "$graphic_2d_root/rosen/build/icu:rosen_libicu_$platform" ]
138      }
139      if (platform == "android") {
140        defines += [ "BUILD_SDK_ANDROID" ]
141      }
142      if (platform == "ios") {
143        defines += [ "BUILD_SDK_IOS" ]
144      }
145      external_deps += [ "cJSON:cjson" ]
146    }
147  }
148
149  part_name = "graphic_2d"
150  subsystem_name = "graphic"
151}
152
153ohos_shared_library("libtexgine") {
154  deps = [ ":libtexgine_source" ]
155
156  platform = current_os
157  if (platform == "mingw") {
158    platform = "windows"
159  }
160
161  #the texengine process is only enabled_ Text_ Engine is valid if it is true
162  if (enable_text_gine) {
163    if (platform == "ohos") {
164      deps += [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics" ]
165    } else {
166      deps += [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics_new" ]
167    }
168    deps += [ "$graphic_2d_root/rosen/modules/render_service_client:librender_service_client" ]
169  }
170  innerapi_tags = [ "platformsdk" ]
171  part_name = "graphic_2d"
172  subsystem_name = "graphic"
173}
174## Build libtexgine.so }}}
175