1# Copyright (c) 2020-2021 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#     http://www.apache.org/licenses/LICENSE-2.0
6# Unless required by applicable law or agreed to in writing, software
7# distributed under the License is distributed on an "AS IS" BASIS,
8# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9# See the License for the specific language governing permissions and
10# limitations under the License.
11if (defined(ohos_lite)) {
12  import("//build/lite/config/component/lite_component.gni")
13} else {
14  import("//build/ohos.gni")
15}
16config("harfbuzz_config") {
17  include_dirs = [ "${target_gen_dir}/harfbuzz-2.8.2/src" ]
18}
19
20action("harfbuzz_action") {
21  script = "//third_party/harfbuzz/install.py"
22  outputs = [
23    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-aat-layout.cc",
24    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-aat-map.cc",
25    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-blob.cc",
26    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-buffer-serialize.cc",
27    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-buffer.cc",
28    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-common.cc",
29    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-face.cc",
30    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-fallback-shape.cc",
31    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-font.cc",
32    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-map.cc",
33    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-number.cc",
34    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-cff1-table.cc",
35    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-cff2-table.cc",
36    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-face.cc",
37    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-font.cc",
38    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-layout.cc",
39    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-map.cc",
40    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-math.cc",
41    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-meta.cc",
42    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-metrics.cc",
43    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-name.cc",
44    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-arabic.cc",
45    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-default.cc",
46    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-hangul.cc",
47    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-hebrew.cc",
48    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-indic-table.cc",
49    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-indic.cc",
50    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-khmer.cc",
51    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-myanmar.cc",
52    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-syllabic.cc",
53    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-thai.cc",
54    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-use.cc",
55    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-complex-vowel-constraints.cc",
56    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-fallback.cc",
57    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape-normalize.cc",
58    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-shape.cc",
59    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-tag.cc",
60    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ot-var.cc",
61    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-set.cc",
62    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-shape-plan.cc",
63    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-shape.cc",
64    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-shaper.cc",
65    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-static.cc",
66    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-subset-cff2.cc",
67    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-subset-cff-common.cc",
68    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-ucd.cc",
69    "${target_gen_dir}/harfbuzz-2.8.2/src/hb-unicode.cc",
70  ]
71
72  inputs = [ "//third_party/harfbuzz/harfbuzz-2.8.2.tar.xz" ]
73  harfbuzz_path = rebase_path("${target_gen_dir}", root_build_dir)
74  harfbuzz_source_path = rebase_path("//third_party/harfbuzz", root_build_dir)
75  args = [
76    "--gen-dir",
77    "$harfbuzz_path",
78    "--source-dir",
79    "$harfbuzz_source_path",
80  ]
81}
82
83if (defined(ohos_lite)) {
84  lite_library("harfbuzz") {
85    output_name = "harfbuzz"
86    sources = get_target_outputs(":harfbuzz_action")
87    deps = [ ":harfbuzz_action" ]
88    public_configs = [ ":harfbuzz_config" ]
89    if (defined(board_toolchain_type) && board_toolchain_type == "iccarm") {
90      target_type = "static_library"
91      defines = [
92        "HB_TINY",
93        "ENABLE_ICCARM=1",
94        "HB_CUSTOM_MALLOC",
95      ]
96      cflags = [
97        "--diag_suppress",
98        "Pe068,Pa093,Pe111,Pa181,Pe128,Pe161,Pe177,Pe185,Pe186,Pe550,Pe554",
99      ]
100      cflags_cc = cflags
101    } else {
102      target_type = "shared_library"
103      defines = [ "HAVE_PTHREAD = 1" ]
104    }
105  }
106} else {
107  ohos_static_library("harfbuzz_static") {
108    sources = get_target_outputs(":harfbuzz_action")
109    deps = [ ":harfbuzz_action" ]
110    include_dirs = [ "${target_gen_dir}/harfbuzz-2.8.2/src" ]
111    defines = [ "HAVE_PTHREAD = 1" ]
112    public_configs = [ ":harfbuzz_config" ]
113    part_name = "harfbuzz"
114    subsystem_name = "thirdparty"
115  }
116}
117