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    "safwk:system_ability_fwk",
286    "samgr:samgr_proxy",
287    "syscap_codec:syscap_interface_shared",
288    "zlib:shared_libz",
289  ]
290
291  if (bundle_framework_power_mgr_enable) {
292    external_deps += aot_external_deps
293  }
294
295  if (storage_service_enable) {
296    external_deps += [ "storage_service:storage_manager_sa_proxy" ]
297    defines += [ "STORAGE_SERVICE_ENABLE" ]
298  }
299
300  if (window_enable) {
301    external_deps += [ "window_manager:libwsutils" ]
302    defines += [ "WINDOW_ENABLE" ]
303  }
304
305  if (distributed_bundle_framework) {
306    external_deps += [ "distributed_bundle_framework:dbms_fwk" ]
307    defines += [ "DISTRIBUTED_BUNDLE_FRAMEWORK" ]
308  }
309
310  if (bundle_framework_sandbox_app) {
311    sources += sandbox_app
312    defines += [ "BUNDLE_FRAMEWORK_SANDBOX_APP" ]
313
314    if (dlp_permission_enable) {
315      external_deps += [ "dlp_permission_service:libdlp_permission_sdk" ]
316      defines += [ "DLP_PERMISSION_ENABLE" ]
317    }
318  }
319
320  if (ability_runtime_enable) {
321    external_deps += [
322      "ability_runtime:ability_manager",
323      "ability_runtime:app_manager",
324    ]
325    defines += [ "ABILITY_RUNTIME_ENABLE" ]
326  }
327
328  if (account_enable) {
329    external_deps += [ "os_account:os_account_innerkits" ]
330    defines += [ "ACCOUNT_ENABLE" ]
331  }
332
333  if (bundle_framework_free_install) {
334    sources += aging
335    sources += free_install
336    sources += distributed_manager
337    external_deps += [
338      "ability_runtime:ability_manager",
339      "ability_runtime:app_manager",
340      "battery_manager:batterysrv_client",
341      "display_manager:displaymgr",
342      "power_manager:powermgr_client",
343    ]
344    defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
345  }
346
347  if (device_usage_statistics_enabled) {
348    external_deps += [ "device_usage_statistics:usagestatsinner" ]
349    defines += [ "DEVICE_USAGE_STATISTICS_ENABLED" ]
350  }
351
352  if (bundle_framework_power_mgr_enable) {
353    defines += [ "BUNDLE_FRAMEWORK_POWER_MGR_ENABLE" ]
354  }
355
356  if (bundle_framework_default_app) {
357    sources += default_app
358    defines += [ "BUNDLE_FRAMEWORK_DEFAULT_APP" ]
359  }
360
361  if (bundle_framework_quick_fix) {
362    sources += quick_fix
363    defines += [ "BUNDLE_FRAMEWORK_QUICK_FIX" ]
364  }
365
366  if (configpolicy_enable) {
367    external_deps += [ "config_policy:configpolicy_util" ]
368    defines += [ "CONFIG_POLOCY_ENABLE" ]
369  }
370
371  if (global_resmgr_enable) {
372    defines += [ "GLOBAL_RESMGR_ENABLE" ]
373    external_deps += [ "resource_management:global_resmgr" ]
374  }
375
376  if (global_i18n_enable) {
377    defines += [ "GLOBAL_I18_ENABLE" ]
378    external_deps += [ "i18n:intl_util" ]
379  }
380
381  if (hicollie_enable) {
382    external_deps += [ "hicollie:libhicollie" ]
383    defines += [ "HICOLLIE_ENABLE" ]
384  }
385
386  if (hisysevent_enable) {
387    sources += [ "src/inner_event_report.cpp" ]
388    external_deps += [ "hisysevent:libhisysevent" ]
389    defines += [ "HISYSEVENT_ENABLE" ]
390  }
391
392  if (use_pre_bundle_profile) {
393    defines += [ "USE_PRE_BUNDLE_PROFILE" ]
394  }
395
396  if (bundle_framework_overlay_install) {
397    configs += [ ":overlay_installation_config" ]
398    sources += overlay_installation
399    defines += [ "BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION" ]
400  }
401
402  configs += [ ":rdb_config" ]
403  external_deps += [ "relational_store:native_rdb" ]
404  sources += [
405    "src/bundle_data_storage_rdb.cpp",
406    "src/preinstall_data_storage_rdb.cpp",
407    "src/rdb/bms_rdb_open_callback.cpp",
408    "src/rdb/rdb_data_manager.cpp",
409  ]
410
411  if (bundle_framework_app_control) {
412    configs += [ ":app_control_config" ]
413    defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ]
414    sources += app_control
415  }
416
417  if (bundle_framework_bundle_resource) {
418    defines += [ "BUNDLE_FRAMEWORK_BUNDLE_RESOURCE" ]
419    external_deps += [ "ability_base:configuration" ]
420    if (bundle_framework_graphics) {
421      defines += [ "BUNDLE_FRAMEWORK_GRAPHICS" ]
422      external_deps += [
423        "ace_engine:drawable_descriptor",
424        "image_framework:image_native",
425      ]
426    }
427
428    sources += bundle_resource
429  }
430
431  if (build_variant == "root") {
432    defines += [ "QUOTA_PARAM_SET_ENABLE" ]
433  }
434
435  if (verify_abc_enabled) {
436    defines += [ "VERIFY_ABC_ENABLED" ]
437    external_deps += [ "runtime_core:libarkverifier" ]
438  }
439
440  if (check_eldir_enabled) {
441    defines += [ "CHECK_ELDIR_ENABLED" ]
442  }
443
444  if (udmf_enabled) {
445    defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
446    external_deps += [ "udmf:utd_client" ]
447  }
448
449  if (bms_device_info_manager_part_enabled) {
450    external_deps += [
451      "device_info_manager:distributed_device_profile_common",
452      "device_info_manager:distributed_device_profile_sdk",
453    ]
454    defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ]
455  }
456
457  if (app_domain_verify_enabled) {
458    external_deps += [
459      "app_domain_verify:app_domain_verify_common",
460      "app_domain_verify:app_domain_verify_mgr_client",
461    ]
462    defines += [ "APP_DOMAIN_VERIFY_ENABLED" ]
463  }
464
465  if (code_signature_enable) {
466    sources += [ "src/aot/aot_sign_data_cache_mgr.cpp" ]
467    defines += [ "CODE_SIGNATURE_ENABLE" ]
468  }
469
470  if (webview_enable) {
471    external_deps += [ "webview:app_fwk_update_service" ]
472    defines += [ "WEBVIEW_ENABLE" ]
473  }
474
475  subsystem_name = "bundlemanager"
476  part_name = "bundle_framework"
477}
478
479ohos_shared_library("installs") {
480  branch_protector_ret = "pac_ret"
481
482  sanitize = {
483    boundary_sanitize = true
484    cfi = true
485    cfi_cross_dso = true
486    debug = false
487    integer_overflow = true
488    ubsan = true
489  }
490
491  sources = [
492    "src/bundle_extractor.cpp",
493    "src/system_ability_helper.cpp",
494  ]
495
496  use_exceptions = true
497  visibility = [
498    "//base/*",
499    "//foundation/*",
500  ]
501
502  sources += install_daemon_sources
503
504  defines = [ "APP_LOG_TAG = \"BMS\"" ]
505
506  configs = [ ":bundlemgr_common_config" ]
507
508  cflags = [ "-Os" ]
509  cflags_cc = [ "-Os" ]
510
511  if (target_cpu == "arm") {
512    cflags += [ "-DBINDER_IPC_32BIT" ]
513  }
514  deps = [
515    ":parser_common",
516    "${common_path}:libappexecfwk_common",
517  ]
518
519  external_deps = [
520    "access_token:el5_filekey_manager_sdk",
521    "appspawn:hnpapi",
522    "bounds_checking_function:libsec_shared",
523    "eventhandler:libeventhandler",
524    "hilog:libhilog",
525    "hitrace:hitrace_meter",
526    "init:libbegetutil",
527    "ipc:ipc_single",
528    "safwk:system_ability_fwk",
529    "samgr:samgr_proxy",
530    "selinux_adapter:librestorecon",
531    "storage_service:storage_manager_acl",
532  ]
533
534  if (code_signature_enable) {
535    external_deps += [
536      "code_signature:libcode_sign_utils",
537      "ets_runtime:libcompiler_service",
538    ]
539    defines += [ "CODE_SIGNATURE_ENABLE" ]
540  }
541
542  if (code_encryption_enable) {
543    defines += [ "CODE_ENCRYPTION_ENABLE" ]
544  }
545
546  if (configpolicy_enable) {
547    external_deps += [ "config_policy:configpolicy_util" ]
548    defines += [ "CONFIG_POLOCY_ENABLE" ]
549  }
550
551  if (build_selinux) {
552    external_deps += [ "selinux_adapter:libhap_restorecon" ]
553    cflags += [ "-DWITH_SELINUX" ]
554  }
555
556  if (dfx_sigdump_handler_enabled) {
557    external_deps += [ "faultloggerd:dfx_sigdump_handler" ]
558    defines += [ "DFX_SIGDUMP_HANDLER_ENABLE" ]
559  }
560
561  install_enable = true
562  subsystem_name = "bundlemanager"
563  part_name = "bundle_framework"
564}
565
566ohos_prebuilt_etc("installs.cfg") {
567  source = "installs.cfg"
568  relative_install_dir = "init"
569  subsystem_name = "bundlemanager"
570  part_name = "bundle_framework"
571}
572