• 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 = [ "$flutter_root/engine" ]
77    cflags_cc = [ "-Wno-thread-safety-attributes" ]
78
79    # xcomponent components supports phone, TV and wearable except PC Preview
80    if (defined(config.xcomponent_components_support) &&
81        config.xcomponent_components_support) {
82      sources += [ "jsi_xcomponent_bridge.cpp" ]
83    }
84
85    if (defined(config.use_build_in_js_engine) &&
86        config.use_build_in_js_engine) {
87      defines += [ "BUILT_IN_JS_ENGINE" ]
88    }
89
90    external_deps = []
91    deps = []
92    if (defined(config.build_for_preview) && config.build_for_preview) {
93      deps += [
94        ":gen_obj_src_abc_strip_native_min",
95        "//foundation/arkui/napi/native_engine/impl/ark:ace_napi_impl_ark",
96      ]
97    } else if (defined(config.build_for_android) && config.build_for_android) {
98      deps += [
99        ":gen_obj_src_abc_strip_native_min",
100        "//third_party/jsframework:ark_build",
101      ]
102    } else if (defined(config.build_for_ios) && config.build_for_ios) {
103      deps += [
104        ":gen_obj_src_abc_strip_native_min",
105        "//foundation/arkui/napi/native_engine/impl/ark:ace_napi_impl_ark",
106      ]
107      deps += [ "//third_party/jsframework:ark_build" ]
108      external_deps += [ "napi:ace_napi" ]
109    } else {
110      deps += [ "//third_party/jsframework:ark_build" ]
111      external_deps += [
112        "image_framework:image",
113        "image_framework:image_native",
114        "napi:ace_napi",
115      ]
116    }
117    if (target_cpu == "arm64") {
118      defines += [ "APP_USE_ARM64" ]
119    } else if (target_cpu == "arm") {
120      defines += [ "APP_USE_ARM" ]
121    }
122    external_deps += [ "napi:ace_napi_ark" ]
123
124    # add for cross_platfrom_build temporarily, shall be removed after external_deps is supported
125    if (is_arkui_x) {
126      deps += [ "$ark_ets_path:libark_jsruntime_static" ]
127      if (defined(config.pixel_map_support) && config.pixel_map_support) {
128        configs += [
129          "//foundation/multimedia/image_framework/interfaces/innerkits:image_external_config",
130          "//foundation/arkui/napi:ace_napi_config",
131        ]
132      }
133    } else {
134      external_deps += [ "ets_runtime:libark_jsruntime" ]
135    }
136  }
137}
138
139foreach(item, ace_platforms) {
140  platform = item.name
141  engine_config = {
142  }
143  engine_config = item.config
144  support_engines = []
145  support_engines = engine_config.js_engines
146  foreach(engine, support_engines) {
147    if (engine.engine_name == "ark") {
148      js_engine_ark("js_engine_bridge_ark_$platform") {
149        defines = engine.engine_defines
150        config = {
151        }
152
153        if (defined(item.config)) {
154          config = item.config
155        }
156        if (defined(config.defines)) {
157          defines += config.defines
158        }
159      }
160    }
161  }
162}
163