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:uicontext", 111 "$ace_root/frameworks/bridge/declarative_frontend:x_node", 112 ] 113 out_path = get_label_info( 114 "$ace_root/frameworks/bridge/declarative_frontend:ark_modifier", 115 "root_out_dir") 116 sources = [ 117 "${out_path}/arkui/ace_engine/modifier.abc", 118 "${out_path}/arkui/ace_engine/node.abc", 119 "${out_path}/arkui/ace_engine/shape.abc", 120 "${out_path}/arkui/ace_engine/theme.abc", 121 "${out_path}/arkui/ace_engine/uicontext.abc", 122 ] 123 124 outputs = [ target_out_dir + 125 "/previewer/common/bin/module/arkui/{{source_file_part}}" ] 126 module_source_dir = target_out_dir + "/previewer/common/bin/module/arkui" 127 module_install_name = "" 128 } 129 130 # All dynamic libraries to be copied to the path "/previewer/common/bin/", 131 # which are related to the previewer, can be added to this script. 132 ohos_copy("copy_preview_shared_library") { 133 deps = [] 134 foreach(module, napi_modules) { 135 deps += [ ":copy_napi_${module.prefix}libs" ] 136 } 137 138 # The dynamic library here is used for local testing of the previewer. 139 if (enable_glfw_window) { 140 deps += [ "$ace_root/adapter/preview/entrance/samples:previewer_demo" ] 141 } 142 143 sources = [ 144 "//third_party/icu/ohos_icu4j/data/icudt72l.dat", 145 "//third_party/skia/src/ports/skia_ohos/config/fontconfig.json", 146 ] 147 148 foreach(item, common_bin) { 149 subsystem_name = item.subsystem_name 150 part_name = item.part_name 151 deps += [ item.label ] 152 out_path = get_label_info(item.label, "root_out_dir") 153 lib_names = [] 154 if (defined(item.lib_names)) { 155 lib_names += item.lib_names 156 } else { 157 lib_names += 158 [ string_replace(get_label_info(item.label, "name"), "lib", "", 1) ] 159 } 160 foreach(lib_name, lib_names) { 161 sources += [ "${out_path}/${subsystem_name}/${part_name}/lib${lib_name}${dylib_suffix}" ] 162 } 163 } 164 165 # Set the output directory for all dynamic libraries. 166 outputs = [ target_out_dir + "/previewer/common/bin/{{source_file_part}}" ] 167 module_source_dir = target_out_dir + "/previewer/common/bin/" 168 module_install_name = "" 169 } 170 171 if (use_mingw_win) { 172 ohos_copy("copy_preview_curl_cacert") { 173 sources = [ "//third_party/curl/cacert.pem" ] 174 outputs = [ target_out_dir + "/previewer/resources/cacert.pem" ] 175 module_source_dir = target_out_dir + "/previewer/resources" 176 module_install_name = "" 177 } 178 } 179 180 ohos_copy("copy_system_resource_standard") { 181 deps = [ 182 ":extra_system_resource", 183 ":get_system_resource", 184 ] 185 186 sources = [ system_resource_path ] 187 188 outputs = [ target_out_dir + "/previewer/common/{{source_file_part}}" ] 189 module_source_dir = target_out_dir + "/previewer/common" 190 module_install_name = "" 191 } 192} else { 193 ohos_copy("copy_system_resource") { 194 if (use_mac) { 195 sources = [ "//prebuilts/ace-toolkit/preview/rich/resources" ] 196 outputs = [ target_out_dir + "/tv_resources/{{source_file_part}}" ] 197 module_source_dir = target_out_dir + "/tv_resources/" 198 module_install_name = "" 199 } else { 200 deps = [ 201 ":extra_system_resource", 202 ":get_system_resource", 203 ] 204 205 sources = [ system_resource_path ] 206 outputs = [ target_out_dir + "/tv_resources/{{source_file_part}}" ] 207 module_source_dir = target_out_dir + "/tv_resources/" 208 module_install_name = "" 209 } 210 } 211 212 ohos_copy("copy_system_resource_wearable") { 213 if (use_mac) { 214 sources = [ "//prebuilts/ace-toolkit/preview/rich/resources" ] 215 outputs = [ target_out_dir + "/wearable_resources/{{source_file_part}}" ] 216 module_source_dir = target_out_dir + "/wearable_resources/" 217 module_install_name = "" 218 } else { 219 deps = [ 220 ":extra_system_resource", 221 ":get_system_resource", 222 ] 223 224 sources = [ system_resource_path ] 225 outputs = [ target_out_dir + "/wearable_resources/{{source_file_part}}" ] 226 module_source_dir = target_out_dir + "/wearable_resources/" 227 module_install_name = "" 228 } 229 } 230} 231