• 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} else {
27  system_resource_hap_path =
28      get_label_info("//base/global/system_resources/systemres:systemres_hap",
29                     "target_gen_dir") + "/SystemResources.hap"
30  system_resource_path =
31      get_label_info("//base/global/system_resources/systemres:systemres_hap",
32                     "target_gen_dir") + "/resources"
33}
34
35action("get_system_resource") {
36  script = "get_system_resources.sh"
37  deps = [ "//base/global/system_resources/systemres:systemres_hap($current_toolchain)" ]
38  args = [
39    rebase_path(system_resource_hap_path),
40    rebase_path(system_resource_path),
41  ]
42  inputs = [ system_resource_hap_path ]
43  outputs = [ system_resource_path ]
44}
45
46# Triggered only when the SDK is compiled
47if (is_ohos_standard_system) {
48  import("sharedlib_config.gni")
49
50  foreach(module, napi_modules) {
51    ohos_copy("copy_napi_${module.prefix}libs") {
52      deps = []
53      sources = []
54      foreach(shard_lib, module.shard_libs) {
55        subsystem_name = shard_lib.subsystem_name
56        part_name = shard_lib.part_name
57        deps += [ shard_lib.label ]
58        out_path = get_label_info(shard_lib.label, "root_out_dir")
59        lib_names = []
60        if (defined(shard_lib.lib_names)) {
61          lib_names += shard_lib.lib_names
62        } else {
63          cur_lib = get_label_info(shard_lib.label, "name")
64          lib_names += [ string_replace(cur_lib, "lib", "", 1) ]
65        }
66        foreach(lib_name, lib_names) {
67          sources += [ "${out_path}/${subsystem_name}/${part_name}/lib${lib_name}${dylib_suffix}" ]
68        }
69      }
70
71      # Set the output directory for all dynamic libraries.
72      if (module.prefix == "") {
73        module_source_dir = "${target_out_dir}/previewer/common/bin/module/"
74      } else {
75        module_source_dir =
76            "${target_out_dir}/previewer/common/bin/module/${module.prefix}/"
77      }
78      outputs = [ "${module_source_dir}{{source_file_part}}" ]
79      module_install_name = ""
80    }
81  }
82
83  # All dynamic libraries to be copied to the path "/previewer/common/bin/",
84  # which are related to the previewer, can be added to this script.
85  ohos_copy("copy_preview_shared_library") {
86    deps = []
87    foreach(module, napi_modules) {
88      deps += [ ":copy_napi_${module.prefix}libs" ]
89    }
90
91    # The dynamic library here is used for local testing of the previewer.
92    if (enable_glfw_window) {
93      deps += [ "$ace_root/adapter/preview/entrance/samples:previewer_demo" ]
94    }
95
96    sources = [
97      "//base/global/system_resources/fonts",
98      "//foundation/arkui/ace_engine/adapter/preview/sdk/fontconfig.json",
99      "//third_party/icu/ohos_icu4j/data/icudt72l.dat",
100    ]
101
102    foreach(item, common_bin) {
103      subsystem_name = item.subsystem_name
104      part_name = item.part_name
105      deps += [ item.label ]
106      out_path = get_label_info(item.label, "root_out_dir")
107      lib_names = []
108      if (defined(item.lib_names)) {
109        lib_names += item.lib_names
110      } else {
111        lib_names +=
112            [ string_replace(get_label_info(item.label, "name"), "lib", "", 1) ]
113      }
114      foreach(lib_name, lib_names) {
115        sources += [ "${out_path}/${subsystem_name}/${part_name}/lib${lib_name}${dylib_suffix}" ]
116      }
117    }
118
119    # Set the output directory for all dynamic libraries.
120    outputs = [ target_out_dir + "/previewer/common/bin/{{source_file_part}}" ]
121    module_source_dir = target_out_dir + "/previewer/common/bin/"
122    module_install_name = ""
123  }
124
125  if (use_mingw_win) {
126    ohos_copy("copy_preview_curl_cacert") {
127      sources = [ "//third_party/curl/cacert.pem" ]
128      outputs = [ target_out_dir + "/previewer/resources/cacert.pem" ]
129      module_source_dir = target_out_dir + "/previewer/resources"
130      module_install_name = ""
131    }
132  }
133
134  ohos_copy("copy_system_resource_standard") {
135    deps = [ ":get_system_resource" ]
136
137    sources = [ system_resource_path ]
138
139    outputs = [ target_out_dir + "/previewer/common/{{source_file_part}}" ]
140    module_source_dir = target_out_dir + "/previewer/common"
141    module_install_name = ""
142  }
143} else {
144  ohos_copy("copy_system_resource") {
145    if (use_mac) {
146      sources = [ "//prebuilts/ace-toolkit/preview/rich/resources" ]
147      outputs = [ target_out_dir + "/tv_resources/{{source_file_part}}" ]
148      module_source_dir = target_out_dir + "/tv_resources/"
149      module_install_name = ""
150    } else {
151      deps = [ ":get_system_resource" ]
152
153      sources = [ system_resource_path ]
154      outputs = [ target_out_dir + "/tv_resources/{{source_file_part}}" ]
155      module_source_dir = target_out_dir + "/tv_resources/"
156      module_install_name = ""
157    }
158  }
159
160  ohos_copy("copy_system_resource_wearable") {
161    if (use_mac) {
162      sources = [ "//prebuilts/ace-toolkit/preview/rich/resources" ]
163      outputs = [ target_out_dir + "/wearable_resources/{{source_file_part}}" ]
164      module_source_dir = target_out_dir + "/wearable_resources/"
165      module_install_name = ""
166    } else {
167      deps = [ ":get_system_resource" ]
168
169      sources = [ system_resource_path ]
170      outputs = [ target_out_dir + "/wearable_resources/{{source_file_part}}" ]
171      module_source_dir = target_out_dir + "/wearable_resources/"
172      module_install_name = ""
173    }
174  }
175}
176