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