• 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_dfx_adapter.cpp",
47  "${preferences_native_path}/platform/src/preferences_file_lock.cpp",
48  "${preferences_native_path}/platform/src/preferences_thread.cpp",
49  "${preferences_native_path}/src/base64_helper.cpp",
50  "${preferences_native_path}/src/preferences_base.cpp",
51  "${preferences_native_path}/src/preferences_helper.cpp",
52  "${preferences_native_path}/src/preferences_impl.cpp",
53  "${preferences_native_path}/src/preferences_observer.cpp",
54  "${preferences_native_path}/src/preferences_utils.cpp",
55  "${preferences_native_path}/src/preferences_value.cpp",
56  "${preferences_native_path}/src/preferences_xml_utils.cpp",
57]
58
59if (!is_ohos) {
60  mock_sources = [
61    "${preferences_native_path}/mock/ability_base/zuri/src/uri.cpp",
62    "${preferences_native_path}/mock/ability_runtime/dataobs_manager/src/data_ability_observer_stub.cpp",
63    "${preferences_native_path}/mock/ability_runtime/dataobs_manager/src/dataobs_mgr_client.cpp",
64  ]
65  if (!is_android) {
66    mock_sources +=
67        [ "${preferences_native_path}/mock/c_utils/utils/base/src/refbase.cpp" ]
68  }
69}
70
71if (is_ohos) {
72  ohos_shared_library("native_preferences") {
73    defines = []
74    if (!defined(global_parts_info) ||
75        defined(global_parts_info.distributeddatamgr_arkdata_database_core)) {
76      defines += [ "ARKDATA_DATABASE_CORE_ENABLE" ]
77    }
78    branch_protector_ret = "pac_ret"
79    sanitize = {
80      boundary_sanitize = true
81      ubsan = true
82      cfi = true
83      cfi_cross_dso = true
84      debug = false
85    }
86    cflags_cc = [
87      "-std=c++17",
88      "-stdlib=libc++",
89      "-fvisibility=hidden",
90    ]
91    all_dependent_configs = [ ":native_preferences_public_config" ]
92    sources = base_sources
93    sources += [
94      "${preferences_native_path}/platform/src/preferences_db_adapter.cpp",
95      "${preferences_native_path}/src/preferences_enhance_impl.cpp",
96      "${preferences_native_path}/src/preferences_value_parcel.cpp",
97    ]
98
99    innerapi_tags = [
100      "platformsdk",
101      "sasdk",
102    ]
103
104    configs = [ ":native_preferences_config" ]
105
106    external_deps = [
107      "ability_base:zuri",
108      "ability_runtime:dataobs_manager",
109      "access_token:libaccesstoken_sdk",
110      "bounds_checking_function:libsec_shared",
111      "c_utils:utils",
112      "hilog:libhilog",
113      "hisysevent:libhisysevent",
114      "hitrace:hitrace_meter",
115      "ipc:ipc_core",
116      "libxml2:libxml2",
117    ]
118    public_configs = [ ":native_preferences_public_config" ]
119    subsystem_name = "distributeddatamgr"
120    part_name = "preferences"
121  }
122} else if (is_mingw || is_mac) {
123  ohos_shared_library("native_preferences") {
124    all_dependent_configs = [ ":native_preferences_public_config" ]
125    sources = base_sources
126    sources += mock_sources
127    innerapi_tags = [ "platformsdk" ]
128
129    configs = [ ":native_preferences_config" ]
130
131    configs += [ ":mock_config" ]
132    configs += [ ":adaptor_config" ]
133
134    cflags_cc = [
135      "-std=c++17",
136      "-stdlib=libc++",
137    ]
138    if (is_mac) {
139      buildos = "mac"
140      defines = [
141        "MAC_PLATFORM",
142        "CROSS_PLATFORM",
143      ]
144    } else {
145      buildos = "windows"
146      defines = [
147        "WINDOWS_PLATFORM",
148        "CROSS_PLATFORM",
149      ]
150      ldflags = [ "-lws2_32" ]
151    }
152    deps = [
153      "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_${buildos}",
154    ]
155    external_deps = [
156      "bounds_checking_function:libsec_shared",
157      "libxml2:static_libxml2",
158    ]
159    public_configs = [ ":native_preferences_public_config" ]
160
161    subsystem_name = "distributeddatamgr"
162    part_name = "preferences"
163  }
164} else if (is_android) {
165  ohos_source_set("native_preferences") {
166    all_dependent_configs = [ ":native_preferences_public_config" ]
167    sources = base_sources
168    sources += mock_sources
169
170    defines = [
171      "ANDROID_PLATFORM",
172      "CROSS_PLATFORM",
173    ]
174
175    configs = [ ":native_preferences_config" ]
176    configs += [ ":mock_config" ]
177    cflags_cc = [ "-fvisibility=hidden" ]
178    deps = [
179      "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_android",
180      "//commonlibrary/c_utils/base:utilsbase",
181      "//third_party/bounds_checking_function:libsec_static",
182      "//third_party/libxml2:libxml2",
183    ]
184    public_configs = [ ":native_preferences_public_config" ]
185    subsystem_name = "distributeddatamgr"
186    part_name = "preferences"
187  }
188} else if (is_ios) {
189  ohos_source_set("native_preferences") {
190    all_dependent_configs = [ ":native_preferences_public_config" ]
191    sources = base_sources
192    sources += mock_sources
193    defines = [
194      "IOS_PLATFORM",
195      "CROSS_PLATFORM",
196    ]
197
198    configs = [ ":native_preferences_config" ]
199    configs += [ ":mock_config" ]
200    cflags_cc = [ "-fvisibility=hidden" ]
201    deps = [
202      "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_${target_os}",
203      "//commonlibrary/c_utils/base:utilsbase",
204      "//third_party/bounds_checking_function:libsec_static",
205      "//third_party/libxml2:libxml2",
206    ]
207    public_configs = [ ":native_preferences_public_config" ]
208    subsystem_name = "distributeddatamgr"
209    part_name = "preferences"
210  }
211}
212
213ohos_static_library("native_preferences_static") {
214  sources = base_sources
215  configs = [ ":native_preferences_config" ]
216
217  if (is_mingw || is_mac) {
218    configs += [ ":mock_config" ]
219    configs += [ ":adaptor_config" ]
220
221    sources += mock_sources
222    cflags_cc = [
223      "-std=c++17",
224      "-stdlib=libc++",
225    ]
226    if (is_mac) {
227      buildos = "mac"
228      defines = [
229        "MAC_PLATFORM",
230        "CROSS_PLATFORM",
231      ]
232    } else {
233      buildos = "windows"
234      defines = [
235        "WINDOWS_PLATFORM",
236        "CROSS_PLATFORM",
237      ]
238      ldflags = [ "-lws2_32" ]
239    }
240    deps = [
241      "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_${buildos}",
242    ]
243    external_deps = [
244      "bounds_checking_function:libsec_shared",
245      "libxml2:static_libxml2",
246    ]
247  } else {
248    if (is_ohos) {
249      defines = []
250      if (!defined(global_parts_info) ||
251          defined(global_parts_info.distributeddatamgr_arkdata_database_core)) {
252        defines += [ "ARKDATA_DATABASE_CORE_ENABLE" ]
253      }
254      branch_protector_ret = "pac_ret"
255      sanitize = {
256        boundary_sanitize = true
257        ubsan = true
258        cfi = true
259        cfi_cross_dso = true
260        debug = false
261      }
262      sources += [
263        "${preferences_native_path}/platform/src/preferences_db_adapter.cpp",
264        "${preferences_native_path}/src/preferences_enhance_impl.cpp",
265        "${preferences_native_path}/src/preferences_value_parcel.cpp",
266      ]
267    }
268    external_deps = [
269      "ability_base:zuri",
270      "ability_runtime:dataobs_manager",
271      "access_token:libaccesstoken_sdk",
272      "bounds_checking_function:libsec_shared",
273      "c_utils:utils",
274      "hilog:libhilog",
275      "hisysevent:libhisysevent",
276      "hitrace:hitrace_meter",
277      "ipc:ipc_core",
278      "libxml2:libxml2",
279    ]
280  }
281
282  public_configs = [ ":native_preferences_public_config" ]
283
284  subsystem_name = "distributeddatamgr"
285  part_name = "preferences"
286}
287