• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
14if (!defined(ark_standalone_build)) {
15  ark_standalone_build = false
16}
17
18if (ark_standalone_build) {
19  import("$build_root/ark.gni")
20  use_clang_coverage = false
21  build_ohos_sdk = false
22} else {
23  import("//build/ohos.gni")
24}
25
26config("ark_interop_config") {
27  include_dirs = [ "../../.." ]
28  cflags = [
29    "-std=c++17",
30    "-Wno-gnu-zero-variadic-macro-arguments",
31    "-fvisibility-inlines-hidden",
32    "-fvisibility=hidden",
33    "-fno-exceptions",
34    "-fno-rtti",
35    "-fmerge-all-constants",
36    "-ffunction-sections",
37    "-Wno-unused-private-field",
38  ]
39  if (current_os == "ohos") {
40    cflags += [ "-fPIC" ]
41    defines = [
42      "__LINUX__",
43      "__OHOS__=1",
44    ]
45  } else if (current_os == "linux") {
46    defines = [ "__LINUX__" ]
47  } else if (current_os == "mingw") {
48    defines = [ "__WINDOWS__" ]
49  }
50}
51
52ohos_source_set("cj_envsetup") {
53  part_name = "napi"
54  subsystem_name = "arkui"
55
56  configs = [ ":ark_interop_config" ]
57  sources = [ "cj_envsetup.cpp" ]
58}
59
60ohos_shared_library("ark_interop") {
61  part_name = "napi"
62  subsystem_name = "arkui"
63  innerapi_tags = [ "platformsdk" ]
64
65  public_configs = [ ":ark_interop_config" ]
66
67  sources = [
68    "ark_interop_async.cpp",
69    "ark_interop_bigint.cpp",
70    "ark_interop_engine.cpp",
71    "ark_interop_global.cpp",
72    "ark_interop_hitrace.cpp",
73    "ark_interop_module.cpp",
74    "ark_interop_napi.cpp",
75    "ark_interop_object.cpp",
76    "ark_interop_scope.cpp",
77    "ark_interop_string.cpp",
78    "ark_interop_symbol.cpp",
79  ]
80
81  deps = [
82    ":cj_envsetup",
83    "../../../..:ace_napi",
84  ]
85
86  external_deps = [ "ets_runtime:libark_jsruntime" ]
87
88  if (!ark_standalone_build) {
89    external_deps += [ "hilog:libhilog" ]
90  }
91
92  if (!is_mingw && !is_mac && !is_linux && !is_arkui_x && is_standard_system) {
93    external_deps += [ "c_utils:utils" ]
94
95    # macro in runtime_core in full repo will effect build napi
96    if (ohos_indep_compiler_enable) {
97      external_deps += [ "runtime_core:libarkbase_static" ]
98    }
99  }
100
101  defines = [
102    "DEBUG_JS",
103    "ENABLE_PROFILE",
104  ]
105
106  if (use_clang_coverage) {
107    defines += [ "CLANG_COVERAGE" ]
108  }
109
110  if (is_arkui_x) {
111    deps += [
112      "//third_party/bounds_checking_function:libsec_static",
113      "//third_party/libuv:uv",
114    ]
115  } else {
116    external_deps += [
117      "bounds_checking_function:libsec_static",
118      "libuv:uv",
119    ]
120  }
121
122  if (build_ohos_sdk) {
123    defines += [
124      "NO_HITRACE",
125      "NO_CONTAINER",
126    ]
127  } else {
128    if (!ark_standalone_build) {
129      external_deps += [
130        "eventhandler:libeventhandler",
131        "hitrace:hitrace_meter",
132      ]
133    }
134  }
135}
136
137ohos_shared_library("cjLibLoader") {
138  part_name = "napi"
139  subsystem_name = "arkui"
140  relative_install_dir = "module"
141
142  configs = [ ":ark_interop_config" ]
143
144  defines = []
145  if (current_cpu == "arm64") {
146    defines += [ "USE_LIBS_ARM64" ]
147  } else if (current_cpu == "arm") {
148    defines += [ "USE_LIBS_ARM" ]
149  } else if (current_cpu == "x86_64") {
150    defines += [ "USE_LIBS_x86_64" ]
151  } else {
152    print("unsupported cpu ${current_cpu}")
153  }
154
155  sources = [ "ark_interop_loader.cpp" ]
156  if (!ark_standalone_build) {
157    external_deps = [ "hilog:libhilog" ]
158  }
159
160  deps = [
161    ":cj_envsetup",
162    "../../../..:ace_napi",
163  ]
164}
165