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