1# Copyright (c) 2021-2022 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") 16 17config("v8_engine_config") { 18 include_dirs = [ 19 "//third_party/v8/include", 20 "//foundation/arkui/napi", 21 ] 22} 23 24template("declarative_js_engine_v8") { 25 forward_variables_from(invoker, "*") 26 27 ohos_source_set(target_name) { 28 defines += invoker.defines 29 if (target_cpu == "arm64") { 30 defines += [ "APP_USE_ARM64" ] 31 } else if (target_cpu == "arm") { 32 defines += [ "APP_USE_ARM" ] 33 } 34 35 public_configs = [ 36 "$ace_root:ace_config", 37 ":v8_engine_config", 38 "$v8_root:v8_header_features", 39 ] 40 41 sources = [ 42 "functions/v8_function.cpp", 43 "v8_declarative_engine.cpp", 44 "v8_declarative_group_js_bridge.cpp", 45 "v8_function_destroy_helper.cpp", 46 "v8_js_matrix4.cpp", 47 "v8_module_manager.cpp", 48 "v8_object_template.cpp", 49 "v8_types.cpp", 50 "v8_utils.cpp", 51 "v8_view_register.cpp", 52 ] 53 54 deps = [] 55 if (use_shared_v8) { 56 deps += [ "$v8_root:v8_shared" ] 57 } else { 58 deps += [ 59 "$v8_root:ace_libicu", 60 "$v8_root:v8", 61 "$v8_root:v8_libbase", 62 "$v8_root:v8_libplatform", 63 ] 64 } 65 66 if (defined(config.use_build_in_js_engine) && 67 config.use_build_in_js_engine) { 68 deps += 69 [ "$ace_root/frameworks/bridge/common/utils/v8:ace_v8_helper_static" ] 70 } else { 71 deps += [ "$ace_root/frameworks/bridge/common/utils/v8:ace_v8_helper" ] 72 } 73 74 public_deps = [ "//foundation/arkui/napi:ace_napi" ] 75 deps += [ "//foundation/arkui/napi:ace_napi_v8" ] 76 } 77} 78 79foreach(item, ace_platforms) { 80 platform = item.name 81 engine_config = { 82 } 83 engine_config = item.config 84 support_engines = [] 85 support_engines = engine_config.js_engines 86 foreach(engine, support_engines) { 87 if (engine.engine_name == "v8") { 88 declarative_js_engine_v8("declarative_js_engine_bridge_v8_$platform") { 89 defines = engine.engine_defines 90 config = { 91 } 92 93 if (defined(item.config)) { 94 config = item.config 95 } 96 if (defined(config.defines)) { 97 defines += config.defines 98 } 99 } 100 } 101 } 102} 103