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