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