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/ts2panda/ts2abc_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 22ts2abc_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 = [ 54 "$ace_root:ace_config", 55 "//arkcompiler/ets_runtime:ark_jsruntime_public_config", 56 ] 57 58 sources = [ 59 "ark_js_runtime.cpp", 60 "ark_js_value.cpp", 61 "jsi_animation_bridge.cpp", 62 "jsi_animator_bridge.cpp", 63 "jsi_badge_bridge.cpp", 64 "jsi_base_utils.cpp", 65 "jsi_canvas_bridge.cpp", 66 "jsi_chart_bridge.cpp", 67 "jsi_clock_bridge.cpp", 68 "jsi_component_api_bridge.cpp", 69 "jsi_engine.cpp", 70 "jsi_engine_loader.cpp", 71 "jsi_group_js_bridge.cpp", 72 "jsi_image_animator_bridge.cpp", 73 "jsi_input_bridge.cpp", 74 "jsi_list_bridge.cpp", 75 "jsi_offscreen_canvas_bridge.cpp", 76 "jsi_stepper_bridge.cpp", 77 ] 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 deps = [] 91 if (defined(config.build_for_preview) && config.build_for_preview) { 92 deps += [ 93 ":gen_obj_src_abc_strip_native_min", 94 "//foundation/arkui/napi/native_engine/impl/ark:ace_napi_impl_ark", 95 ] 96 } else if (defined(config.build_for_android) && config.build_for_android) { 97 deps += [ 98 ":gen_obj_src_abc_strip_native_min", 99 "//third_party/jsframework:ark_build", 100 ] 101 } else if (defined(config.build_for_ios) && config.build_for_ios) { 102 deps += [ 103 ":gen_obj_src_abc_strip_native_min", 104 "//foundation/arkui/napi/native_engine/impl/ark:ace_napi_impl_ark", 105 ] 106 deps += [ "//third_party/jsframework:ark_build" ] 107 external_deps = [ "napi:ace_napi" ] 108 } else { 109 deps += [ "//third_party/jsframework:ark_build" ] 110 external_deps = [ 111 "multimedia_image_framework:image", 112 "multimedia_image_framework:image_native", 113 "napi:ace_napi", 114 ] 115 } 116 if (target_cpu == "arm64") { 117 defines += [ "APP_USE_ARM64" ] 118 } else if (target_cpu == "arm") { 119 defines += [ "APP_USE_ARM" ] 120 } 121 deps += [ "//foundation/arkui/napi:ace_napi_ark" ] 122 if (defined(config.build_for_ios) && config.build_for_ios) { 123 # static library for ios platform 124 deps += [ "//arkcompiler/ets_runtime:libark_jsruntime_static" ] 125 } else { 126 deps += [ "//arkcompiler/ets_runtime:libark_jsruntime" ] 127 } 128 } 129} 130 131foreach(item, ace_platforms) { 132 platform = item.name 133 engine_config = { 134 } 135 engine_config = item.config 136 support_engines = [] 137 support_engines = engine_config.js_engines 138 foreach(engine, support_engines) { 139 if (engine.engine_name == "ark") { 140 js_engine_ark("js_engine_bridge_ark_$platform") { 141 defines = engine.engine_defines 142 config = { 143 } 144 145 if (defined(item.config)) { 146 config = item.config 147 } 148 if (defined(config.defines)) { 149 defines += config.defines 150 } 151 } 152 } 153 } 154} 155