• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
17# build javascript engine library
18template("js_engine") {
19  forward_variables_from(invoker, "*")
20
21  ohos_source_set(target_name) {
22    defines += invoker.defines
23    deps = []
24    configs = [ "$ace_root:ace_config" ]
25
26    if (use_js_debug) {
27      deps +=
28          [ "${engine_path}:js_engine_bridge_${engine_name}_debug_$platform" ]
29    } else {
30      deps += [ "${engine_path}:js_engine_bridge_${engine_name}_$platform" ]
31    }
32
33    # if support napi
34    sources = [ "common/js_engine.cpp" ]
35
36    deps += [ "$ace_napi:ace_napi" ]
37
38    if (defined(config.use_build_in_js_engine) &&
39        config.use_build_in_js_engine) {
40      deps += [ "$ace_root/frameworks/bridge:framework_bridge_$platform" ]
41    } else {
42      deps += [ "$ace_root/build:libace" ]
43      if (defined(config.build_container_scope_lib) &&
44          config.build_container_scope_lib) {
45        deps += [ "$ace_root/frameworks/core:ace_container_scope" ]
46      }
47    }
48  }
49}
50
51# dynamic generate js_engine targets
52foreach(item, ace_platforms) {
53  platform = item.name
54  engine_config = {
55  }
56  engine_config = item.config
57  support_engines = []
58  support_engines = engine_config.js_engines
59  foreach(engine, support_engines) {
60    js_engine("js_engine_${engine.engine_name}_$platform") {
61      platform = item.name
62      engine_name = engine.engine_name
63      engine_path = engine.engine_path
64      defines = engine.engine_defines
65      use_js_debug = false
66      config = {
67      }
68      if (defined(item.config)) {
69        config = item.config
70      }
71      if (defined(config.defines)) {
72        defines += config.defines
73      }
74    }
75    if (defined(engine.have_debug) && engine.have_debug) {
76      js_engine("js_engine_${engine.engine_name}_debug_$platform") {
77        platform = item.name
78        engine_name = engine.engine_name
79        engine_path = engine.engine_path
80        defines = engine.engine_defines
81        use_js_debug = true
82        config = {
83        }
84        if (defined(item.config)) {
85          config = item.config
86        }
87        if (defined(config.defines)) {
88          defines += config.defines
89        }
90      }
91    }
92  }
93}
94