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