1# Copyright (c) 2021-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/arkui/ace_engine/ace_config.gni")
16
17template("build_component") {
18  forward_variables_from(invoker, "*")
19
20  component_name = target_name
21
22  template("build_component_impl") {
23    forward_variables_from(invoker, "*")
24
25    platform = target_name
26
27    component_deps = []
28    extra_deps = []
29    foreach(item, component_deps) {
30      extra_deps += [ "$ace_root/frameworks/core/components/${item}:ace_core_components_${item}_${platform}" ]
31    }
32
33    if (defined(platform_deps)) {
34      foreach(item, platform_deps) {
35        extra_deps += [ "${item}_${platform}" ]
36      }
37    }
38
39    if (defined(deps)) {
40      extra_deps += deps
41    }
42
43    ohos_source_set("ace_core_components_${component_name}_${platform}") {
44      defines += invoker.defines
45
46      sources = []
47      sources += invoker.sources
48
49      configs = []
50      configs += [ "$ace_root:ace_config" ]
51
52      if (defined(invoker.configs)) {
53        configs += invoker.configs
54      }
55
56      include_dirs = []
57      if (defined(invoker.include_dirs)) {
58        include_dirs += invoker.include_dirs
59      }
60      deps = []
61      deps += extra_deps
62      deps += [ "$ace_root/frameworks/core/components/theme:build_theme_code" ]
63
64      if (defined(invoker.public_configs)) {
65        public_configs = []
66        public_configs += invoker.public_configs
67      }
68
69      external_deps = []
70      if (use_hilog) {
71        external_deps += [ "hilog:libhilog" ]
72      }
73      if (defined(invoker.external_deps)) {
74        external_deps += invoker.external_deps
75      }
76
77      if (defined(invoker.external_deps_info)) {
78        external_deps_info = []
79        external_deps_info += invoker.external_deps_info
80      }
81
82      if (defined(invoker.cflags_cc)) {
83        cflags_cc = []
84        cflags_cc += invoker.cflags_cc
85      }
86
87      if (defined(invoker.public_deps)) {
88        public_deps = []
89        public_deps += invoker.public_deps
90      }
91
92      if (defined(invoker.component_defines)) {
93        defines += invoker.component_defines
94      }
95
96      if (defined(config.enable_standard_input) &&
97          config.enable_standard_input) {
98        if (defined(invoker.standard_input_sources)) {
99          sources += invoker.standard_input_sources
100        }
101        if (defined(invoker.standard_input_deps)) {
102          if (defined(external_deps)) {
103            external_deps += invoker.standard_input_deps
104          } else {
105            external_deps = invoker.standard_input_deps
106          }
107        }
108      }
109
110      if (defined(config.web_components_support) &&
111          config.web_components_support && is_ohos_standard_system) {
112        if (defined(invoker.standard_web_configs)) {
113          configs += invoker.standard_web_configs
114        }
115        if (defined(invoker.standard_web_deps)) {
116          if (defined(external_deps)) {
117            external_deps += invoker.standard_web_deps
118          } else {
119            external_deps = invoker.standard_web_deps
120          }
121        }
122      }
123
124      if (defined(config.enable_rosen_backend) && config.enable_rosen_backend &&
125          defined(invoker.rosen_sources)) {
126        sources += invoker.rosen_sources
127        if (enable_graphic_text_gine) {
128          external_deps += [ "graphic_2d:rosen_text" ]
129        }
130        if (is_arkui_x) {
131          deps += [ "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client_static" ]
132        } else {
133          external_deps += [ "graphic_2d:librender_service_client" ]
134          if (ace_use_rosen_drawing) {
135            external_deps += [ "graphic_2d:2d_graphics" ]
136          }
137        }
138      }
139      part_name = ace_engine_part
140      subsystem_name = ace_engine_subsystem
141    }
142  }
143
144  foreach(item, ace_platforms) {
145    build_component_impl(item.name) {
146      platform = item.name
147      defines = []
148
149      if (defined(item.config)) {
150        config = item.config
151      } else {
152        config = {
153        }
154      }
155
156      if (defined(config.defines)) {
157        defines += config.defines
158      }
159
160      if (defined(config.cflags_cc)) {
161        cflags_cc = config.cflags_cc
162      } else {
163        cflags_cc = []
164      }
165    }
166  }
167}
168