1# Copyright (c) 2021-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.
13
14import("//build/ohos.gni")
15import("../../appexecfwk.gni")
16import("appexecfwk_bundlemgr.gni")
17
18config("bundlemgr_common_config") {
19  include_dirs = [
20    "include",
21    "include/aot",
22    "include/app_provision_info",
23    "include/app_service_fwk",
24    "include/bundlemgr",
25    "include/bms_extension",
26    "include/bundle_resource",
27    "include/clone",
28    "include/common",
29    "include/default_app",
30    "include/free_install",
31    "include/distributed_manager",
32    "include/driver",
33    "include/extend_resource",
34    "include/uninstall_data_mgr",
35    "include/overlay",
36    "include/quick_fix",
37    "include/sandbox_app",
38    "include/navigation",
39    "include/shared",
40    "include/quick_fix/state/include",
41    "include/utd",
42    "include/verify",
43    "../../interfaces/inner_api/appexecfwk_base/include",
44    "../../interfaces/inner_api/bundlemgr_extension/include",
45  ]
46
47  include_dirs += bundle_mgr_impl_include_dirs
48
49  defines = [
50    "APP_LOG_TAG = \"BMS\"",
51    "LOG_DOMAIN = 0xD001120",
52  ]
53}
54
55config("rdb_config") {
56  include_dirs = [ "include/rdb" ]
57}
58
59config("app_control_config") {
60  include_dirs = [ "include/app_control" ]
61}
62
63config("overlay_installation_config") {
64  include_dirs = [ "include/overlay" ]
65}
66
67bundlemgr_parser_common_config = [ ":bundlemgr_common_config" ]
68
69ohos_source_set("parser_common") {
70  branch_protector_ret = "pac_ret"
71
72  sanitize = {
73    cfi = true
74    cfi_cross_dso = true
75    debug = false
76  }
77
78  sources = [
79    "src/base_extractor.cpp",
80    "src/zip_file.cpp",
81  ]
82
83  public_configs = bundlemgr_parser_common_config
84
85  deps = [
86    "${base_path}:appexecfwk_base",
87    "${common_path}:libappexecfwk_common",
88    "${extension_path}:bundlemgr_extension",
89  ]
90
91  external_deps = [
92    "c_utils:utils",
93    "hilog:libhilog",
94    "zlib:shared_libz",
95  ]
96
97  public_external_deps = [
98    "json:nlohmann_json_static",
99    "zlib:libz",
100  ]
101
102  part_name = "bundle_framework"
103}
104
105ohos_source_set("rpcid_decode") {
106  branch_protector_ret = "pac_ret"
107
108  sanitize = {
109    cfi = true
110    cfi_cross_dso = true
111    debug = false
112  }
113
114  include_dirs = [ "include/rpcid_decode" ]
115
116  sources = [ "src/rpcid_decode/syscap_tool.c" ]
117
118  external_deps = [
119    "c_utils:utils",
120    "hilog:libhilog",
121  ]
122
123  part_name = "bundle_framework"
124}
125
126ohos_source_set("bundle_parser") {
127  branch_protector_ret = "pac_ret"
128
129  sanitize = {
130    cfi = true
131    cfi_cross_dso = true
132    debug = false
133  }
134
135  sources = [
136    "include/bundle_extractor.h",
137    "include/bundle_parser.h",
138    "include/bundle_profile.h",
139    "include/default_permission_profile.h",
140    "include/module_profile.h",
141    "src/bundle_extractor.cpp",
142    "src/bundle_parser.cpp",
143    "src/bundle_profile.cpp",
144    "src/default_permission_profile.cpp",
145    "src/module_profile.cpp",
146    "src/pre_bundle_profile.cpp",
147  ]
148
149  if (bundle_framework_quick_fix) {
150    sources += [
151      "include/quick_fix/patch_extractor.h",
152      "include/quick_fix/patch_parser.h",
153      "include/quick_fix/patch_profile.h",
154      "src/quick_fix/patch_extractor.cpp",
155      "src/quick_fix/patch_parser.cpp",
156      "src/quick_fix/patch_profile.cpp",
157    ]
158  }
159
160  public_configs = bundlemgr_parser_common_config
161  cflags = []
162  if (target_cpu == "arm") {
163    cflags += [ "-DBINDER_IPC_32BIT" ]
164  }
165  deps = [
166    ":parser_common",
167    ":rpcid_decode",
168    "${base_path}:appexecfwk_base",
169    "${common_path}:libappexecfwk_common",
170    "${extension_path}:bundlemgr_extension",
171  ]
172
173  external_deps = [
174    "ability_base:want",
175    "access_token:libaccesstoken_sdk",
176    "c_utils:utils",
177    "hilog:libhilog",
178    "init:libbegetutil",
179    "ipc:ipc_single",
180  ]
181
182  public_external_deps = [
183    "json:nlohmann_json_static",
184    "zlib:libz",
185  ]
186
187  defines = []
188  if (use_pre_bundle_profile) {
189    defines += [ "USE_PRE_BUNDLE_PROFILE" ]
190  }
191
192  if (bundle_framework_overlay_install) {
193    defines += [ "BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION" ]
194  }
195
196  if (is_emulator) {
197    defines += [ "X86_EMULATOR_MODE" ]
198  }
199  part_name = "bundle_framework"
200}
201
202group("bms_target") {
203  deps = [
204    ":installs",
205    ":installs.cfg",
206    ":libbms",
207  ]
208}
209
210ohos_shared_library("libbms") {
211  branch_protector_ret = "pac_ret"
212
213  sanitize = {
214    boundary_sanitize = true
215    cfi = true
216    cfi_cross_dso = true
217    debug = false
218    integer_overflow = true
219    ubsan = true
220  }
221
222  use_exceptions = true
223  visibility = [
224    "//base/*",
225    "//foundation/*",
226  ]
227
228  sources = bundle_mgr_source
229
230  sources += bundle_install_sources
231
232  sources += bundle_mgr_impl_sources
233
234  defines = [
235    "APP_LOG_TAG = \"BMS\"",
236    "LOG_DOMAIN = 0xD001120",
237  ]
238
239  if (is_emulator) {
240    defines += [ "X86_EMULATOR_MODE" ]
241  }
242
243  configs = [ ":bundlemgr_common_config" ]
244  cflags = [
245    "-fvisibility=hidden",
246    "-fdata-sections",
247    "-ffunction-sections",
248    "-Wno-non-c-typedef-for-linkage",
249    "-Os",
250  ]
251
252  cflags_cc = [
253    "-fvisibility-inlines-hidden",
254    "-Wno-non-c-typedef-for-linkage",
255    "-Os",
256  ]
257  if (target_cpu == "arm") {
258    cflags += [ "-DBINDER_IPC_32BIT" ]
259  }
260  deps = [
261    ":bundle_parser",
262    ":parser_common",
263    "${base_path}:appexecfwk_base",
264    "${common_path}:libappexecfwk_common",
265    "${core_path}:appexecfwk_core",
266    "${extension_path}:bundlemgr_extension",
267  ]
268
269  version_script = "libbms.map"
270  external_deps = [
271    "ability_base:want",
272    "ability_runtime:ability_connect_callback_stub",
273    "access_token:el5_filekey_manager_sdk",
274    "access_token:libaccesstoken_sdk",
275    "access_token:libprivacy_sdk",
276    "access_token:libtokenid_sdk",
277    "appverify:libhapverify",
278    "common_event_service:cesfwk_innerkits",
279    "eventhandler:libeventhandler",
280    "ffrt:libffrt",
281    "hilog:libhilog",
282    "hitrace:hitrace_meter",
283    "init:libbegetutil",
284    "ipc:ipc_single",
285    "os_account:libaccountkits",
286    "safwk:system_ability_fwk",
287    "samgr:samgr_proxy",
288    "syscap_codec:syscap_interface_shared",
289    "zlib:shared_libz",
290  ]
291
292  if (bundle_framework_power_mgr_enable) {
293    external_deps += aot_external_deps
294  }
295
296  if (storage_service_enable) {
297    external_deps += [ "storage_service:storage_manager_sa_proxy" ]
298    defines += [ "STORAGE_SERVICE_ENABLE" ]
299  }
300
301  if (window_enable) {
302    external_deps += [ "window_manager:libwsutils" ]
303    defines += [ "WINDOW_ENABLE" ]
304  }
305
306  if (distributed_bundle_framework) {
307    external_deps += [ "distributed_bundle_framework:dbms_fwk" ]
308    defines += [ "DISTRIBUTED_BUNDLE_FRAMEWORK" ]
309  }
310
311  if (bundle_framework_sandbox_app) {
312    sources += sandbox_app
313    defines += [ "BUNDLE_FRAMEWORK_SANDBOX_APP" ]
314
315    if (dlp_permission_enable) {
316      external_deps += [ "dlp_permission_service:libdlp_permission_sdk" ]
317      defines += [ "DLP_PERMISSION_ENABLE" ]
318    }
319  }
320
321  if (ability_runtime_enable) {
322    external_deps += [
323      "ability_runtime:ability_manager",
324      "ability_runtime:app_manager",
325    ]
326    defines += [ "ABILITY_RUNTIME_ENABLE" ]
327  }
328
329  if (account_enable) {
330    external_deps += [ "os_account:os_account_innerkits" ]
331    defines += [ "ACCOUNT_ENABLE" ]
332  }
333
334  if (bundle_framework_free_install) {
335    sources += aging
336    sources += free_install
337    sources += distributed_manager
338    external_deps += [
339      "ability_runtime:ability_manager",
340      "ability_runtime:app_manager",
341      "battery_manager:batterysrv_client",
342      "display_manager:displaymgr",
343      "power_manager:powermgr_client",
344    ]
345    defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
346  }
347
348  if (device_usage_statistics_enabled) {
349    external_deps += [ "device_usage_statistics:usagestatsinner" ]
350    defines += [ "DEVICE_USAGE_STATISTICS_ENABLED" ]
351  }
352
353  if (bundle_framework_power_mgr_enable) {
354    defines += [ "BUNDLE_FRAMEWORK_POWER_MGR_ENABLE" ]
355  }
356
357  if (bundle_framework_default_app) {
358    sources += default_app
359    defines += [ "BUNDLE_FRAMEWORK_DEFAULT_APP" ]
360  }
361
362  if (bundle_framework_quick_fix) {
363    sources += quick_fix
364    defines += [ "BUNDLE_FRAMEWORK_QUICK_FIX" ]
365  }
366
367  if (configpolicy_enable) {
368    external_deps += [ "config_policy:configpolicy_util" ]
369    defines += [ "CONFIG_POLOCY_ENABLE" ]
370  }
371
372  if (global_resmgr_enable) {
373    defines += [ "GLOBAL_RESMGR_ENABLE" ]
374    external_deps += [ "resource_management:global_resmgr" ]
375  }
376
377  if (global_i18n_enable) {
378    defines += [ "GLOBAL_I18_ENABLE" ]
379    external_deps += [ "i18n:intl_util" ]
380  }
381
382  if (hicollie_enable) {
383    external_deps += [ "hicollie:libhicollie" ]
384    defines += [ "HICOLLIE_ENABLE" ]
385  }
386
387  if (hisysevent_enable) {
388    sources += [ "src/inner_event_report.cpp" ]
389    external_deps += [ "hisysevent:libhisysevent" ]
390    defines += [ "HISYSEVENT_ENABLE" ]
391  }
392
393  if (use_pre_bundle_profile) {
394    defines += [ "USE_PRE_BUNDLE_PROFILE" ]
395  }
396
397  if (bundle_framework_overlay_install) {
398    configs += [ ":overlay_installation_config" ]
399    sources += overlay_installation
400    defines += [ "BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION" ]
401  }
402
403  configs += [ ":rdb_config" ]
404  external_deps += [ "relational_store:native_rdb" ]
405  sources += [
406    "src/bundle_data_storage_rdb.cpp",
407    "src/preinstall_data_storage_rdb.cpp",
408    "src/rdb/bms_rdb_open_callback.cpp",
409    "src/rdb/rdb_data_manager.cpp",
410  ]
411
412  if (bundle_framework_app_control) {
413    configs += [ ":app_control_config" ]
414    defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ]
415    sources += app_control
416  }
417
418  if (bundle_framework_bundle_resource) {
419    defines += [ "BUNDLE_FRAMEWORK_BUNDLE_RESOURCE" ]
420    external_deps += [ "ability_base:configuration" ]
421    if (bundle_framework_graphics) {
422      defines += [ "BUNDLE_FRAMEWORK_GRAPHICS" ]
423      external_deps += [
424        "ace_engine:drawable_descriptor",
425        "image_framework:image_native",
426      ]
427    }
428
429    sources += bundle_resource
430  }
431
432  if (build_variant == "root") {
433    defines += [ "QUOTA_PARAM_SET_ENABLE" ]
434  }
435
436  if (verify_abc_enabled) {
437    defines += [ "VERIFY_ABC_ENABLED" ]
438    external_deps += [ "runtime_core:libarkverifier" ]
439  }
440
441  if (check_eldir_enabled) {
442    defines += [ "CHECK_ELDIR_ENABLED" ]
443  }
444
445  if (udmf_enabled) {
446    defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
447    external_deps += [ "udmf:utd_client" ]
448  }
449
450  if (bms_device_info_manager_part_enabled) {
451    external_deps += [
452      "device_info_manager:distributed_device_profile_common",
453      "device_info_manager:distributed_device_profile_sdk",
454    ]
455    defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ]
456  }
457
458  if (app_domain_verify_enabled) {
459    external_deps += [
460      "app_domain_verify:app_domain_verify_common",
461      "app_domain_verify:app_domain_verify_mgr_client",
462    ]
463    defines += [ "APP_DOMAIN_VERIFY_ENABLED" ]
464  }
465
466  if (code_signature_enable) {
467    sources += [ "src/aot/aot_sign_data_cache_mgr.cpp" ]
468    defines += [ "CODE_SIGNATURE_ENABLE" ]
469  }
470
471  if (webview_enable) {
472    external_deps += [ "webview:app_fwk_update_service" ]
473    defines += [ "WEBVIEW_ENABLE" ]
474  }
475
476  subsystem_name = "bundlemanager"
477  part_name = "bundle_framework"
478}
479
480ohos_shared_library("installs") {
481  branch_protector_ret = "pac_ret"
482
483  sanitize = {
484    boundary_sanitize = true
485    cfi = true
486    cfi_cross_dso = true
487    debug = false
488    integer_overflow = true
489    ubsan = true
490  }
491
492  sources = [
493    "src/bundle_extractor.cpp",
494    "src/system_ability_helper.cpp",
495  ]
496
497  use_exceptions = true
498  visibility = [
499    "//base/*",
500    "//foundation/*",
501  ]
502
503  sources += install_daemon_sources
504
505  defines = [ "APP_LOG_TAG = \"BMS\"" ]
506
507  configs = [ ":bundlemgr_common_config" ]
508
509  cflags = [ "-Os" ]
510  cflags_cc = [ "-Os" ]
511
512  if (target_cpu == "arm") {
513    cflags += [ "-DBINDER_IPC_32BIT" ]
514  }
515  deps = [
516    ":parser_common",
517    "${common_path}:libappexecfwk_common",
518  ]
519
520  external_deps = [
521    "access_token:el5_filekey_manager_sdk",
522    "appspawn:hnpapi",
523    "bounds_checking_function:libsec_shared",
524    "eventhandler:libeventhandler",
525    "ffrt:libffrt",
526    "hilog:libhilog",
527    "hitrace:hitrace_meter",
528    "init:libbegetutil",
529    "ipc:ipc_single",
530    "safwk:system_ability_fwk",
531    "samgr:samgr_proxy",
532    "storage_service:storage_manager_acl",
533  ]
534
535  if (code_signature_enable) {
536    external_deps += [
537      "code_signature:libcode_sign_utils",
538      "ets_runtime:libcompiler_service",
539    ]
540    defines += [ "CODE_SIGNATURE_ENABLE" ]
541  }
542
543  if (code_encryption_enable) {
544    defines += [ "CODE_ENCRYPTION_ENABLE" ]
545  }
546
547  if (configpolicy_enable) {
548    external_deps += [ "config_policy:configpolicy_util" ]
549    defines += [ "CONFIG_POLOCY_ENABLE" ]
550  }
551
552  if (build_selinux) {
553    external_deps += [ "selinux_adapter:libhap_restorecon" ]
554    cflags += [ "-DWITH_SELINUX" ]
555  }
556
557  if (dfx_sigdump_handler_enabled) {
558    external_deps += [ "faultloggerd:dfx_sigdump_handler" ]
559    defines += [ "DFX_SIGDUMP_HANDLER_ENABLE" ]
560  }
561
562  install_enable = true
563  subsystem_name = "bundlemanager"
564  part_name = "bundle_framework"
565}
566
567ohos_prebuilt_etc("installs.cfg") {
568  source = "installs.cfg"
569  relative_install_dir = "init"
570  subsystem_name = "bundlemanager"
571  part_name = "bundle_framework"
572}
573