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("ndk_preferences_config") {
17  visibility = [ ":*" ]
18  include_dirs = [
19    "include",
20    "${preferences_base_path}/frameworks/common/include",
21    "${preferences_base_path}/frameworks/ndk/include",
22    "${preferences_native_path}/include",
23    "${preferences_native_path}/platform/include/",
24  ]
25}
26
27config("ndk_preferences_public_config") {
28  visibility = [ ":*" ]
29  include_dirs = [ "include" ]
30}
31
32if (is_ohos) {
33  base_sources = [
34    "${preferences_ndk_path}/src/convertor_error_code.cpp",
35    "${preferences_ndk_path}/src/oh_preferences.cpp",
36    "${preferences_ndk_path}/src/oh_preferences_option.cpp",
37    "${preferences_ndk_path}/src/oh_preferences_value.cpp",
38  ]
39  ohos_shared_library("libohpreferences") {
40    branch_protector_ret = "pac_ret"
41    sanitize = {
42      cfi = true
43      cfi_cross_dso = true
44      debug = false
45    }
46    cflags_cc = [
47      "-std=c++17",
48      "-stdlib=libc++",
49    ]
50    deps =
51        [ "${preferences_base_path}/interfaces/inner_api:native_preferences" ]
52
53    sources = base_sources
54
55    defines = [ "API_EXPORT=__attribute__((visibility (\"default\")))" ]
56
57    configs = [ ":ndk_preferences_config" ]
58
59    external_deps = [
60      "ability_runtime:app_context",
61      "c_utils:utils",
62      "hilog:libhilog",
63    ]
64    public_configs = [ ":ndk_preferences_public_config" ]
65    relative_install_dir = "ndk"
66    part_name = "preferences"
67    output_name = "ohpreferences"
68    subsystem_name = "distributeddatamgr"
69    output_extension = "so"
70  }
71}
72