1# Copyright (c) 2022-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.
13import("//build/ohos.gni")
14import("../../power.gni")
15
16ohos_shared_library("libpower_interface_service_1.2") {
17  include_dirs = [ "../../utils/include" ]
18  sources = [
19    "../../utils/power_xcollie.cpp",
20    "src/power_interface_impl.cpp",
21    "src/running_lock_counter.cpp",
22    "src/running_lock_impl.cpp",
23    "src/running_lock_timer_handler.cpp",
24    "src/system_operation.cpp",
25  ]
26
27  external_deps = [
28    "drivers_interface_power:libpower_stub_1.2",
29    "hdf_core:libhdf_host",
30    "hdf_core:libhdf_utils",
31    "hilog:libhilog",
32    "ipc:ipc_single",
33    "libxml2:libxml2",
34  ]
35
36  defines = []
37  if (has_power_c_utils_part) {
38    external_deps += [ "c_utils:utils" ]
39  }
40  if (has_power_hisysevent_part) {
41    external_deps += [ "hisysevent:libhisysevent" ]
42  }
43
44  # xcollie has a bug, disable it
45  has_power_xcollie_part = false
46  if (has_power_xcollie_part) {
47    external_deps += [ "hicollie:libhicollie" ]
48    defines += [ "HICOLLIE_ENABLE" ]
49  }
50
51  if (drivers_peripheral_power_wakeup_cause_path) {
52    sources += [ "src/power_config.cpp" ]
53
54    external_deps += [ "jsoncpp:jsoncpp" ]
55
56    if (has_power_config_policy_part) {
57      external_deps += [ "config_policy:configpolicy_util" ]
58    }
59
60    defines += [ "DRIVER_PERIPHERAL_POWER_WAKEUP_CAUSE_PATH" ]
61  }
62
63  if (drivers_peripheral_power_suspend_with_tag) {
64    defines += [ "DRIVER_PERIPHERAL_POWER_SUSPEND_WITH_TAG" ]
65  }
66
67  if (drivers_peripheral_power_faster_retry_of_sleep) {
68    defines += [ "FASTER_RETRY_OF_SLEEP" ]
69  }
70
71  if (drivers_peripheral_power_enable_s4) {
72    sources += [ "src/hibernate.cpp" ]
73    defines += [ "DRIVERS_PERIPHERAL_POWER_ENABLE_S4" ]
74  }
75
76  if (drivers_peripheral_power_slower_retry_of_sleep) {
77    defines += [ "SLOWER_RETRY_OF_SLEEP" ]
78  }
79
80  install_images = [ chipset_base_dir ]
81  subsystem_name = "hdf"
82  part_name = "drivers_peripheral_power"
83}
84
85##############################################################################################
86
87ohos_shared_library("libpower_driver") {
88  sources = [ "src/power_interface_driver.cpp" ]
89
90  external_deps = [
91    "drivers_interface_power:libpower_stub_1.2",
92    "hdf_core:libhdf_host",
93    "hdf_core:libhdf_ipc_adapter",
94    "hdf_core:libhdf_utils",
95    "hdf_core:libhdi",
96    "hilog:libhilog",
97    "ipc:ipc_single",
98  ]
99  if (has_power_c_utils_part) {
100    external_deps += [ "c_utils:utils" ]
101  }
102
103  shlib_type = "hdi"
104  install_images = [ chipset_base_dir ]
105  subsystem_name = "hdf"
106  part_name = "drivers_peripheral_power"
107}
108
109group("hdf_power") {
110  deps = [
111    ":libpower_driver",
112    ":libpower_interface_service_1.2",
113  ]
114
115  if (drivers_peripheral_power_wakeup_cause_path) {
116    deps += [ "profile:power_hdi_service_config" ]
117  }
118}
119