1# Copyright (c) 2021 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/ohos.gni") 15import("//foundation/arkui/ace_engine/ace_config.gni") 16import("//foundation/arkui/napi/napi.gni") 17 18config("ace_napi_ark_config") { 19 include_dirs = [ 20 "//foundation/arkui/napi", 21 "../../../../../../foundation/arkui/napi/native_engine/impl/ark", 22 "//third_party/libuv/include", 23 "//commonlibrary/c_utils/base/include", 24 ] 25 26 defines = [] 27 cflags_cc = [] 28 if (is_mingw || is_mac || is_linux) { 29 defines += [ "PREVIEW" ] 30 } 31 if (is_mingw) { 32 defines += [ "WINDOWS_PLATFORM" ] 33 cflags_cc += [ "-std=c++17" ] 34 } else if (is_mac) { 35 defines += [ "MAC_PLATFORM" ] 36 } else if (is_linux) { 37 defines += [ "LINUX_PLATFORM" ] 38 cflags_cc += [ "-std=c++17" ] 39 } else if (target_os == "ios") { 40 defines += [ "IOS_PLATFORM" ] 41 } 42} 43 44template("ace_napi_impl") { 45 ohos_source_set(target_name) { 46 public_configs = [ ":ace_napi_ark_config" ] 47 defines = invoker.engine_defines 48 49 include_dirs = [ "//foundation/arkui/napi/native_engine/impl/ark" ] 50 51 sources = [ 52 "ark_native_deferred.cpp", 53 "ark_native_engine.cpp", 54 "ark_native_reference.cpp", 55 "native_value/ark_native_array.cpp", 56 "native_value/ark_native_array_buffer.cpp", 57 "native_value/ark_native_big_int.cpp", 58 "native_value/ark_native_boolean.cpp", 59 "native_value/ark_native_buffer.cpp", 60 "native_value/ark_native_data_view.cpp", 61 "native_value/ark_native_date.cpp", 62 "native_value/ark_native_external.cpp", 63 "native_value/ark_native_function.cpp", 64 "native_value/ark_native_number.cpp", 65 "native_value/ark_native_object.cpp", 66 "native_value/ark_native_string.cpp", 67 "native_value/ark_native_typed_array.cpp", 68 "native_value/ark_native_value.cpp", 69 ] 70 71 if (target_cpu == "arm64") { 72 defines += [ "APP_USE_ARM64" ] 73 } else if (target_cpu == "arm") { 74 defines += [ "APP_USE_ARM" ] 75 } 76 if (target_os == "android") { 77 defines += [ "ANDROID_PLATFORM" ] 78 } 79 80 deps = [ "//foundation/arkui/napi:ace_napi" ] 81 82 external_deps = [] 83 84 # add for cross_platfrom_build temporarily, shall be removed after external_deps is supported 85 if (is_arkui_x) { 86 configs = [ "$ark_ets_path:ark_jsruntime_public_config" ] 87 deps += [ "$ark_ets_path:libark_jsruntime_static" ] 88 } else { 89 external_deps += [ "ets_runtime:libark_jsruntime" ] 90 } 91 92 if (is_mingw || is_mac || is_linux) { 93 deps += [ 94 "//third_party/icu/icu4c:shared_icui18n", 95 "//third_party/icu/icu4c:shared_icuuc", 96 ] 97 } 98 99 if (product_name != "ohos-sdk") { 100 if (napi_enable_container_scope) { 101 if (is_arkui_x) { 102 deps += [ "//foundation/arkui/napi:ace_container_scope_static" ] 103 } else { 104 deps += [ "//foundation/arkui/napi:ace_container_scope" ] 105 } 106 defines += [ "ENABLE_CONTAINER_SCOPE" ] 107 } 108 } 109 110 cflags_cc = [ "-Wno-missing-braces" ] 111 if (!is_mingw && !is_mac && !is_linux) { 112 external_deps += hilog_deps 113 if (is_ohos_standard_system) { 114 defines += [ "OHOS_PLATFORM" ] 115 defines += [ "ENABLE_HITRACE" ] 116 external_deps += [ 117 "hitrace:hitrace_meter", 118 "init:libbegetutil", 119 ] 120 } 121 } 122 123 part_name = "napi" 124 subsystem_name = "arkui" 125 } 126} 127 128foreach(item, ace_platforms) { 129 if (item.name == "ohos" || is_arkui_x) { 130 engine_config = item.config 131 support_engines = engine_config.js_engines 132 foreach(engine, support_engines) { 133 if (engine.engine_name == "ark") { 134 ace_napi_impl("ace_napi_impl_ark") { 135 engine_defines = engine.engine_defines 136 } 137 } 138 } 139 } 140} 141