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/ace/ace_engine/ace_config.gni") 16 17config("v8_engine_config") { 18 include_dirs = [ 19 "//third_party/v8/include", 20 "//foundation/ace/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 "content_storage_set.cpp", 43 "functions/v8_function.cpp", 44 "js_converter.cpp", 45 "v8_declarative_engine.cpp", 46 "v8_declarative_group_js_bridge.cpp", 47 "v8_function_destroy_helper.cpp", 48 "v8_js_matrix4.cpp", 49 "v8_module_manager.cpp", 50 "v8_object_template.cpp", 51 "v8_types.cpp", 52 "v8_utils.cpp", 53 "v8_view_register.cpp", 54 ] 55 56 deps = [] 57 if (use_shared_v8) { 58 deps += [ "$v8_root:v8_shared" ] 59 } else { 60 deps += [ 61 "$v8_root:ace_libicu", 62 "$v8_root:v8", 63 "$v8_root:v8_libbase", 64 "$v8_root:v8_libplatform", 65 ] 66 } 67 68 if (defined(config.use_build_in_js_engine) && 69 config.use_build_in_js_engine) { 70 deps += 71 [ "$ace_root/frameworks/bridge/common/utils/v8:ace_v8_helper_static" ] 72 } else { 73 deps += [ "$ace_root/frameworks/bridge/common/utils/v8:ace_v8_helper" ] 74 } 75 76 public_deps = [ "//foundation/ace/napi:ace_napi" ] 77 deps += [ "//foundation/ace/napi:ace_napi_v8" ] 78 } 79} 80 81foreach(item, ace_platforms) { 82 platform = item.name 83 engine_config = { 84 } 85 engine_config = item.config 86 support_engines = [] 87 support_engines = engine_config.js_engines 88 foreach(engine, support_engines) { 89 if (engine.engine_name == "v8") { 90 declarative_js_engine_v8("declarative_js_engine_bridge_v8_$platform") { 91 defines = engine.engine_defines 92 config = { 93 } 94 95 if (defined(item.config)) { 96 config = item.config 97 } 98 if (defined(config.defines)) { 99 defines += config.defines 100 } 101 } 102 } 103 } 104} 105