1# Copyright (c) 2024 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")
15
16config("ark_interop_config") {
17  include_dirs = [ "../../.." ]
18  cflags = [
19    "-std=c++17",
20    "-Wno-gnu-zero-variadic-macro-arguments",
21    "-fvisibility-inlines-hidden",
22    "-fvisibility=hidden",
23    "-fno-exceptions",
24    "-fno-rtti",
25    "-fmerge-all-constants",
26    "-ffunction-sections",
27    "-Wno-unused-private-field",
28  ]
29  if (current_os == "ohos") {
30    cflags += [ "-fPIC" ]
31    defines = [
32      "__LINUX__",
33      "__OHOS__=1",
34    ]
35  } else if (current_os == "linux") {
36    defines = [ "__LINUX__" ]
37  } else if (current_os == "mingw") {
38    defines = [ "__WINDOWS__" ]
39  }
40}
41
42ohos_source_set("cj_envsetup") {
43  part_name = "napi"
44  subsystem_name = "arkui"
45
46  configs = [ ":ark_interop_config" ]
47  sources = [ "cj_envsetup.cpp" ]
48}
49
50ohos_shared_library("ark_interop") {
51  part_name = "napi"
52  subsystem_name = "arkui"
53  innerapi_tags = [ "platformsdk" ]
54
55  public_configs = [ ":ark_interop_config" ]
56
57  sources = [
58    "ark_interop_async.cpp",
59    "ark_interop_bigint.cpp",
60    "ark_interop_engine.cpp",
61    "ark_interop_global.cpp",
62    "ark_interop_hitrace.cpp",
63    "ark_interop_module.cpp",
64    "ark_interop_napi.cpp",
65    "ark_interop_object.cpp",
66    "ark_interop_scope.cpp",
67    "ark_interop_string.cpp",
68    "ark_interop_symbol.cpp",
69  ]
70
71  deps = [
72    ":cj_envsetup",
73    "../../../..:ace_napi",
74  ]
75
76  external_deps = [
77    "ets_runtime:libark_jsruntime",
78    "hilog:libhilog",
79  ]
80
81  defines = [
82    "DEBUG_JS",
83    "ENABLE_PROFILE",
84  ]
85
86  if (use_clang_coverage) {
87    defines += [ "CLANG_COVERAGE" ]
88  }
89
90  if (is_arkui_x) {
91    deps += [
92      "//third_party/bounds_checking_function:libsec_static",
93      "//third_party/libuv:uv",
94    ]
95  } else {
96    external_deps += [
97      "bounds_checking_function:libsec_static",
98      "libuv:uv",
99    ]
100  }
101
102  if (build_ohos_sdk) {
103    defines += [
104      "NO_HITRACE",
105      "NO_CONTAINER",
106    ]
107  } else {
108    external_deps += [
109      "eventhandler:libeventhandler",
110      "hitrace:hitrace_meter",
111    ]
112  }
113}
114
115ohos_shared_library("ark_interop_loader") {
116  part_name = "napi"
117  subsystem_name = "arkui"
118  relative_install_dir = "module"
119
120  configs = [ ":ark_interop_config" ]
121
122  sources = [ "ark_interop_loader.cpp" ]
123
124  external_deps = [ "hilog:libhilog" ]
125
126  deps = [
127    ":cj_envsetup",
128    "../../../..:ace_napi",
129  ]
130}
131