• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("//arkcompiler/ets_runtime/js_runtime_config.gni")
15import("//build/ohos.gni")
16import("//foundation/arkui/ace_engine/ace_config.gni")
17import("//foundation/arkui/napi/napi.gni")
18
19config("ace_napi_ark_config") {
20  include_dirs = [
21    "//foundation/arkui/napi",
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    configs = [ "//arkcompiler/ets_runtime:ark_jsruntime_public_config" ]
49
50    include_dirs = [ "//foundation/arkui/napi/native_engine/impl/ark" ]
51
52    sources = [
53      "ark_native_deferred.cpp",
54      "ark_native_engine.cpp",
55      "ark_native_engine_impl.cpp",
56      "ark_native_reference.cpp",
57      "native_value/ark_native_array.cpp",
58      "native_value/ark_native_array_buffer.cpp",
59      "native_value/ark_native_big_int.cpp",
60      "native_value/ark_native_boolean.cpp",
61      "native_value/ark_native_data_view.cpp",
62      "native_value/ark_native_date.cpp",
63      "native_value/ark_native_external.cpp",
64      "native_value/ark_native_function.cpp",
65      "native_value/ark_native_number.cpp",
66      "native_value/ark_native_object.cpp",
67      "native_value/ark_native_string.cpp",
68      "native_value/ark_native_typed_array.cpp",
69      "native_value/ark_native_value.cpp",
70    ]
71
72    if (target_cpu == "arm64") {
73      defines += [ "APP_USE_ARM64" ]
74    } else if (target_cpu == "arm") {
75      defines += [ "APP_USE_ARM" ]
76    }
77    if (target_os == "android") {
78      defines += [ "ANDROID_PLATFORM" ]
79    }
80
81    deps = [ "//foundation/arkui/napi:ace_napi" ]
82
83    if (target_os == "ios") {
84      deps += [ "//arkcompiler/ets_runtime:libark_jsruntime_static" ]
85    } else {
86      deps += [ "//arkcompiler/ets_runtime:libark_jsruntime" ]
87    }
88
89    if (is_mingw || is_mac || is_linux) {
90      deps += [
91        "//third_party/icu/icu4c:shared_icui18n",
92        "//third_party/icu/icu4c:shared_icuuc",
93      ]
94    }
95
96    if (product_name != "ohos-sdk") {
97      if (napi_enable_container_scope) {
98        if (target_os == "ios") {
99          deps += [ "//foundation/arkui/napi:ace_container_scope_static" ]
100        } else {
101          deps += [ "//foundation/arkui/napi:ace_container_scope" ]
102        }
103        defines += [ "ENABLE_CONTAINER_SCOPE" ]
104      }
105    }
106
107    cflags_cc = [ "-Wno-missing-braces" ]
108    if (!is_mingw && !is_mac && !is_linux) {
109      external_deps = hilog_deps
110      if (is_standard_system) {
111        defines += [ "OHOS_PLATFORM" ]
112        defines += [ "ENABLE_HITRACE" ]
113        external_deps += [
114          "hitrace_native:hitrace_meter",
115          "init:libbegetutil",
116        ]
117      }
118    }
119
120    part_name = "napi"
121    subsystem_name = "arkui"
122  }
123}
124
125foreach(item, ace_platforms) {
126  if (item.name == "ohos" || is_cross_platform_build) {
127    engine_config = item.config
128    support_engines = engine_config.js_engines
129    foreach(engine, support_engines) {
130      if (engine.engine_name == "ark") {
131        ace_napi_impl("ace_napi_impl_ark") {
132          engine_defines = engine.engine_defines
133        }
134      }
135    }
136  }
137}
138