• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_v8") {
18  forward_variables_from(invoker, "*")
19
20  ohos_source_set(target_name) {
21    defines += invoker.defines
22    if (target_cpu == "arm64") {
23      defines += [ "APP_USE_ARM64" ]
24    } else if (target_cpu == "arm") {
25      defines += [ "APP_USE_ARM" ]
26    }
27
28    configs = [
29      "$ace_root:ace_config",
30      "$v8_root:v8_header_features",
31    ]
32
33    configs += [ "$ace_flutter_engine_root:flutter_config" ]
34    include_dirs = [ "//third_party/v8/include" ]
35
36    sources = [
37      "v8_animation_bridge.cpp",
38      "v8_animator_bridge.cpp",
39      "v8_badge_bridge.cpp",
40      "v8_canvas_bridge.cpp",
41      "v8_chart_bridge.cpp",
42      "v8_clock_bridge.cpp",
43      "v8_component_api_bridge.cpp",
44      "v8_engine.cpp",
45      "v8_engine_loader.cpp",
46      "v8_group_js_bridge.cpp",
47      "v8_image_animator_bridge.cpp",
48      "v8_input_bridge.cpp",
49      "v8_list_bridge.cpp",
50      "v8_offscreen_canvas_bridge.cpp",
51      "v8_stepper_bridge.cpp",
52      "v8_utils.cpp",
53      "v8_xcomponent_bridge.cpp",
54    ]
55
56    deps = []
57    if (use_shared_v8) {
58      deps += [ "$v8_root:v8_shared" ]
59    } else {
60      deps += [
61        "$v8_root:ace_libicu",
62        "$v8_root:v8",
63        "$v8_root:v8_libbase",
64        "$v8_root:v8_libplatform",
65      ]
66    }
67
68    if (use_external_v8_snapshot) {
69      deps += [ "//third_party/jsframework:v8_snapshot_bin" ]
70      defines += [ "USE_EXTERNAL_V8_SNAPSHOT" ]
71    } else {
72      deps += [ "//third_party/jsframework:v8_snapshot_obj" ]
73    }
74
75    if (defined(config.use_build_in_js_engine) &&
76        config.use_build_in_js_engine) {
77      defines += [ "BUILT_IN_JS_ENGINE" ]
78      deps +=
79          [ "$ace_root/frameworks/bridge/common/utils/v8:ace_v8_helper_static" ]
80    } else {
81      deps += [ "$ace_root/frameworks/bridge/common/utils/v8:ace_v8_helper" ]
82    }
83
84    deps += [ "//foundation/arkui/napi:ace_napi_v8" ]
85  }
86}
87
88foreach(item, ace_platforms) {
89  platform = item.name
90  engine_config = {
91  }
92  engine_config = item.config
93  support_engines = []
94  support_engines = engine_config.js_engines
95  foreach(engine, support_engines) {
96    if (engine.engine_name == "v8") {
97      js_engine_v8("js_engine_bridge_v8_$platform") {
98        defines = engine.engine_defines
99        config = {
100        }
101
102        if (defined(item.config)) {
103          config = item.config
104        }
105        if (defined(config.defines)) {
106          defines += config.defines
107        }
108      }
109    }
110  }
111}
112