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 17template("js_engine_qjs") { 18 forward_variables_from(invoker, "*") 19 20 ohos_source_set(target_name) { 21 subsystem_name = ace_engine_subsystem 22 part_name = ace_engine_part 23 defines += invoker.defines 24 25 configs = [ "$ace_root:ace_config" ] 26 27 sources = [ 28 "animation_bridge.cpp", 29 "animator_bridge.cpp", 30 "badge_bridge.cpp", 31 "canvas_bridge.cpp", 32 "chart_bridge.cpp", 33 "clock_bridge.cpp", 34 "component_api_bridge.cpp", 35 "image_animator_bridge.cpp", 36 "list_bridge.cpp", 37 "offscreen_canvas_bridge.cpp", 38 "qjs_engine.cpp", 39 "qjs_engine_loader.cpp", 40 "qjs_group_js_bridge.cpp", 41 "qjs_utils.cpp", 42 "qjs_xcomponent_bridge.cpp", 43 "stepper_bridge.cpp", 44 ] 45 46 deps = [ 47 "$ace_root/frameworks/core/components/theme:build_theme_code", 48 "//third_party/jsframework:jsf", 49 ] 50 51 if (use_js_debug) { 52 deps += [ 53 "//foundation/arkui/napi:ace_napi_quickjs_debug", 54 "//third_party/quickjs:qjs_debugger", 55 ] 56 defines += [ "ENABLE_JS_DEBUG" ] 57 configs += [ "//third_party/quickjs:qjs_debug_config" ] 58 } else { 59 deps += [ 60 "//foundation/arkui/napi:ace_napi_quickjs", 61 "//third_party/quickjs:qjs", 62 ] 63 } 64 65 if (defined(config.use_build_in_js_engine) && 66 config.use_build_in_js_engine) { 67 defines += [ "BUILT_IN_JS_ENGINE" ] 68 } 69 70 if (platform == "windows" || platform == "mac" || platform == "linux") { 71 defines += [ "ENABLE_JS_DEBUG_PREVIEW" ] 72 73 configs += [ "$ace_flutter_engine_root:flutter_config" ] 74 } 75 } 76} 77 78foreach(item, ace_platforms) { 79 platform = item.name 80 engine_config = { 81 } 82 engine_config = item.config 83 support_engines = [] 84 support_engines = engine_config.js_engines 85 foreach(engine, support_engines) { 86 if (engine.engine_name == "qjs") { 87 js_engine_qjs("js_engine_bridge_qjs_$platform") { 88 platform = item.name 89 defines = engine.engine_defines 90 use_js_debug = false 91 config = { 92 } 93 94 if (defined(item.config)) { 95 config = item.config 96 } 97 if (defined(config.defines)) { 98 defines += config.defines 99 } 100 } 101 if (defined(engine.have_debug) && engine.have_debug) { 102 js_engine_qjs("js_engine_bridge_qjs_debug_$platform") { 103 platform = item.name 104 defines = engine.engine_defines 105 use_js_debug = true 106 config = { 107 } 108 109 if (defined(item.config)) { 110 config = item.config 111 } 112 if (defined(config.defines)) { 113 defines += config.defines 114 } 115 } 116 } 117 } 118 } 119} 120