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") 16 17# build javascript engine library 18template("js_engine") { 19 forward_variables_from(invoker, "*") 20 21 ohos_source_set(target_name) { 22 subsystem_name = ace_engine_subsystem 23 part_name = ace_engine_part 24 defines += invoker.defines 25 if (target_cpu == "arm64") { 26 if (!is_mingw) { 27 defines += [ "_ARM64_" ] 28 } 29 } 30 if (current_os == "ohos" && current_cpu == "x86_64") { 31 defines += [ "SIMULATOR_64" ] 32 } 33 deps = [] 34 external_deps = [] 35 configs = [ "$ace_root:ace_config" ] 36 37 if (use_js_debug) { 38 deps += 39 [ "${engine_path}:js_engine_bridge_${engine_name}_debug_$platform" ] 40 } else { 41 deps += [ "${engine_path}:js_engine_bridge_${engine_name}_$platform" ] 42 } 43 44 # if support napi 45 sources = [ "common/js_engine.cpp" ] 46 47 external_deps += [ "napi:ace_napi" ] 48 49 if (defined(config.use_build_in_js_engine) && 50 config.use_build_in_js_engine) { 51 deps += [ "$ace_root/frameworks/bridge:framework_bridge_$platform" ] 52 } else { 53 deps += [ "$ace_root/build:libace" ] 54 if (defined(config.build_container_scope_lib) && 55 config.build_container_scope_lib) { 56 if (is_arkui_x) { 57 deps += [ "$ace_napi:ace_container_scope_static" ] 58 } else { 59 external_deps += [ "napi:ace_container_scope" ] 60 } 61 } 62 } 63 } 64} 65 66# dynamic generate js_engine targets 67foreach(item, ace_platforms) { 68 platform = item.name 69 engine_config = { 70 } 71 engine_config = item.config 72 support_engines = [] 73 support_engines = engine_config.js_engines 74 foreach(engine, support_engines) { 75 js_engine("js_engine_${engine.engine_name}_$platform") { 76 platform = item.name 77 engine_name = engine.engine_name 78 engine_path = engine.engine_path 79 defines = engine.engine_defines 80 use_js_debug = false 81 config = { 82 } 83 if (defined(item.config)) { 84 config = item.config 85 } 86 if (defined(config.defines)) { 87 defines += config.defines 88 } 89 } 90 if (defined(engine.have_debug) && engine.have_debug) { 91 js_engine("js_engine_${engine.engine_name}_debug_$platform") { 92 platform = item.name 93 engine_name = engine.engine_name 94 engine_path = engine.engine_path 95 defines = engine.engine_defines 96 use_js_debug = true 97 config = { 98 } 99 if (defined(item.config)) { 100 config = item.config 101 } 102 if (defined(config.defines)) { 103 defines += config.defines 104 } 105 } 106 } 107 } 108} 109