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("//build/ohos_var.gni")
16import("../var.gni")
17
18config("distributed_store_config") {
19  visibility = [ ":*" ]
20  include_dirs =
21      [ "//foundation/systemabilitymgr/samgr/services/samgr/native/include" ]
22}
23
24config("sam_config") {
25  # header file path
26  include_dirs = [
27    "//foundation/systemabilitymgr/samgr/services/samgr/native/include",
28    "//foundation/systemabilitymgr/samgr/services/samgr/native/include/collect",
29    "//foundation/systemabilitymgr/samgr/services/dfx/include",
30    "//foundation/systemabilitymgr/samgr/utils/native/include",
31    "//foundation/systemabilitymgr/samgr/services/lsamgr/include",
32    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/common/include",
33    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include",
34  ]
35}
36
37ohos_executable("samgr") {
38  sanitize = {
39    cfi = true
40    cfi_cross_dso = true
41    debug = false
42    cfi_no_nvcall = true
43    blocklist = "../../../cfi_blocklist.txt"
44  }
45  branch_protector_ret = "pac_ret"
46
47  install_enable = true
48  sources = [
49    "//foundation/systemabilitymgr/samgr/frameworks/native/source/system_ability_load_callback_stub.cpp",
50    "//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
51    "//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_ability_manager_proxy.cpp",
52    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/ability_death_recipient.cpp",
53    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/collect/device_param_collect.cpp",
54    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/collect/device_status_collect_manager.cpp",
55    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/collect/device_timed_collect.cpp",
56    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/collect/icollect_plugin.cpp",
57    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/collect/ref_count_collect.cpp",
58    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/ffrt_handler.cpp",
59    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/main.cpp",
60    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/memory_guard.cpp",
61    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/rpc_callback_imp.cpp",
62    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/samgr_time_handler.cpp",
63    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/schedule/system_ability_event_handler.cpp",
64    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/schedule/system_ability_state_machine.cpp",
65    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/schedule/system_ability_state_scheduler.cpp",
66    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/system_ability_load_callback_proxy.cpp",
67    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/system_ability_manager.cpp",
68    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/system_ability_manager_dumper.cpp",
69    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/system_ability_manager_stub.cpp",
70    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/system_ability_manager_util.cpp",
71    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/system_ability_status_change_proxy.cpp",
72    "//foundation/systemabilitymgr/samgr/services/samgr/native/source/system_process_status_change_proxy.cpp",
73    "//foundation/systemabilitymgr/samgr/utils/native/source/tools.cpp",
74  ]
75
76  deps = [
77    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/common:samgr_common",
78    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/dynamic_cache:dynamic_cache",
79    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/rust:samgr_rust",
80    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
81  ]
82
83  configs = [
84    ":sam_config",
85    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/common:config_samgr_common",
86    "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
87    ":distributed_store_config",
88  ]
89  defines = []
90  if (use_musl) {
91    if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
92      defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ]
93    }
94  }
95  if (is_standard_system) {
96    external_deps = [
97      "access_token:libaccesstoken_sdk",
98      "c_utils:utils",
99      "ffrt:libffrt",
100      "hilog:libhilog",
101      "hisysevent:libhisysevent",
102      "hitrace:hitrace_meter",
103      "init:libbeget_proxy",
104      "init:libbegetutil",
105      "ipc:ipc_core",
106      "ipc:libdbinder",
107      "safwk:system_ability_ondemand_reason",
108    ]
109
110    if (build_selinux) {
111      external_deps += [ "selinux_adapter:libservice_checker" ]
112      defines += [ "WITH_SELINUX" ]
113    }
114
115    if (hicollie_able) {
116      external_deps += [ "hicollie:libhicollie" ]
117      defines += [ "HICOLLIE_ENABLE" ]
118    }
119
120    if (support_device_manager) {
121      sources += [ "//foundation/systemabilitymgr/samgr/services/samgr/native/source/collect/device_networking_collect.cpp" ]
122      external_deps += [ "device_manager:devicemanagersdk" ]
123      defines += [ "SUPPORT_DEVICE_MANAGER" ]
124    }
125
126    if (support_common_event) {
127      sources += [
128        "//foundation/systemabilitymgr/samgr/services/samgr/native/source/collect/common_event_collect.cpp",
129        "//foundation/systemabilitymgr/samgr/services/samgr/native/source/collect/device_switch_collect.cpp",
130      ]
131      external_deps += [
132        "ability_base:want",
133        "common_event_service:cesfwk_innerkits",
134      ]
135      defines += [
136        "SUPPORT_COMMON_EVENT",
137        "SUPPORT_SWITCH_COLLECT",
138      ]
139    }
140
141    if (preferences_enable) {
142      sources += [ "//foundation/systemabilitymgr/samgr/services/samgr/native/source/collect/device_timed_collect_tool.cpp" ]
143      external_deps += [ "preferences:native_preferences" ]
144      defines += [ "PREFERENCES_ENABLE" ]
145    }
146    part_name = "samgr"
147  }
148
149  subsystem_name = "systemabilitymgr"
150}
151