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 = [ "//third_party/icu/ohos_icu4j/data/icudt72l.dat" ] 146 if (ace_engine_feature_enable_upgrade_skia) { 147 sources += [ 148 "//third_party/skia/m133/src/ports/skia_ohos/config/fontconfig.json", 149 "//third_party/skia/m133/src/ports/skia_ohos/config/fontconfig_ohos.json", 150 ] 151 } else { 152 sources += [ 153 "//third_party/skia/src/ports/skia_ohos/config/fontconfig.json", 154 "//third_party/skia/src/ports/skia_ohos/config/fontconfig_ohos.json", 155 ] 156 } 157 158 foreach(item, common_bin) { 159 subsystem_name = item.subsystem_name 160 part_name = item.part_name 161 deps += [ item.label ] 162 out_path = get_label_info(item.label, "root_out_dir") 163 lib_names = [] 164 if (defined(item.lib_names)) { 165 lib_names += item.lib_names 166 } else { 167 lib_names += 168 [ string_replace(get_label_info(item.label, "name"), "lib", "", 1) ] 169 } 170 foreach(lib_name, lib_names) { 171 sources += [ "${out_path}/${subsystem_name}/${part_name}/lib${lib_name}${dylib_suffix}" ] 172 } 173 } 174 175 # Set the output directory for all dynamic libraries. 176 outputs = [ target_out_dir + "/previewer/common/bin/{{source_file_part}}" ] 177 module_source_dir = target_out_dir + "/previewer/common/bin/" 178 module_install_name = "" 179 } 180 181 if (use_mingw_win) { 182 ohos_copy("copy_preview_curl_cacert") { 183 sources = [ "//third_party/curl/cacert.pem" ] 184 outputs = [ target_out_dir + "/previewer/resources/cacert.pem" ] 185 module_source_dir = target_out_dir + "/previewer/resources" 186 module_install_name = "" 187 } 188 } 189 190 ohos_copy("copy_system_resource_standard") { 191 deps = [ 192 ":extra_system_resource", 193 ":get_system_resource", 194 ] 195 196 sources = [ system_resource_path ] 197 198 outputs = [ target_out_dir + "/previewer/common/{{source_file_part}}" ] 199 module_source_dir = target_out_dir + "/previewer/common" 200 module_install_name = "" 201 } 202} else { 203 ohos_copy("copy_system_resource") { 204 if (use_mac) { 205 sources = [ "//prebuilts/ace-toolkit/preview/rich/resources" ] 206 outputs = [ target_out_dir + "/tv_resources/{{source_file_part}}" ] 207 module_source_dir = target_out_dir + "/tv_resources/" 208 module_install_name = "" 209 } else { 210 deps = [ 211 ":extra_system_resource", 212 ":get_system_resource", 213 ] 214 215 sources = [ system_resource_path ] 216 outputs = [ target_out_dir + "/tv_resources/{{source_file_part}}" ] 217 module_source_dir = target_out_dir + "/tv_resources/" 218 module_install_name = "" 219 } 220 } 221 222 ohos_copy("copy_system_resource_wearable") { 223 if (use_mac) { 224 sources = [ "//prebuilts/ace-toolkit/preview/rich/resources" ] 225 outputs = [ target_out_dir + "/wearable_resources/{{source_file_part}}" ] 226 module_source_dir = target_out_dir + "/wearable_resources/" 227 module_install_name = "" 228 } else { 229 deps = [ 230 ":extra_system_resource", 231 ":get_system_resource", 232 ] 233 234 sources = [ system_resource_path ] 235 outputs = [ target_out_dir + "/wearable_resources/{{source_file_part}}" ] 236 module_source_dir = target_out_dir + "/wearable_resources/" 237 module_install_name = "" 238 } 239 } 240} 241