• 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/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    configs = [ "$ace_root:ace_config" ]
35
36    if (use_js_debug) {
37      deps +=
38          [ "${engine_path}:js_engine_bridge_${engine_name}_debug_$platform" ]
39    } else {
40      deps += [ "${engine_path}:js_engine_bridge_${engine_name}_$platform" ]
41    }
42
43    # if support napi
44    sources = [ "common/js_engine.cpp" ]
45
46    deps += [ "$ace_napi:ace_napi" ]
47
48    if (defined(config.use_build_in_js_engine) &&
49        config.use_build_in_js_engine) {
50      deps += [ "$ace_root/frameworks/bridge:framework_bridge_$platform" ]
51    } else {
52      deps += [ "$ace_root/build:libace" ]
53      if (defined(config.build_container_scope_lib) &&
54          config.build_container_scope_lib) {
55        deps += [ "$ace_napi:ace_container_scope" ]
56      }
57    }
58  }
59}
60
61# dynamic generate js_engine targets
62foreach(item, ace_platforms) {
63  platform = item.name
64  engine_config = {
65  }
66  engine_config = item.config
67  support_engines = []
68  support_engines = engine_config.js_engines
69  foreach(engine, support_engines) {
70    js_engine("js_engine_${engine.engine_name}_$platform") {
71      platform = item.name
72      engine_name = engine.engine_name
73      engine_path = engine.engine_path
74      defines = engine.engine_defines
75      use_js_debug = false
76      config = {
77      }
78      if (defined(item.config)) {
79        config = item.config
80      }
81      if (defined(config.defines)) {
82        defines += config.defines
83      }
84    }
85    if (defined(engine.have_debug) && engine.have_debug) {
86      js_engine("js_engine_${engine.engine_name}_debug_$platform") {
87        platform = item.name
88        engine_name = engine.engine_name
89        engine_path = engine.engine_path
90        defines = engine.engine_defines
91        use_js_debug = true
92        config = {
93        }
94        if (defined(item.config)) {
95          config = item.config
96        }
97        if (defined(config.defines)) {
98          defines += config.defines
99        }
100      }
101    }
102  }
103}
104