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 # Avoid conditional judgment branches caused by dynamic library suffixes. 48 if (use_mac) { 49 dylib_suffix = ".dylib" 50 } else if (use_mingw_win) { 51 dylib_suffix = ".dll" 52 } else if (use_linux) { 53 dylib_suffix = ".so" 54 } 55 56 # All dynamic libraries to be copied to the path "/previewer/common/bin/module/", 57 # which are called by the napi framework, can be added to this script. 58 ohos_copy("copy_napi_modules_shared_library") { 59 deps = [] 60 sources = [] 61 out_path = get_label_info( 62 "//base/hiviewdfx/hilog/interfaces/js/kits/napi:libhilognapi", 63 "root_out_dir") 64 deps += [ "//base/hiviewdfx/hilog/interfaces/js/kits/napi:libhilognapi" ] 65 sources += [ "${out_path}/hiviewdfx/hilog_native/libhilog${dylib_suffix}" ] 66 67 foreach(module, common_napi_libs) { 68 out_path = get_label_info("$ace_root/interfaces/napi/kits:${module}", 69 "root_out_dir") 70 deps += [ "$ace_root/interfaces/napi/kits:${module}" ] 71 sources += [ "${out_path}/arkui/ace_engine/lib${module}${dylib_suffix}" ] 72 } 73 74 outputs = 75 [ target_out_dir + "/previewer/common/bin/module/{{source_file_part}}" ] 76 module_source_dir = target_out_dir + "/previewer/common/bin/module/" 77 module_install_name = "" 78 } 79 80 if (use_mac || use_mingw_win) { 81 ohos_copy("copy_distributeddata_library") { 82 out_path = get_label_info( 83 "//foundation/distributeddatamgr/kv_store/kvstoremock/interfaces/jskits/distributeddata:distributeddata", 84 "root_out_dir") 85 deps = [ "//foundation/distributeddatamgr/kv_store/kvstoremock/interfaces/jskits/distributeddata:distributeddata" ] 86 sources = [ "${out_path}/distributeddatamgr/kv_store/libdistributeddata${dylib_suffix}" ] 87 88 outputs = [ target_out_dir + 89 "/previewer/common/bin/module/data/{{source_file_part}}" ] 90 module_source_dir = target_out_dir + "/previewer/common/bin/module/data/" 91 module_install_name = "" 92 } 93 } 94 95 # All dynamic libraries to be copied to the path "/previewer/common/bin/", 96 # which are related to the previewer, can be added to this script. 97 ohos_copy("copy_preview_shared_library") { 98 deps = [] 99 sources = [] 100 101 # The two dynamic libraries here are used for local testing of the previewer. 102 if (enable_glfw_window) { 103 deps += [ 104 "$ace_root/adapter/preview/entrance/samples:previewer_demo", 105 "$ace_root/adapter/preview/entrance/test:test_bridge", 106 ] 107 } 108 109 # Add some resources 110 # Add ohos fonts 111 sources += [ 112 "//base/global/system_resources/fonts", 113 "//foundation/arkui/ace_engine/adapter/preview/sdk/fontconfig.json", 114 ] 115 116 # Add the dynamic library with the same name on the mac and windows system here. 117 if (use_mac || use_mingw_win) { 118 # Add dynamic library "native_preferences" 119 native_preferences_path = get_label_info( 120 "//foundation/distributeddatamgr/preferences/interfaces/inner_api:native_preferences", 121 "root_out_dir") 122 deps += [ "//foundation/distributeddatamgr/preferences/interfaces/inner_api:native_preferences" ] 123 sources += [ "${native_preferences_path}/distributeddatamgr/preferences/libnative_preferences${dylib_suffix}" ] 124 125 # Add dynamic library "native_rdb" 126 native_rdb_path = get_label_info( 127 "//foundation/distributeddatamgr/relational_store/interfaces/inner_api/rdb:native_rdb", 128 "root_out_dir") 129 deps += [ "//foundation/distributeddatamgr/relational_store/interfaces/inner_api/rdb:native_rdb" ] 130 sources += [ "${native_rdb_path}/distributeddatamgr/relational_store/libnative_rdb${dylib_suffix}" ] 131 132 # Add dynamic library "sqlite" 133 sqlite_path = 134 get_label_info("//third_party/sqlite:sqlite_sdk", "root_out_dir") 135 deps += [ "//third_party/sqlite:sqlite_sdk" ] 136 sources += [ "${sqlite_path}/common/common/libsqlite_sdk${dylib_suffix}" ] 137 138 # Add dynamic library "libcrypto_restool" 139 libcrypto_path = get_label_info("//third_party/openssl:libcrypto_restool", 140 "root_out_dir") 141 deps += [ "//third_party/openssl:libcrypto_restool" ] 142 sources += 143 [ "${libcrypto_path}/security/huks/libcrypto_restool${dylib_suffix}" ] 144 } 145 146 # Add dynamic library "hilog" 147 if (use_mac) { 148 hilog_path = get_label_info( 149 "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_mac", 150 "root_out_dir") 151 deps += 152 [ "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_mac" ] 153 sources += 154 [ "${hilog_path}/hiviewdfx/hilog_native/libhilog_mac${dylib_suffix}" ] 155 } else if (use_mingw_win) { 156 hilog_path = get_label_info( 157 "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_windows", 158 "root_out_dir") 159 deps += [ 160 "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_windows", 161 ] 162 sources += [ 163 "${hilog_path}/hiviewdfx/hilog_native/libhilog_windows${dylib_suffix}", 164 ] 165 } else if (use_linux) { 166 hilog_path = get_label_info( 167 "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_linux", 168 "root_out_dir") 169 deps += [ 170 "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_linux", 171 ] 172 sources += [ 173 "${hilog_path}/hiviewdfx/hilog_native/libhilog_linux${dylib_suffix}", 174 ] 175 } 176 177 # Add dynamic library "libcurl_shared" 178 curl_path = get_label_info("//third_party/curl:curl_shared", "root_out_dir") 179 deps += [ "//third_party/curl:curl_shared" ] 180 sources += [ curl_path + "/thirdparty/curl/libcurl_shared${dylib_suffix}" ] 181 182 # Add dynamic library "libnghttp2_shared" 183 nghttp2_path = get_label_info("//third_party/nghttp2/lib:libnghttp2_shared", 184 "root_out_dir") 185 deps += [ "//third_party/nghttp2/lib:libnghttp2_shared" ] 186 sources += 187 [ nghttp2_path + 188 "/thirdparty/thirdparty_nghttp2/libnghttp2_shared${dylib_suffix}" ] 189 190 # Add dynamic library "libssl_shared" 191 openssl_path = 192 get_label_info("//third_party/openssl:libssl_shared", "root_out_dir") 193 deps += [ "//third_party/openssl:libssl_shared" ] 194 sources += [ openssl_path + 195 "/developtools/profiler/libssl_openssl${dylib_suffix}" ] 196 197 # Add dynamic library "libcrypto_shared" 198 crypto_path = 199 get_label_info("//third_party/openssl:libcrypto_shared", "root_out_dir") 200 deps += [ "//third_party/openssl:libcrypto_shared" ] 201 sources += 202 [ "${crypto_path}/security/huks/libcrypto_openssl${dylib_suffix}" ] 203 204 if (use_mac || use_mingw_win) { 205 # add kvfdb 206 out_path = get_label_info( 207 "//foundation/distributeddatamgr/kv_store/kvstoremock/interfaces/innerkits/distributeddata:distributeddata_inner_mock", 208 "root_out_dir") 209 deps += [ "//foundation/distributeddatamgr/kv_store/kvstoremock/interfaces/innerkits/distributeddata:distributeddata_inner_mock" ] 210 sources += [ "${out_path}/distributeddatamgr/kv_store/libdistributeddata_inner_mock${dylib_suffix}" ] 211 out_path = get_label_info( 212 "//foundation/distributeddatamgr/kv_store/kvstoremock/distributeddb:distributeddb_mock", 213 "root_out_dir") 214 deps += [ "//foundation/distributeddatamgr/kv_store/kvstoremock/distributeddb:distributeddb_mock" ] 215 sources += [ "${out_path}/distributeddatamgr/kv_store/libdistributeddb_mock${dylib_suffix}" ] 216 217 #add shared_libz 218 out_path = 219 get_label_info("//third_party/zlib:shared_libz", "root_out_dir") 220 deps += [ "//third_party/zlib:shared_libz" ] 221 sources += [ "${out_path}/thirdparty/zlib/libshared_libz${dylib_suffix}" ] 222 } 223 224 # Add dynamic library "libsec_shared" 225 sec_path = 226 get_label_info("//third_party/bounds_checking_function:libsec_shared", 227 "root_out_dir") 228 deps += [ "//third_party/bounds_checking_function:libsec_shared" ] 229 sources += 230 [ sec_path + 231 "/thirdparty/bounds_checking_function/libsec_shared${dylib_suffix}" ] 232 233 # Add napi framework-related dynamic libraries 234 ace_napi_path = 235 get_label_info("//foundation/arkui/napi:ace_napi", "root_out_dir") 236 uv_path = get_label_info("//third_party/libuv:uv", "root_out_dir") 237 icu_path = 238 get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir") 239 cjson_path = get_label_info("//third_party/cJSON:cjson", "root_out_dir") 240 deps += [ 241 "$ace_napi:ace_napi", 242 "//third_party/cJSON:cjson", 243 "//third_party/icu/icu4c:shared_icui18n", 244 "//third_party/icu/icu4c:shared_icuuc", 245 "//third_party/libuv:uv", 246 ] 247 sources += [ 248 "$ace_napi_path/arkui/napi/libace_napi${dylib_suffix}", 249 "$cjson_path/thirdparty/cjson/libcjson${dylib_suffix}", 250 "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}", 251 "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}", 252 "$uv_path/thirdparty/libuv/libuv${dylib_suffix}", 253 ] 254 255 rosen_path = get_label_info( 256 "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", 257 "root_out_dir") 258 deps += [ 259 "//foundation/graphic/graphic_2d/rosen/modules/glfw_render_context:libglfw_render_context", 260 "//foundation/graphic/graphic_2d/rosen/modules/render_service_base:librender_service_base", 261 "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", 262 "//third_party/flutter/build/skia:skia_shared", 263 "//third_party/flutter/glfw:glfw", 264 ] 265 266 sources += [ 267 "${rosen_path}/graphic/graphic_standard/libglfw${dylib_suffix}", 268 "${rosen_path}/graphic/graphic_standard/libglfw_render_context${dylib_suffix}", 269 "${rosen_path}/graphic/graphic_standard/librender_service_base${dylib_suffix}", 270 "${rosen_path}/graphic/graphic_standard/librender_service_client${dylib_suffix}", 271 "${rosen_path}/thirdparty/flutter/libskia_shared${dylib_suffix}", 272 ] 273 274 # Add ark engine-related dynamic libraries 275 ark_js_path = get_label_info("//arkcompiler/ets_runtime:libark_jsruntime", 276 "root_out_dir") 277 deps += [ 278 "$ace_napi:ace_napi_ark", 279 "//arkcompiler/ets_runtime:libark_jsruntime", 280 ] 281 sources += [ 282 "$ace_napi_path/arkui/napi/libace_napi_ark${dylib_suffix}", 283 "$ark_js_path/arkcompiler/ets_runtime/libark_jsruntime${dylib_suffix}", 284 "//third_party/icu/ohos_icu4j/data/icudt69l.dat", 285 ] 286 287 # Add dynamic libraries with different names on mac and windows systems here. 288 if (use_mac) { 289 ace_engine_path = 290 get_label_info("$ace_root/adapter/preview/build::libace_engine_mac", 291 "root_out_dir") + 292 "/common/common/libace_engine_mac${dylib_suffix}" 293 294 resource_manager_path = get_label_info( 295 "//base/global/resource_management/frameworks/resmgr:global_resmgr_mac", 296 "root_out_dir") + "/global/resource_management/libglobal_resmgr_mac${dylib_suffix}" 297 deps += [ 298 "$ace_root/adapter/preview/build:libace_engine_mac", 299 "//base/global/resource_management/frameworks/resmgr:global_resmgr_mac", 300 ] 301 } else if (use_mingw_win) { 302 ace_engine_path = 303 get_label_info( 304 "$ace_root/adapter/preview/build::libace_engine_windows", 305 "root_out_dir") + 306 "/common/common/libace_engine_windows${dylib_suffix}" 307 resource_manager_path = get_label_info( 308 "//base/global/resource_management/frameworks/resmgr:global_resmgr_win", 309 "root_out_dir") + "/global/resource_management/libglobal_resmgr_win${dylib_suffix}" 310 deps += [ 311 "$ace_root/adapter/preview/build:libace_engine_windows", 312 "//base/global/resource_management/frameworks/resmgr:global_resmgr_win", 313 ] 314 } else if (use_linux) { 315 ace_engine_path = 316 get_label_info("$ace_root/adapter/preview/build::libace_engine_linux", 317 "root_out_dir") + 318 "/common/common/libace_engine_linux${dylib_suffix}" 319 resource_manager_path = get_label_info( 320 "//base/global/resource_management/frameworks/resmgr:global_resmgr_linux", 321 "root_out_dir") + "/global/resource_management/libglobal_resmgr_linux${dylib_suffix}" 322 deps += [ 323 "$ace_root/adapter/preview/build:libace_engine_linux", 324 "//base/global/resource_management/frameworks/resmgr:global_resmgr_linux", 325 ] 326 } 327 328 sources += [ 329 ace_engine_path, 330 resource_manager_path, 331 ] 332 333 # Set the output directory for all dynamic libraries. 334 outputs = [ target_out_dir + "/previewer/common/bin/{{source_file_part}}" ] 335 module_source_dir = target_out_dir + "/previewer/common/bin/" 336 module_install_name = "" 337 } 338 339 ohos_copy("copy_system_resource_standard") { 340 deps = [ ":get_system_resource" ] 341 342 sources = [ system_resource_path ] 343 344 outputs = [ target_out_dir + "/previewer/common/{{source_file_part}}" ] 345 module_source_dir = target_out_dir + "/previewer/common" 346 module_install_name = "" 347 } 348 349 if (use_mac || use_mingw_win) { 350 ohos_copy("copy_distributeddatamgr_library") { 351 #preferences 352 out_path = get_label_info( 353 "//foundation/distributeddatamgr/preferences/frameworks/js/napi:preferences", 354 "root_out_dir") 355 deps = [ "//foundation/distributeddatamgr/preferences/frameworks/js/napi/preferences:preferences" ] 356 sources = [ "${out_path}/distributeddatamgr/preferences/libpreferences${dylib_suffix}" ] 357 358 #rdb 359 out_path = get_label_info( 360 "//foundation/distributeddatamgr/relational_store/frameworks/js/napi/rdb:rdb", 361 "root_out_dir") 362 deps += [ "//foundation/distributeddatamgr/relational_store/frameworks/js/napi/rdb:rdb" ] 363 sources += [ 364 "${out_path}/distributeddatamgr/relational_store/librdb${dylib_suffix}", 365 ] 366 367 outputs = [ target_out_dir + 368 "/previewer/common/bin/module/data/{{source_file_part}}" ] 369 module_source_dir = target_out_dir + "/previewer/common/bin/module/data/" 370 module_install_name = "" 371 } 372 } 373 374 if (use_mac || use_mingw_win) { 375 ohos_copy("copy_communication_library") { 376 #http 377 out_path = get_label_info( 378 "//foundation/communication/netstack/frameworks/js/napi/http:http", 379 "root_out_dir") 380 deps = 381 [ "//foundation/communication/netstack/frameworks/js/napi/http:http" ] 382 sources = [ "${out_path}/communication/netstack/libhttp${dylib_suffix}" ] 383 384 outputs = [ target_out_dir + 385 "/previewer/common/bin/module/net/{{source_file_part}}" ] 386 module_source_dir = target_out_dir + "/previewer/common/bin/module/net/" 387 module_install_name = "" 388 } 389 } 390 391 if (use_mingw_win) { 392 ohos_copy("copy_preview_curl_cacert") { 393 sources = [ "//third_party/curl/cacert.pem" ] 394 outputs = [ target_out_dir + "/previewer/resources/cacert.pem" ] 395 module_source_dir = target_out_dir + "/previewer/resources" 396 module_install_name = "" 397 } 398 } 399} else { 400 ohos_copy("copy_system_resource") { 401 if (use_mac) { 402 sources = [ "//prebuilts/ace-toolkit/preview/rich/resources" ] 403 outputs = [ target_out_dir + "/tv_resources/{{source_file_part}}" ] 404 module_source_dir = target_out_dir + "/tv_resources/" 405 module_install_name = "" 406 } else { 407 deps = [ ":get_system_resource" ] 408 409 sources = [ system_resource_path ] 410 outputs = [ target_out_dir + "/tv_resources/{{source_file_part}}" ] 411 module_source_dir = target_out_dir + "/tv_resources/" 412 module_install_name = "" 413 } 414 } 415 416 ohos_copy("copy_system_resource_wearable") { 417 if (use_mac) { 418 sources = [ "//prebuilts/ace-toolkit/preview/rich/resources" ] 419 outputs = [ target_out_dir + "/wearable_resources/{{source_file_part}}" ] 420 module_source_dir = target_out_dir + "/wearable_resources/" 421 module_install_name = "" 422 } else { 423 deps = [ ":get_system_resource" ] 424 425 sources = [ system_resource_path ] 426 outputs = [ target_out_dir + "/wearable_resources/{{source_file_part}}" ] 427 module_source_dir = target_out_dir + "/wearable_resources/" 428 module_install_name = "" 429 } 430 } 431} 432