1# Copyright (c) 2021-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.
13
14import("//build/ohos.gni")
15import("os_account_service.gni")
16
17ohos_prebuilt_etc("accountmgr.init") {
18  source = "accountmgr.cfg"
19  relative_install_dir = "init"
20  subsystem_name = "account"
21  part_name = "os_account"
22}
23
24ohos_prebuilt_etc("osaccount_constraint") {
25  source = "osaccount_constraints.json"
26  relative_install_dir = "account"
27  subsystem_name = "account"
28  part_name = "os_account"
29}
30
31ohos_prebuilt_etc("os_account_config") {
32  source = "os_account_config.json"
33  relative_install_dir = "account"
34  subsystem_name = "account"
35  part_name = "os_account"
36}
37
38ohos_prebuilt_etc("constraints_list_collection") {
39  source = "constraints_list_collection.json"
40  relative_install_dir = "account"
41  subsystem_name = "account"
42  part_name = "os_account"
43}
44
45config("accountmgr_config") {
46  include_dirs = [
47    "./include",
48    "./include/ability_manager_adapter",
49    "./include/appaccount",
50    "./include/osaccount",
51    "${innerkits_path}/include",
52    "${os_account_dfx_path}/hidumper_adapter",
53    "${app_account_interfaces_native_path}/include",
54    "${os_account_dfx_path}/hisysevent_adapter",
55    "${os_account_dfx_path}/hitrace_adapter",
56    "${app_account_innerkits_native_path}/include",
57  ]
58  if (ohos_indep_compiler_enable) {
59    include_dirs += [
60      "${binarys_path}/foundation/bundlemanager/bundle_framework/innerapis/appexecfwk_core/includes/app_control",
61      "${binarys_path}/third_party/jsoncpp/innerapis/jsoncpp/includes",
62      "${binarys_path}/base/useriam/user_auth_framework/innerapis/userauth_client/includes",
63    ]
64  }
65}
66
67config("account_iam_config") {
68  include_dirs = [ "${account_iam_interfaces_native_path}/include" ]
69}
70
71config("domain_account_config") {
72  include_dirs = [
73    "include/domain_account",
74    "${domain_account_framework_path}/include",
75    "${domain_account_interfaces_native_path}/include",
76  ]
77}
78
79config("ability_manager_config") {
80  include_dirs = [
81    "${ability_runtime_path}/interfaces/inner_api/ability_manager/include",
82    "${ability_runtime_path}/ability_base/interfaces/inner_api/want/include",
83    "${ability_runtime_path}/services/abilitymgr/include",
84    "${ability_runtime_path}/services/common/include",
85  ]
86}
87
88config("accountmgr_public_config") {
89  visibility = [ ":*" ]
90
91  include_dirs = [
92    "${services_path}/accountmgr/include",
93    "${services_path}/accountmgr/include/appaccount",
94    "${services_path}/accountmgr/include/osaccount",
95    "${services_path}/accountmgr/include/domain_account",
96  ]
97
98  if (has_user_auth_part) {
99    include_dirs += [ "${services_path}/accountmgr/include/account_iam" ]
100  }
101}
102
103config("bundle_manager_config") {
104  include_dirs =
105      [ "${services_path}/accountmgr/include/bundle_manager_adapter" ]
106}
107
108ability_manager_sources =
109    [ "src/ability_manager_adapter/ability_manager_adapter.cpp" ]
110
111if (has_kv_store_part) {
112  app_account_sources = [
113    "${app_account_innerkits_native_path}/src/app_account_authenticator_callback_proxy.cpp",
114    "${app_account_innerkits_native_path}/src/app_account_authenticator_callback_stub.cpp",
115    "${app_account_innerkits_native_path}/src/app_account_authorization_extension_callback_proxy.cpp",
116    "${app_account_innerkits_native_path}/src/app_account_authorization_extension_callback_service.cpp",
117    "${app_account_innerkits_native_path}/src/app_account_authorization_extension_callback_stub.cpp",
118    "${app_account_innerkits_native_path}/src/app_account_common.cpp",
119    "${app_account_innerkits_native_path}/src/app_account_info.cpp",
120    "${app_account_innerkits_native_path}/src/app_account_subscribe_info.cpp",
121    "src/appaccount/app_account_app_state_observer.cpp",
122    "src/appaccount/app_account_authenticator_callback.cpp",
123    "src/appaccount/app_account_authenticator_manager.cpp",
124    "src/appaccount/app_account_authenticator_proxy.cpp",
125    "src/appaccount/app_account_authenticator_session.cpp",
126    "src/appaccount/app_account_authenticator_session_manager.cpp",
127    "src/appaccount/app_account_authorization_extension_proxy.cpp",
128    "src/appaccount/app_account_check_labels_callback.cpp",
129    "src/appaccount/app_account_check_labels_session.cpp",
130    "src/appaccount/app_account_common_event_observer.cpp",
131    "src/appaccount/app_account_common_event_subscriber.cpp",
132    "src/appaccount/app_account_control_manager.cpp",
133    "src/appaccount/app_account_data_storage.cpp",
134    "src/appaccount/app_account_event_proxy.cpp",
135    "src/appaccount/app_account_manager_service.cpp",
136    "src/appaccount/app_account_stub.cpp",
137    "src/appaccount/app_account_subscribe_death_recipient.cpp",
138    "src/appaccount/app_account_subscribe_manager.cpp",
139    "src/appaccount/inner_app_account_manager.cpp",
140  ]
141}
142
143if (has_user_auth_part && !ohos_indep_compiler_enable) {
144  account_iam_sources = [
145    "src/account_iam/account_iam_callback.cpp",
146    "src/account_iam/account_iam_client_callback_proxy.cpp",
147    "src/account_iam/account_iam_mgr_stub.cpp",
148    "src/account_iam/account_iam_service.cpp",
149    "src/account_iam/inner_account_iam_manager.cpp",
150  ]
151}
152
153bundle_manager_sources = [
154  "src/bundle_manager_adapter/bundle_manager_adapter.cpp",
155  "src/bundle_manager_adapter/bundle_manager_adapter_proxy.cpp",
156  "src/bundle_manager_adapter/bundle_user_manager_adapter_proxy.cpp",
157]
158
159ohos_shared_library("accountmgr") {
160  branch_protector_ret = "pac_ret"
161
162  sanitize = {
163    cfi = true
164    cfi_cross_dso = true
165    debug = false
166    blocklist = "./account_cfi_blocklist.txt"
167  }
168
169  visibility = [ "${os_account_path}/*" ]
170  cflags = [ "-pipe" ]
171  if (!use_clang_coverage) {
172    version_script = "libaccountmgr.map"
173  }
174  cflags_cc = [
175    "-Wdate-time",
176    "-Wformat=2",
177    "-Wfloat-equal",
178    "-Wshadow",
179  ]
180  if (os_account_multiple_active_accounts) {
181    cflags += [ "-DENABLE_MULTIPLE_ACTIVE_ACCOUNTS" ]
182  }
183
184  if (os_account_support_deactivate_main_os_account) {
185    cflags += [ "-DSUPPORT_STOP_MAIN_OS_ACCOUNT" ]
186  }
187
188  if (os_account_distributed_feature) {
189    cflags += [ "-DDISTRIBUTED_FEATURE_ENABLED" ]
190  }
191
192  if (os_account_enable_multiple_os_accounts || use_clang_coverage) {
193    cflags += [ "-DENABLE_MULTIPLE_OS_ACCOUNTS" ]
194  }
195
196  if (os_account_enable_default_admin_name) {
197    cflags += [ "-DENABLE_DEFAULT_ADMIN_NAME" ]
198  }
199
200  if (os_account_enable_account_short_name) {
201    cflags += [ "-DENABLE_ACCOUNT_SHORT_NAME" ]
202  }
203
204  if (os_account_activate_last_logged_in_account) {
205    cflags += [ "-DACTIVATE_LAST_LOGGED_IN_ACCOUNT" ]
206  }
207
208  sources = [
209    "${common_path}/utils/src/account_permission_manager.cpp",
210    "${domain_account_framework_path}/src/domain_account_callback_proxy.cpp",
211    "${domain_account_framework_path}/src/domain_account_callback_service.cpp",
212    "${domain_account_framework_path}/src/domain_account_callback_stub.cpp",
213    "${domain_account_framework_path}/src/domain_account_common.cpp",
214    "${innerkits_native_path}/src/account_info_parcel.cpp",
215    "${os_account_core_path}/src/os_account_event_proxy.cpp",
216    "${os_account_dfx_path}/hidumper_adapter/account_dump_helper.cpp",
217    "${os_account_dfx_path}/hisysevent_adapter/account_hisysevent_adapter.cpp",
218    "${os_account_dfx_path}/hitrace_adapter/hitrace_adapter.cpp",
219  ]
220  sources += account_service_sources
221  sources += ability_manager_sources
222  sources += bundle_manager_sources
223
224  defines = [
225    "ACCOUNT_LOG_TAG = \"AccountMgrService\"",
226    "LOG_DOMAIN = 0xD001B00",
227  ]
228  if (target_cpu == "arm64") {
229    defines += [ "_ARM64_" ]
230  }
231  configs = [
232    ":accountmgr_config",
233    ":bundle_manager_config",
234    ":domain_account_config",
235  ]
236
237  public_configs = [
238    ":accountmgr_public_config",
239    ":domain_account_config",
240  ]
241
242  use_exceptions = true
243
244  deps = [
245    "${common_path}:libaccount_common",
246    "${innerkits_native_path}:libaccountkits",
247    "${os_account_innerkits_native_path}:os_account_innerkits",
248  ]
249
250  external_deps = [
251    "ability_base:base",
252    "ability_base:want",
253    "ability_runtime:ability_connect_callback_stub",
254    "ability_runtime:app_manager",
255    "ability_runtime:wantagent_innerkits",
256    "access_token:libaccesstoken_sdk",
257    "access_token:libtokenid_sdk",
258    "bundle_framework:appexecfwk_base",
259    "bundle_framework:appexecfwk_core",
260    "c_utils:utils",
261    "hilog:libhilog",
262    "init:libbegetutil",
263    "ipc:ipc_single",
264    "json:nlohmann_json_static",
265    "mbedtls:mbedtls_shared",
266    "safwk:system_ability_fwk",
267    "samgr:samgr_proxy",
268  ]
269  if (has_huks_part) {
270    external_deps += [ "huks:libhukssdk" ]
271    cflags_cc += [ "-DHAS_HUKS_PART" ]
272  }
273
274  if (ohos_indep_compiler_enable) {
275    external_deps += [
276      "ability_base:session_info",
277      "ability_runtime:ability_connect_callback_stub",
278    ]
279  }
280
281  if (has_theme_mar_part) {
282    external_deps += [ "theme_mgr:theme_manager_client" ]
283    cflags_cc += [ "-DHAS_THEME_SERVICE_PART" ]
284  }
285
286  configs += [ ":account_iam_config" ]
287  if (has_user_auth_part && !ohos_indep_compiler_enable) {
288    cflags_cc += [
289      "-DHAS_USER_AUTH_PART",
290      "-DHAS_USER_IDM_PART",
291    ]
292    sources += account_iam_sources
293    external_deps += [
294      "access_token:libtokensetproc_shared",
295      "user_auth_framework:userauth_client",
296    ]
297  }
298
299  if (has_pin_auth_part) {
300    cflags_cc += [ "-DHAS_PIN_AUTH_PART" ]
301    external_deps += [ "pin_auth:pinauth_framework" ]
302  }
303
304  if (has_kv_store_part) {
305    cflags_cc += [
306      "-DHAS_APP_ACCOUNT_PART",
307      "-DHAS_KV_STORE_PART",
308    ]
309    sources += app_account_sources
310    sources += [
311      "src/account_data_storage.cpp",
312      "src/osaccount/os_account_data_storage.cpp",
313      "src/osaccount/os_account_database_operator.cpp",
314    ]
315    external_deps += [ "kv_store:distributeddata_inner" ]
316  }
317
318  if (has_storage_service_part) {
319    cflags += [ "-DHAS_STORAGE_PART" ]
320    external_deps += [ "storage_service:storage_manager_sa_proxy" ]
321  }
322
323  if (build_selinux) {
324    external_deps += [ "selinux_adapter:librestorecon" ]
325    cflags += [ "-DWITH_SELINUX" ]
326  }
327
328  if (has_ces_part) {
329    cflags_cc += [ "-DHAS_CES_PART" ]
330    external_deps += [ "common_event_service:cesfwk_innerkits" ]
331  }
332
333  if (has_hiviewdfx_hisysevent_part) {
334    cflags_cc += [ "-DHAS_HISYSEVENT_PART" ]
335    external_deps += [ "hisysevent:libhisysevent" ]
336  }
337
338  if (use_musl) {
339    cflags_cc += [ "-DUSE_MUSL" ]
340  }
341
342  if (hicollie_enable == true) {
343    external_deps += [ "hicollie:libhicollie" ]
344    cflags_cc += [ "-DHICOLLIE_ENABLE" ]
345  }
346
347  if (security_guard_enabled && !ohos_indep_compiler_enable) {
348    external_deps += [
349      "security_guard:libsg_collect_sdk",
350      "time_service:time_client",
351    ]
352    cflags_cc += [ "-DSECURITY_GUARDE_ENABLE" ]
353  }
354
355  if (has_hiviewdfx_hitrace_part) {
356    external_deps += [ "hitrace:hitrace_meter" ]
357    cflags_cc += [ "-DHAS_HITRACE_PART" ]
358  }
359
360  if (has_asset_part) {
361    external_deps += [ "asset:asset_sdk" ]
362    cflags_cc += [ "-DHAS_ASSET_PART" ]
363  }
364
365  if (has_config_policy_part && !ohos_indep_compiler_enable) {
366    external_deps += [ "config_policy:configpolicy_util" ]
367    cflags_cc += [ "-DHAS_CONFIG_POLICY_PART" ]
368  }
369
370  if (build_variant == "user") {
371    cflags_cc += [ "-DIS_RELEASE_VERSION" ]
372  }
373
374  if (use_clang_coverage) {
375    cflags_cc += [ "-DACCOUNT_COVERAGE_TEST" ]
376  }
377
378  if (!use_clang_coverage) {
379    shlib_type = "sa"
380  }
381  subsystem_name = "account"
382  part_name = "os_account"
383}
384
385group("accountmgr_target") {
386  deps = [
387    ":accountmgr",
388    ":accountmgr.init",
389    ":constraints_list_collection",
390    ":os_account_config",
391    ":osaccount_constraint",
392  ]
393}
394