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