• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023 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")
15config("native_preferences_config") {
16  visibility = [ ":*" ]
17  include_dirs = [
18    "include",
19    "${preferences_base_path}/frameworks/common/include",
20    "${preferences_native_path}/include",
21    "${preferences_native_path}/platform/include/",
22  ]
23}
24
25config("mock_config") {
26  include_dirs = [
27    "${preferences_native_path}/mock/ability_runtime/dataobs_manager/include",
28    "${preferences_native_path}/mock/ability_base/zuri/include",
29  ]
30  if (!is_android) {
31    include_dirs +=
32        [ "${preferences_native_path}/mock/c_utils/utils/base/include" ]
33  }
34}
35
36config("native_preferences_public_config") {
37  visibility = [ ":*" ]
38  include_dirs = [ "include" ]
39}
40
41config("adaptor_config") {
42  include_dirs = [ "//commonlibrary/c_utils/base/include" ]
43}
44
45base_sources = [
46  "${preferences_native_path}/platform/src/preferences_file_lock.cpp",
47  "${preferences_native_path}/platform/src/preferences_thread.cpp",
48  "${preferences_native_path}/src/preferences_helper.cpp",
49  "${preferences_native_path}/src/preferences_impl.cpp",
50  "${preferences_native_path}/src/preferences_observer.cpp",
51  "${preferences_native_path}/src/preferences_value.cpp",
52  "${preferences_native_path}/src/preferences_xml_utils.cpp",
53]
54
55if (!is_ohos) {
56  mock_sources = [
57    "${preferences_native_path}/mock/ability_base/zuri/src/uri.cpp",
58    "${preferences_native_path}/mock/ability_runtime/dataobs_manager/src/data_ability_observer_stub.cpp",
59    "${preferences_native_path}/mock/ability_runtime/dataobs_manager/src/dataobs_mgr_client.cpp",
60  ]
61  if (!is_android) {
62    mock_sources +=
63        [ "${preferences_native_path}/mock/c_utils/utils/base/src/refbase.cpp" ]
64  }
65}
66
67if (is_ohos) {
68  ohos_shared_library("native_preferences") {
69    all_dependent_configs = [ ":native_preferences_public_config" ]
70    sources = base_sources
71
72    innerapi_tags = [ "platformsdk" ]
73
74    configs = [ ":native_preferences_config" ]
75
76    cflags_cc = [ "-fvisibility=hidden" ]
77    deps = [ "//third_party/libxml2:libxml2" ]
78    external_deps = [
79      "ability_base:zuri",
80      "ability_runtime:dataobs_manager",
81      "c_utils:utils",
82      "hilog:libhilog",
83      "hitrace:hitrace_meter",
84      "ipc:ipc_core",
85    ]
86    public_configs = [ ":native_preferences_public_config" ]
87    subsystem_name = "distributeddatamgr"
88    part_name = "preferences"
89  }
90} else if (is_mingw || is_mac) {
91  ohos_shared_library("native_preferences") {
92    all_dependent_configs = [ ":native_preferences_public_config" ]
93    sources = base_sources
94    sources += mock_sources
95    innerapi_tags = [ "platformsdk" ]
96
97    configs = [ ":native_preferences_config" ]
98
99    configs += [ ":mock_config" ]
100    configs += [ ":adaptor_config" ]
101
102    cflags_cc = [
103      "-std=c++17",
104      "-stdlib=libc++",
105    ]
106    if (is_mac) {
107      buildos = "mac"
108      defines = [ "MAC_PLATFORM" ]
109    } else {
110      buildos = "windows"
111      defines = [ "WINDOWS_PLATFORM" ]
112      ldflags = [ "-lws2_32" ]
113    }
114    deps = [
115      "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_${buildos}",
116      "//third_party/libxml2:static_libxml2",
117    ]
118    public_configs = [ ":native_preferences_public_config" ]
119
120    subsystem_name = "distributeddatamgr"
121    part_name = "preferences"
122  }
123} else if (is_android) {
124  ohos_source_set("native_preferences") {
125    all_dependent_configs = [ ":native_preferences_public_config" ]
126    sources = base_sources
127    sources += mock_sources
128
129    defines = [ "ANDROID_PLATFORM" ]
130
131    configs = [ ":native_preferences_config" ]
132    configs += [ ":mock_config" ]
133    cflags_cc = [ "-fvisibility=hidden" ]
134    deps = [
135      "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_android",
136      "//commonlibrary/c_utils/base:utilsbase",
137      "//third_party/libxml2:libxml2",
138    ]
139    public_configs = [ ":native_preferences_public_config" ]
140    subsystem_name = "distributeddatamgr"
141    part_name = "preferences"
142  }
143} else if (is_ios) {
144  ohos_source_set("native_preferences") {
145    all_dependent_configs = [ ":native_preferences_public_config" ]
146    sources = base_sources
147    sources += mock_sources
148    defines = [ "IOS_PLATFORM" ]
149
150    configs = [ ":native_preferences_config" ]
151    configs += [ ":mock_config" ]
152    cflags_cc = [ "-fvisibility=hidden" ]
153    deps = [
154      "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_${target_os}",
155      "//commonlibrary/c_utils/base:utilsbase",
156      "//third_party/libxml2:static_libxml2",
157    ]
158    public_configs = [ ":native_preferences_public_config" ]
159    subsystem_name = "distributeddatamgr"
160    part_name = "preferences"
161  }
162}
163
164ohos_static_library("native_preferences_static") {
165  all_dependent_configs = [ ":native_preferences_public_config" ]
166  sources = base_sources
167  configs = [ ":native_preferences_config" ]
168
169  if (is_mingw || is_mac) {
170    configs += [ ":mock_config" ]
171    configs += [ ":adaptor_config" ]
172
173    sources += mock_sources
174    cflags_cc = [
175      "-std=c++17",
176      "-stdlib=libc++",
177    ]
178    if (is_mac) {
179      buildos = "mac"
180      defines = [ "MAC_PLATFORM" ]
181    } else {
182      buildos = "windows"
183      defines = [ "WINDOWS_PLATFORM" ]
184      ldflags = [ "-lws2_32" ]
185    }
186    deps = [
187      "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_${buildos}",
188      "//third_party/libxml2:static_libxml2",
189    ]
190  } else {
191    deps = [ "//third_party/libxml2:libxml2" ]
192    external_deps = [
193      "ability_base:zuri",
194      "ability_runtime:dataobs_manager",
195      "c_utils:utils",
196      "hilog:libhilog",
197      "hitrace:hitrace_meter",
198      "ipc:ipc_core",
199    ]
200  }
201
202  public_configs = [ ":native_preferences_public_config" ]
203
204  subsystem_name = "distributeddatamgr"
205  part_name = "preferences"
206}
207