1# Copyright (c) 2021 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/interfaces/napi/kits/napi_lib.gni") 17 18# Build libace static library 19template("libace_static") { 20 forward_variables_from(invoker, "*") 21 22 ohos_source_set(target_name) { 23 if (current_os == "ohos") { 24 sanitize = { 25 integer_overflow = true 26 boundary_sanitize = true 27 debug = ace_sanitize_debug 28 } 29 } 30 31 deps = [ "$ace_root/frameworks/base:ace_base_$platform" ] 32 external_deps = [] 33 if (use_mingw_win || use_mac || use_linux) { 34 external_deps += [ 35 "icu:shared_icui18n", 36 "icu:shared_icuuc", 37 ] 38 } 39 40 if (platform == "ohos_ng" || is_arkui_x) { 41 deps += [ 42 "$ace_root/frameworks/bridge:framework_bridge_ng_$platform", 43 "$ace_root/frameworks/core:ace_core_ng_$platform", 44 ] 45 } else if (platform == "ohos" && !is_asan) { 46 deps += [ 47 "$ace_root/frameworks/bridge:framework_bridge_$platform", 48 "$ace_root/frameworks/core:ace_core_$platform", 49 ] 50 51 # add napi lib to libace.z.so for auto load in old generation mode 52 foreach(module, common_napi_libs) { 53 target_names = [] 54 prefix_dir = [] 55 module_path = [] 56 module_name = [] 57 58 target_names = string_split(module, "/") 59 prefix_dir = target_names[0] 60 if (prefix_dir != module) { 61 module_path = target_names[1] 62 } else { 63 module_path = prefix_dir 64 } 65 module_name = string_replace(module_path, "_", "") 66 67 deps += [ "$ace_root/interfaces/napi/kits/${module_path}:${module_name}_static_${platform}" ] 68 } 69 } else { 70 deps += [ 71 "$ace_root/frameworks/bridge:framework_bridge_$platform", 72 "$ace_root/frameworks/core:ace_core_$platform", 73 ] 74 } 75 76 if (defined(config.platform_deps)) { 77 deps += config.platform_deps 78 } 79 80 # build-in ark js engine for preview 81 if (defined(config.use_build_in_js_engine) && 82 config.use_build_in_js_engine && defined(config.ark_engine)) { 83 if (platform == "ohos_ng" || is_arkui_x) { 84 deps += [ "$ace_root/frameworks/bridge/declarative_frontend:declarative_js_engine_ng_ark_$platform" ] 85 } else { 86 deps += [ 87 "$ace_root/frameworks/bridge/declarative_frontend:declarative_js_engine_ark_$platform", 88 "$ace_root/frameworks/bridge/js_frontend/engine:js_engine_ark_$platform", 89 ] 90 } 91 } 92 configs = [ "$ace_root:ace_coverage_config" ] 93 if (use_hilog) { 94 external_deps += [ "hilog:libhilog" ] 95 } 96 part_name = ace_engine_part 97 subsystem_name = ace_engine_subsystem 98 } 99} 100 101# build platform engine sources 102template("ace_bridge_engine") { 103 forward_variables_from(invoker, "*") 104 105 ohos_shared_library(target_name) { 106 configs = [ "$ace_root:ace_coverage_config" ] 107 deps = [] 108 109 assert(defined(platform) && (platform == "ohos" || platform == "ohos_ng"), 110 "Only ohos need separated engine lib") 111 112 if (use_hilog) { 113 external_deps = [ "hilog:libhilog" ] 114 } 115 if (build_type == "engine") { 116 if (use_js_debug) { 117 deps += [ "$ace_root/frameworks/bridge/js_frontend/engine:js_engine_${engine_name}_debug_$platform" ] 118 } else { 119 deps += [ "$ace_root/frameworks/bridge/js_frontend/engine:js_engine_${engine_name}_$platform" ] 120 } 121 } else if (build_type == "engine_declarative") { 122 deps += [ "$ace_root/frameworks/bridge/declarative_frontend:declarative_js_engine_${engine_name}_$platform" ] 123 } else if (build_type == "engine_pa") { 124 deps += [ "$ace_root/${pa_engine_path}/engine:js_pa_engine_${engine_name}_$platform" ] 125 } 126 127 subsystem_name = ace_engine_subsystem 128 part_name = ace_engine_part 129 } 130} 131