• 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("//build/ohos.gni")
15import("//foundation/arkui/ace_engine/ace_config.gni")
16import("napi.gni")
17
18config("ace_napi_config") {
19  include_dirs = [
20    ".",
21    "interfaces/inner_api",
22    "interfaces/kits",
23    "native_engine",
24    "native_engine/impl/ark",
25    "//third_party/libuv/include",
26    "//third_party/node/src",
27  ]
28  defines = []
29  cflags_cc = []
30  if (is_mingw || is_mac || is_linux) {
31    defines += [ "PREVIEW" ]
32  }
33
34  if (current_os == "ohos" && current_cpu == "x86_64") {
35    defines += [ "SIMULATOR" ]
36  }
37  if (is_ohos) {
38    defines += [ "OHOS_PLATFORM" ]
39  } else if (is_mingw) {
40    defines += [ "WINDOWS_PLATFORM" ]
41    cflags_cc += [ "-std=c++17" ]
42  } else if (is_mac) {
43    defines += [ "MAC_PLATFORM" ]
44  } else if (is_linux) {
45    defines += [ "LINUX_PLATFORM" ]
46    cflags_cc += [ "-std=c++17" ]
47  } else if (is_arkui_x && target_os == "ios") {
48    defines += [ "IOS_PLATFORM" ]
49    include_dirs += [ "//arkcompiler/ets_runtime" ]
50  } else if (is_arkui_x && target_os == "android") {
51    defines += [ "ANDROID_PLATFORM" ]
52    include_dirs += [ "//arkcompiler/ets_runtime" ]
53  }
54}
55
56config("module_manager_config") {
57  include_dirs = [ "module_manager" ]
58}
59
60ohos_source_set("ace_napi_static") {
61  defines = []
62  public_configs = [ ":ace_napi_config" ]
63  deps = []
64  external_deps = []
65
66  sources = napi_sources
67
68  if (current_cpu == "arm64") {
69    defines += [ "_ARM64_" ]
70  }
71  if (is_arkui_x) {
72    if (target_os == "android") {
73      libs = [ "log" ]
74    }
75  } else if (!is_mingw && !is_mac && !is_linux && is_ohos_standard_system) {
76    external_deps += [
77      "hilog:libhilog",
78      "hitrace:hitrace_meter",
79      "hitrace:libhitracechain",
80      "init:libbegetutil",
81    ]
82    defines += [ "ENABLE_HITRACE" ]
83  }
84
85  configs = [ "//third_party/icu/icu4c:icu_config" ]
86
87  # Use static libuv and icu for cross build
88  if (is_arkui_x) {
89    deps += [
90      "${ets_runtime_path}:libark_jsruntime_static",
91      "//third_party/bounds_checking_function:libsec_static",
92      "//third_party/icu/icu4c:static_icui18n",
93      "//third_party/icu/icu4c:static_icuuc",
94      "//third_party/libuv:uv_static",
95    ]
96    configs += [ "${ets_runtime_path}:ark_jsruntime_public_config" ]
97  } else {
98    deps += [
99      "//third_party/icu/icu4c:shared_icui18n",
100      "//third_party/icu/icu4c:shared_icuuc",
101      "//third_party/libuv:uv",
102    ]
103    external_deps += [ "ets_runtime:libark_jsruntime" ]
104  }
105
106  cflags_cc = [ "-Wno-missing-braces" ]
107
108  subsystem_name = "arkui"
109  part_name = "napi"
110}
111
112if (is_arkui_x) {
113  ohos_source_set("ace_napi") {
114    deps = [ ":ace_napi_static" ]
115    public_configs = [ ":ace_napi_config" ]
116    subsystem_name = "arkui"
117    part_name = "napi"
118  }
119} else {
120  ohos_shared_library("ace_napi") {
121    deps = [
122      ":ace_napi_static",
123      "//third_party/bounds_checking_function:libsec_shared",
124    ]
125    public_configs = [
126      ":ace_napi_config",
127      ":module_manager_config",
128    ]
129    public_deps = [ "//third_party/libuv:uv" ]
130
131    subsystem_name = "arkui"
132    innerapi_tags = [ "platformsdk" ]
133    part_name = "napi"
134  }
135}
136
137config("container_scope_config") {
138  visibility = [ ":*" ]
139  include_dirs = [ "$ace_root/frameworks" ]
140}
141
142ohos_shared_library("ace_container_scope") {
143  public_configs = [ ":container_scope_config" ]
144
145  configs = [ "$ace_root:ace_config" ]
146
147  sources = [ "$ace_root/frameworks/core/common/container_scope.cpp" ]
148
149  subsystem_name = "arkui"
150  innerapi_tags = [ "platformsdk_indirect" ]
151  part_name = "napi"
152}
153
154ohos_source_set("ace_container_scope_static") {
155  public_configs = [ ":container_scope_config" ]
156
157  configs = [ "$ace_root:ace_config" ]
158
159  sources = [ "$ace_root/frameworks/core/common/container_scope.cpp" ]
160}
161
162group("napi_packages") {
163  deps = [ ":ace_napi" ]
164}
165
166ohos_ndk_library("libnapi_ndk") {
167  ndk_description_file = "./libnapi.ndk.json"
168  min_compact_version = "1"
169  output_name = "ace_napi"
170}
171
172ohos_ndk_headers("napi_header") {
173  dest_dir = "$ndk_headers_out_dir/napi"
174  sources = [
175    "interfaces/kits/napi/common.h",
176    "interfaces/kits/napi/native_api.h",
177  ]
178}
179
180group("napi_packages_ndk") {
181  deps = [ ":libnapi_ndk" ]
182}
183
184if (!build_ohos_ndk && !is_arkui_x) {
185  group("napi_packages_test") {
186    testonly = true
187
188    deps = [
189      "sample/native_module_calc:calc",
190      "sample/native_module_calc:number",
191      "sample/native_module_callback:callback",
192      "sample/native_module_demo:demo",
193      "sample/native_module_netserver:netserver",
194      "sample/native_module_storage:storage",
195      "test/fuzztest:fuzztest",
196      "test/unittest:unittest",
197    ]
198  }
199}
200