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
17# build service backend javascript engine library
18template("js_pa_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    configs = [ "$ace_root:ace_config" ]
26
27    deps = []
28    if (use_js_debug) {
29      deps += [
30        "${engine_path}:js_pa_engine_bridge_${engine_name}_debug_$platform",
31      ]
32    } else {
33      deps += [ "${engine_path}:js_pa_engine_bridge_${engine_name}_$platform" ]
34    }
35
36    deps += [ "$ace_root/build:libace_compatible" ]
37    if (defined(config.build_container_scope_lib) &&
38        config.build_container_scope_lib) {
39      external_deps = [ "napi:ace_container_scope" ]
40    }
41  }
42}
43
44# dynamic generate js_engine targets
45foreach(item, ace_platforms) {
46  platform = item.name
47  engine_config = {
48  }
49  engine_config = item.config
50  support_engines = []
51  support_engines = engine_config.js_engines
52  foreach(engine, support_engines) {
53    js_pa_engine("js_pa_engine_${engine.engine_name}_$platform") {
54      platform = item.name
55      engine_name = engine.engine_name
56      engine_path = engine.engine_path
57      defines = engine.engine_defines
58      use_js_debug = false
59      config = {
60      }
61      if (defined(item.config)) {
62        config = item.config
63      }
64      if (defined(config.defines)) {
65        defines += config.defines
66      }
67    }
68    if (defined(engine.have_debug) && engine.have_debug) {
69      js_pa_engine("js_pa_engine_${engine.engine_name}_debug_$platform") {
70        platform = item.name
71        engine_name = engine.engine_name
72        engine_path = engine.engine_path
73        defines = engine.engine_defines
74        use_js_debug = true
75        config = {
76        }
77        if (defined(item.config)) {
78          config = item.config
79        }
80        if (defined(config.defines)) {
81          defines += config.defines
82        }
83      }
84    }
85  }
86}
87