• 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/config/components/ets_frontend/es2abc_config.gni")
15import("//build/ohos.gni")
16import("//foundation/arkui/ace_engine/ace_config.gni")
17import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni")
18
19if (is_arkui_x || use_mac || use_mingw_win || use_linux) {
20  base_output_path = get_label_info(":gen_abc_proxyclass", "target_out_dir")
21  abcstrip_native_min_obj_path = base_output_path + "strip.native.min.abc"
22
23  es2abc_gen_abc("gen_strip_native_min_abc") {
24    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
25    src_js = rebase_path(
26            "$root_out_dir/obj/third_party/jsframework/dist/strip.native.min.js")
27    dst_file = rebase_path(base_output_path + "/strip.native.min.abc")
28
29    in_puts =
30        [ "$root_out_dir/obj/third_party/jsframework/dist/strip.native.min.js" ]
31    out_puts = [ base_output_path + "/strip.native.min.abc" ]
32    extra_dependencies = [ "//third_party/jsframework:gen_snapshot" ]
33  }
34
35  gen_obj("abc_strip_native_min") {
36    input = base_output_path + "/strip.native.min.abc"
37    if (use_mac || use_mingw_win || use_ios || use_linux) {
38      abcstripnativemin_obj_path = base_output_path + "/strip_native_min.c"
39    } else {
40      abcstripnativemin_obj_path = base_output_path + "/strip_native_min.o"
41    }
42    output = abcstripnativemin_obj_path
43    snapshot_dep = [ ":gen_strip_native_min_abc" ]
44  }
45}
46
47template("js_engine_ark") {
48  forward_variables_from(invoker, "*")
49
50  ohos_source_set(target_name) {
51    subsystem_name = ace_engine_subsystem
52    part_name = ace_engine_part
53    defines += invoker.defines
54
55    configs = [ "$ace_root:ace_config" ]
56
57    sources = [
58      "ark_js_runtime.cpp",
59      "ark_js_value.cpp",
60      "jsi_animation_bridge.cpp",
61      "jsi_animator_bridge.cpp",
62      "jsi_badge_bridge.cpp",
63      "jsi_base_utils.cpp",
64      "jsi_canvas_bridge.cpp",
65      "jsi_chart_bridge.cpp",
66      "jsi_clock_bridge.cpp",
67      "jsi_component_api_bridge.cpp",
68      "jsi_engine.cpp",
69      "jsi_engine_loader.cpp",
70      "jsi_group_js_bridge.cpp",
71      "jsi_image_animator_bridge.cpp",
72      "jsi_input_bridge.cpp",
73      "jsi_list_bridge.cpp",
74      "jsi_offscreen_canvas_bridge.cpp",
75      "jsi_stepper_bridge.cpp",
76    ]
77
78    cflags_cc = [ "-Wno-thread-safety-attributes" ]
79
80    # xcomponent components supports phone, TV and wearable except PC Preview
81    if (defined(config.xcomponent_components_support) &&
82        config.xcomponent_components_support) {
83      sources += [ "jsi_xcomponent_bridge.cpp" ]
84    }
85
86    if (defined(config.use_build_in_js_engine) &&
87        config.use_build_in_js_engine) {
88      defines += [ "BUILT_IN_JS_ENGINE" ]
89    }
90
91    external_deps = []
92    deps = [ "$ace_root/frameworks/core/components/theme:build_theme_code" ]
93    if (use_hilog) {
94      external_deps = [ "hilog:libhilog" ]
95    }
96    if (defined(config.build_for_preview) && config.build_for_preview) {
97      deps += [ ":gen_obj_src_abc_strip_native_min" ]
98      external_deps += [ "napi:ace_napi" ]
99      include_dirs = [ "//commonlibrary/c_utils/base/include" ]
100    } else if (defined(config.build_for_android) && config.build_for_android) {
101      deps += [
102        ":gen_obj_src_abc_strip_native_min",
103        "//third_party/css-what:css_what_sources",
104        "//third_party/jsframework:ark_build",
105      ]
106    } else if (defined(config.build_for_ios) && config.build_for_ios) {
107      deps += [ ":gen_obj_src_abc_strip_native_min" ]
108      external_deps += [
109        "css-what:css_what_sources",
110        "jsframework:ark_build",
111        "napi:ace_napi",
112      ]
113    } else {
114      external_deps += [
115        "css-what:css_what_sources",
116        "image_framework:image",
117        "image_framework:image_native",
118        "jsframework:ark_build",
119        "napi:ace_napi",
120      ]
121    }
122    if (target_cpu == "arm64") {
123      defines += [ "APP_USE_ARM64" ]
124    } else if (target_cpu == "arm") {
125      defines += [ "APP_USE_ARM" ]
126    }
127
128    # add for cross_platfrom_build temporarily, shall be removed after external_deps is supported
129    if (is_arkui_x) {
130      deps += [ "$ark_ets_path:libark_jsruntime_static" ]
131      if (defined(config.pixel_map_support) && config.pixel_map_support) {
132        configs += [
133          "//foundation/multimedia/image_framework/interfaces/innerkits:image_external_config",
134          "//foundation/arkui/napi:ace_napi_config",
135        ]
136      }
137    } else {
138      external_deps += [ "ets_runtime:libark_jsruntime" ]
139    }
140  }
141}
142
143foreach(item, ace_platforms) {
144  platform = item.name
145  engine_config = {
146  }
147  engine_config = item.config
148  support_engines = []
149  support_engines = engine_config.js_engines
150  foreach(engine, support_engines) {
151    if (engine.engine_name == "ark") {
152      js_engine_ark("js_engine_bridge_ark_$platform") {
153        defines = engine.engine_defines
154        config = {
155        }
156
157        if (defined(item.config)) {
158          config = item.config
159        }
160        if (defined(config.defines)) {
161          defines += config.defines
162        }
163      }
164    }
165  }
166}
167