1e9297d28Sopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd.
2e9297d28Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3e9297d28Sopenharmony_ci# you may not use this file except in compliance with the License.
4e9297d28Sopenharmony_ci# You may obtain a copy of the License at
5e9297d28Sopenharmony_ci#
6e9297d28Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7e9297d28Sopenharmony_ci#
8e9297d28Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9e9297d28Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10e9297d28Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11e9297d28Sopenharmony_ci# See the License for the specific language governing permissions and
12e9297d28Sopenharmony_ci# limitations under the License.
13e9297d28Sopenharmony_ci
14e9297d28Sopenharmony_ciimport("//build/ohos.gni")
15e9297d28Sopenharmony_ciimport("//foundation/graphic/graphic_2d/graphic_config.gni")
16e9297d28Sopenharmony_ci
17e9297d28Sopenharmony_ciis_ok = true
18e9297d28Sopenharmony_ci
19e9297d28Sopenharmony_ci## Build libtexgine.so {{{
20e9297d28Sopenharmony_ciconfig("libtexgine_config") {
21e9297d28Sopenharmony_ci  visibility = [ ":*" ]
22e9297d28Sopenharmony_ci
23e9297d28Sopenharmony_ci  cflags = [
24e9297d28Sopenharmony_ci    "-Wall",
25e9297d28Sopenharmony_ci    "-Werror",
26e9297d28Sopenharmony_ci    "-g3",
27e9297d28Sopenharmony_ci    "-std=c++17",
28e9297d28Sopenharmony_ci  ]
29e9297d28Sopenharmony_ci
30e9297d28Sopenharmony_ci  include_dirs = [
31e9297d28Sopenharmony_ci    "src",
32e9297d28Sopenharmony_ci    "export",
33e9297d28Sopenharmony_ci  ]
34e9297d28Sopenharmony_ci}
35e9297d28Sopenharmony_ci
36e9297d28Sopenharmony_ciif (defined(is_arkui_x) && is_arkui_x) {
37e9297d28Sopenharmony_ci  config("libtexgine_public_config") {
38e9297d28Sopenharmony_ci    include_dirs = [
39e9297d28Sopenharmony_ci      "export",
40e9297d28Sopenharmony_ci      "texgine_drawing",
41e9297d28Sopenharmony_ci      "//third_party/icu/icu4c/source/common",
42e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/render_service_base/include",
43e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter",
44e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/2d_graphics/include",
45e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/2d_graphics/src",
46e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_text",
47e9297d28Sopenharmony_ci    ]
48e9297d28Sopenharmony_ci  }
49e9297d28Sopenharmony_ci} else {
50e9297d28Sopenharmony_ci  config("libtexgine_public_config") {
51e9297d28Sopenharmony_ci    include_dirs = [
52e9297d28Sopenharmony_ci      "export",
53e9297d28Sopenharmony_ci      "texgine_drawing",
54e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/render_service_base/include",
55e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter",
56e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/2d_graphics/include",
57e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/2d_graphics/src",
58e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_text",
59e9297d28Sopenharmony_ci    ]
60e9297d28Sopenharmony_ci  }
61e9297d28Sopenharmony_ci}
62e9297d28Sopenharmony_ci
63e9297d28Sopenharmony_ciohos_source_set("libtexgine_source") {
64e9297d28Sopenharmony_ci  if (is_ok) {
65e9297d28Sopenharmony_ci    sources = [
66e9297d28Sopenharmony_ci      "src/font_config.cpp",
67e9297d28Sopenharmony_ci      "src/font_descriptor_cache.cpp",
68e9297d28Sopenharmony_ci      "src/font_descriptor_mgr.cpp",
69e9297d28Sopenharmony_ci      "src/font_parser.cpp",
70e9297d28Sopenharmony_ci      "src/opentype_parser/cmap_table_parser.cpp",
71e9297d28Sopenharmony_ci      "src/opentype_parser/name_table_parser.cpp",
72e9297d28Sopenharmony_ci      "src/opentype_parser/opentype_basic_type.cpp",
73e9297d28Sopenharmony_ci      "src/opentype_parser/post_table_parser.cpp",
74e9297d28Sopenharmony_ci      "src/opentype_parser/ranges.cpp",
75e9297d28Sopenharmony_ci      "src/utils/exlog.cpp",
76e9297d28Sopenharmony_ci      "src/utils/logger.cpp",
77e9297d28Sopenharmony_ci    ]
78e9297d28Sopenharmony_ci
79e9297d28Sopenharmony_ci    configs = [
80e9297d28Sopenharmony_ci      ":libtexgine_config",
81e9297d28Sopenharmony_ci      "//build/config/compiler:exceptions",
82e9297d28Sopenharmony_ci      "//build/config/compiler:rtti",
83e9297d28Sopenharmony_ci    ]
84e9297d28Sopenharmony_ci
85e9297d28Sopenharmony_ci    public_configs = [ ":libtexgine_public_config" ]
86e9297d28Sopenharmony_ci
87e9297d28Sopenharmony_ci    platform = current_os
88e9297d28Sopenharmony_ci    if (platform == "mingw") {
89e9297d28Sopenharmony_ci      platform = "windows"
90e9297d28Sopenharmony_ci    }
91e9297d28Sopenharmony_ci
92e9297d28Sopenharmony_ci    public_deps = [ "texgine_drawing:libtexgine_drawing" ]
93e9297d28Sopenharmony_ci
94e9297d28Sopenharmony_ci    defines = []
95e9297d28Sopenharmony_ci    if (is_arkui_x) {
96e9297d28Sopenharmony_ci      defines += [ "CROSS_PLATFORM" ]
97e9297d28Sopenharmony_ci      public_deps += [ "//third_party/jsoncpp:jsoncpp_static" ]
98e9297d28Sopenharmony_ci    }
99e9297d28Sopenharmony_ci    if (defined(use_rosen_drawing) && use_rosen_drawing) {
100e9297d28Sopenharmony_ci      defines += [ "USE_ROSEN_DRAWING" ]
101e9297d28Sopenharmony_ci      if (rs_enable_gpu) {
102e9297d28Sopenharmony_ci        defines += [ "RS_ENABLE_GPU" ]
103e9297d28Sopenharmony_ci      }
104e9297d28Sopenharmony_ci    }
105e9297d28Sopenharmony_ci    if (enable_text_gine) {
106e9297d28Sopenharmony_ci      defines += [ "USE_GRAPHIC_TEXT_GINE" ]
107e9297d28Sopenharmony_ci    }
108e9297d28Sopenharmony_ci    if (is_arkui_x) {
109e9297d28Sopenharmony_ci      deps = [ "//third_party/bounds_checking_function:libsec_static" ]
110e9297d28Sopenharmony_ci      deps += [ "//third_party/cJSON:cjson_static" ]
111e9297d28Sopenharmony_ci    } else {
112e9297d28Sopenharmony_ci      external_deps = [
113e9297d28Sopenharmony_ci        "bounds_checking_function:libsec_static",
114e9297d28Sopenharmony_ci        "cJSON:cjson_static",
115e9297d28Sopenharmony_ci      ]
116e9297d28Sopenharmony_ci    }
117e9297d28Sopenharmony_ci
118e9297d28Sopenharmony_ci    if (platform == "ohos") {
119e9297d28Sopenharmony_ci      defines += [ "BUILD_NON_SDK_VER" ]
120e9297d28Sopenharmony_ci
121e9297d28Sopenharmony_ci      if (logger_enable_scope) {
122e9297d28Sopenharmony_ci        defines += [ "LOGGER_ENABLE_SCOPE" ]
123e9297d28Sopenharmony_ci      }
124e9297d28Sopenharmony_ci
125e9297d28Sopenharmony_ci      if (texgine_enable_debug_log) {
126e9297d28Sopenharmony_ci        defines += [ "TEXGINE_ENABLE_DEBUGLOG" ]
127e9297d28Sopenharmony_ci      }
128e9297d28Sopenharmony_ci
129e9297d28Sopenharmony_ci      external_deps += [
130e9297d28Sopenharmony_ci        "c_utils:utils",
131e9297d28Sopenharmony_ci        "hilog:libhilog",
132e9297d28Sopenharmony_ci        "hitrace:hitrace_meter",
133e9297d28Sopenharmony_ci      ]
134e9297d28Sopenharmony_ci
135e9297d28Sopenharmony_ci      public_deps +=
136e9297d28Sopenharmony_ci          [ "$graphic_2d_root/rosen/build/icu:rosen_libicu_$platform" ]
137e9297d28Sopenharmony_ci    } else {
138e9297d28Sopenharmony_ci      if (platform == "mac") {
139e9297d28Sopenharmony_ci        defines += [ "BUILD_SDK_MAC" ]
140e9297d28Sopenharmony_ci        public_deps += [
141e9297d28Sopenharmony_ci          "$graphic_2d_root/rosen/build/harfbuzz:rosen_libharfbuzz_$platform",
142e9297d28Sopenharmony_ci        ]
143e9297d28Sopenharmony_ci      } else {
144e9297d28Sopenharmony_ci        if (!(host_os == "linux" && host_cpu == "arm64")) {
145e9297d28Sopenharmony_ci          public_deps +=
146e9297d28Sopenharmony_ci              [ "$graphic_2d_root/rosen/build/icu:rosen_libicu_$platform" ]
147e9297d28Sopenharmony_ci        }
148e9297d28Sopenharmony_ci      }
149e9297d28Sopenharmony_ci      if (platform == "android") {
150e9297d28Sopenharmony_ci        defines += [ "BUILD_SDK_ANDROID" ]
151e9297d28Sopenharmony_ci      }
152e9297d28Sopenharmony_ci      if (platform == "ios") {
153e9297d28Sopenharmony_ci        defines += [ "BUILD_SDK_IOS" ]
154e9297d28Sopenharmony_ci      }
155e9297d28Sopenharmony_ci    }
156e9297d28Sopenharmony_ci  }
157e9297d28Sopenharmony_ci
158e9297d28Sopenharmony_ci  part_name = "graphic_2d"
159e9297d28Sopenharmony_ci  subsystem_name = "graphic"
160e9297d28Sopenharmony_ci}
161e9297d28Sopenharmony_ci
162e9297d28Sopenharmony_ciohos_shared_library("libtexgine") {
163e9297d28Sopenharmony_ci  deps = [ ":libtexgine_source" ]
164e9297d28Sopenharmony_ci
165e9297d28Sopenharmony_ci  platform = current_os
166e9297d28Sopenharmony_ci  if (platform == "mingw") {
167e9297d28Sopenharmony_ci    platform = "windows"
168e9297d28Sopenharmony_ci  }
169e9297d28Sopenharmony_ci
170e9297d28Sopenharmony_ci  #the texengine process is only enabled_ Text_ Engine is valid if it is true
171e9297d28Sopenharmony_ci  if (enable_text_gine) {
172e9297d28Sopenharmony_ci    if (platform == "ohos") {
173e9297d28Sopenharmony_ci      deps += [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics" ]
174e9297d28Sopenharmony_ci    } else {
175e9297d28Sopenharmony_ci      deps += [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics_new" ]
176e9297d28Sopenharmony_ci    }
177e9297d28Sopenharmony_ci    deps += [ "$graphic_2d_root/rosen/modules/render_service_client:librender_service_client" ]
178e9297d28Sopenharmony_ci  }
179e9297d28Sopenharmony_ci  innerapi_tags = [ "platformsdk" ]
180e9297d28Sopenharmony_ci  part_name = "graphic_2d"
181e9297d28Sopenharmony_ci  subsystem_name = "graphic"
182e9297d28Sopenharmony_ci}
183e9297d28Sopenharmony_ci## Build libtexgine.so }}}
184