• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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")
16import("//foundation/arkui/ace_engine/build/ace_lib.gni")
17import("//foundation/arkui/ace_engine/interfaces/napi/kits/napi_lib.gni")
18
19if (is_ohos_standard_system) {
20  system_resource_hap_path =
21      get_label_info("//base/global/system_resources/systemres:systemres_hap",
22                     "target_out_dir") + "/SystemResources.hap"
23  system_resource_path =
24      get_label_info("//base/global/system_resources/systemres:systemres_hap",
25                     "target_out_dir") + "/resources"
26  system_resource_index_path =
27      get_label_info("//base/global/system_resources/systemres:systemres_hap",
28                     "target_gen_dir") + "/main_res/gen/resources.index"
29  system_resource_value_path =
30      get_label_info("//base/global/system_resources/systemres:systemres_hap",
31                     "target_out_dir") + "/resources/entry/resources.txt"
32} else {
33  system_resource_hap_path =
34      get_label_info("//base/global/system_resources/systemres:systemres_hap",
35                     "target_gen_dir") + "/SystemResources.hap"
36  system_resource_path =
37      get_label_info("//base/global/system_resources/systemres:systemres_hap",
38                     "target_gen_dir") + "/resources"
39  system_resource_index_path =
40      get_label_info("//base/global/system_resources/systemres:systemres_hap",
41                     "target_gen_dir") + "/main_res/gen/resources.index"
42  system_resource_value_path =
43      get_label_info("//base/global/system_resources/systemres:systemres_hap",
44                     "target_gen_dir") + "/resources/entry/resources.txt"
45}
46
47action("get_system_resource") {
48  script = "get_system_resources.sh"
49  deps = [ "//base/global/system_resources/systemres:systemres_hap($current_toolchain)" ]
50  args = [
51    rebase_path(system_resource_hap_path),
52    rebase_path(system_resource_path),
53  ]
54  inputs = [ system_resource_hap_path ]
55  outputs = [ system_resource_path ]
56}
57
58action("extra_system_resource") {
59  script = "./dump/dump.py"
60  deps = [ "//base/global/system_resources/systemres:main_res" ]
61  args = [
62    rebase_path(system_resource_index_path),
63    rebase_path(system_resource_value_path),
64  ]
65  outputs = [ system_resource_value_path ]
66}
67
68# Triggered only when the SDK is compiled
69if (is_ohos_standard_system) {
70  import("sharedlib_config.gni")
71
72  foreach(module, napi_modules) {
73    ohos_copy("copy_napi_${module.prefix}libs") {
74      deps = []
75      sources = []
76      foreach(shard_lib, module.shard_libs) {
77        subsystem_name = shard_lib.subsystem_name
78        part_name = shard_lib.part_name
79        deps += [ shard_lib.label ]
80        out_path = get_label_info(shard_lib.label, "root_out_dir")
81        lib_names = []
82        if (defined(shard_lib.lib_names)) {
83          lib_names += shard_lib.lib_names
84        } else {
85          cur_lib = get_label_info(shard_lib.label, "name")
86          lib_names += [ string_replace(cur_lib, "lib", "", 1) ]
87        }
88        foreach(lib_name, lib_names) {
89          sources += [ "${out_path}/${subsystem_name}/${part_name}/lib${lib_name}${dylib_suffix}" ]
90        }
91      }
92
93      # Set the output directory for all dynamic libraries.
94      if (module.prefix == "") {
95        module_source_dir = "${target_out_dir}/previewer/common/bin/module/"
96      } else {
97        module_source_dir =
98            "${target_out_dir}/previewer/common/bin/module/${module.prefix}/"
99      }
100      outputs = [ "${module_source_dir}{{source_file_part}}" ]
101      module_install_name = ""
102    }
103  }
104
105  ohos_copy("copy_abc_library") {
106    deps = [
107      "$ace_root/frameworks/bridge/declarative_frontend:ark_modifier",
108      "$ace_root/frameworks/bridge/declarative_frontend:ark_theme_control",
109      "$ace_root/frameworks/bridge/declarative_frontend:shape",
110      "$ace_root/frameworks/bridge/declarative_frontend:statemanagement",
111      "$ace_root/frameworks/bridge/declarative_frontend:uicontext",
112      "$ace_root/frameworks/bridge/declarative_frontend:x_node",
113    ]
114    out_path = get_label_info(
115            "$ace_root/frameworks/bridge/declarative_frontend:ark_modifier",
116            "root_out_dir")
117    sources = [
118      "${out_path}/arkui/ace_engine/modifier.abc",
119      "${out_path}/arkui/ace_engine/node.abc",
120      "${out_path}/arkui/ace_engine/shape.abc",
121      "${out_path}/arkui/ace_engine/statemanagement.abc",
122      "${out_path}/arkui/ace_engine/theme.abc",
123      "${out_path}/arkui/ace_engine/uicontext.abc",
124    ]
125
126    outputs = [ target_out_dir +
127                "/previewer/common/bin/module/arkui/{{source_file_part}}" ]
128    module_source_dir = target_out_dir + "/previewer/common/bin/module/arkui"
129    module_install_name = ""
130  }
131
132  # All dynamic libraries to be copied to the path "/previewer/common/bin/",
133  # which are related to the previewer, can be added to this script.
134  ohos_copy("copy_preview_shared_library") {
135    deps = []
136    foreach(module, napi_modules) {
137      deps += [ ":copy_napi_${module.prefix}libs" ]
138    }
139
140    # The dynamic library here is used for local testing of the previewer.
141    if (enable_glfw_window) {
142      deps += [ "$ace_root/adapter/preview/entrance/samples:previewer_demo" ]
143    }
144
145    sources = [
146      "//third_party/icu/ohos_icu4j/data/icudt72l.dat",
147      "//third_party/skia/src/ports/skia_ohos/config/fontconfig.json",
148      "//third_party/skia/src/ports/skia_ohos/config/fontconfig_ohos.json",
149    ]
150
151    foreach(item, common_bin) {
152      subsystem_name = item.subsystem_name
153      part_name = item.part_name
154      deps += [ item.label ]
155      out_path = get_label_info(item.label, "root_out_dir")
156      lib_names = []
157      if (defined(item.lib_names)) {
158        lib_names += item.lib_names
159      } else {
160        lib_names +=
161            [ string_replace(get_label_info(item.label, "name"), "lib", "", 1) ]
162      }
163      foreach(lib_name, lib_names) {
164        sources += [ "${out_path}/${subsystem_name}/${part_name}/lib${lib_name}${dylib_suffix}" ]
165      }
166    }
167
168    # Set the output directory for all dynamic libraries.
169    outputs = [ target_out_dir + "/previewer/common/bin/{{source_file_part}}" ]
170    module_source_dir = target_out_dir + "/previewer/common/bin/"
171    module_install_name = ""
172  }
173
174  if (use_mingw_win) {
175    ohos_copy("copy_preview_curl_cacert") {
176      sources = [ "//third_party/curl/cacert.pem" ]
177      outputs = [ target_out_dir + "/previewer/resources/cacert.pem" ]
178      module_source_dir = target_out_dir + "/previewer/resources"
179      module_install_name = ""
180    }
181  }
182
183  ohos_copy("copy_system_resource_standard") {
184    deps = [
185      ":extra_system_resource",
186      ":get_system_resource",
187    ]
188
189    sources = [ system_resource_path ]
190
191    outputs = [ target_out_dir + "/previewer/common/{{source_file_part}}" ]
192    module_source_dir = target_out_dir + "/previewer/common"
193    module_install_name = ""
194  }
195} else {
196  ohos_copy("copy_system_resource") {
197    if (use_mac) {
198      sources = [ "//prebuilts/ace-toolkit/preview/rich/resources" ]
199      outputs = [ target_out_dir + "/tv_resources/{{source_file_part}}" ]
200      module_source_dir = target_out_dir + "/tv_resources/"
201      module_install_name = ""
202    } else {
203      deps = [
204        ":extra_system_resource",
205        ":get_system_resource",
206      ]
207
208      sources = [ system_resource_path ]
209      outputs = [ target_out_dir + "/tv_resources/{{source_file_part}}" ]
210      module_source_dir = target_out_dir + "/tv_resources/"
211      module_install_name = ""
212    }
213  }
214
215  ohos_copy("copy_system_resource_wearable") {
216    if (use_mac) {
217      sources = [ "//prebuilts/ace-toolkit/preview/rich/resources" ]
218      outputs = [ target_out_dir + "/wearable_resources/{{source_file_part}}" ]
219      module_source_dir = target_out_dir + "/wearable_resources/"
220      module_install_name = ""
221    } else {
222      deps = [
223        ":extra_system_resource",
224        ":get_system_resource",
225      ]
226
227      sources = [ system_resource_path ]
228      outputs = [ target_out_dir + "/wearable_resources/{{source_file_part}}" ]
229      module_source_dir = target_out_dir + "/wearable_resources/"
230      module_install_name = ""
231    }
232  }
233}
234