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.
13import("//build/ohos.gni")
14import("//foundation/distributeddatamgr/preferences/preferences.gni")
15
16config("common_public_config") {
17  visibility = [ ":*" ]
18  include_dirs = [ "include" ]
19}
20
21config("common_config") {
22  visibility = [ ":*" ]
23  include_dirs = [
24    "include",
25    "${preferences_base_path}/frameworks/common/include",
26  ]
27}
28
29if (is_ohos) {
30  ohos_shared_library("preferences_jscommon") {
31    branch_protector_ret = "pac_ret"
32    sanitize = {
33      boundary_sanitize = true
34      ubsan = true
35      cfi = true
36      cfi_cross_dso = true
37      debug = false
38    }
39
40    cflags_cc = [
41      "-std=c++17",
42      "-stdlib=libc++",
43    ]
44
45    sources = [
46      "${preferences_napi_path}/common/src/js_ability.cpp",
47      "${preferences_napi_path}/common/src/js_common_utils.cpp",
48      "${preferences_napi_path}/common/src/js_observer.cpp",
49      "${preferences_napi_path}/common/src/js_sendable_utils.cpp",
50      "${preferences_napi_path}/common/src/napi_async_call.cpp",
51      "${preferences_napi_path}/common/src/napi_preferences_error.cpp",
52      "${preferences_napi_path}/common/src/napi_preferences_observer.cpp",
53      "${preferences_napi_path}/common/src/uv_queue.cpp",
54    ]
55    configs = [ ":common_config" ]
56    public_configs = [ ":common_public_config" ]
57    deps =
58        [ "${preferences_base_path}/interfaces/inner_api:native_preferences" ]
59    version_script = "libcommon.map"
60    external_deps = [
61      "ability_runtime:abilitykit_native",
62      "ability_runtime:napi_base_context",
63      "bounds_checking_function:libsec_shared",
64      "hilog:libhilog",
65      "napi:ace_napi",
66    ]
67
68    subsystem_name = "distributeddatamgr"
69    part_name = "preferences"
70  }
71}
72