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("./../sensor.gni")
16
17ohos_shared_library("libsensor_service") {
18  sources = [
19    "src/client_info.cpp",
20    "src/fifo_cache_data.cpp",
21    "src/flush_info_record.cpp",
22    "src/sensor_dump.cpp",
23    "src/sensor_manager.cpp",
24    "src/sensor_power_policy.cpp",
25    "src/sensor_service.cpp",
26    "src/sensor_service_stub.cpp",
27    "src/stream_server.cpp",
28  ]
29
30  include_dirs = [
31    "$SUBSYSTEM_DIR/frameworks/native/include",
32    "$SUBSYSTEM_DIR/interfaces/inner_api",
33    "$SUBSYSTEM_DIR/services/include",
34    "$SUBSYSTEM_DIR/utils/common/include",
35    "$SUBSYSTEM_DIR/utils/ipc/include",
36  ]
37
38  branch_protector_ret = "pac_ret"
39  sanitize = {
40    cfi = true
41    cfi_cross_dso = true
42    debug = false
43  }
44
45  defines = sensor_default_defines
46
47  deps = [
48    "$SUBSYSTEM_DIR/utils/common:libsensor_utils",
49    "$SUBSYSTEM_DIR/utils/ipc:libsensor_ipc",
50  ]
51
52  if (sensor_rust_socket_ipc) {
53    deps +=
54        [ "$SUBSYSTEM_DIR/rust/utils/socket_ipc_rust_ffi:sensor_rust_util_ffi" ]
55  }
56
57  external_deps = [
58    "access_token:libaccesstoken_sdk",
59    "access_token:libtokenid_sdk",
60    "c_utils:utils",
61    "hilog:libhilog",
62    "hisysevent:libhisysevent",
63    "hitrace:hitrace_meter",
64    "ipc:ipc_single",
65    "safwk:system_ability_fwk",
66    "samgr:samgr_proxy",
67  ]
68
69  if (sensor_memmgr_enable) {
70    defines += [ "MEMMGR_ENABLE" ]
71    external_deps += [ "memmgr:memmgrclient" ]
72  }
73
74  if (sensor_access_token_enable) {
75    defines += [ "ACCESS_TOKEN_ENABLE" ]
76  }
77
78  if (hdf_drivers_interface_sensor) {
79    sources += [
80      "hdi_connection/adapter/src/hdi_connection.cpp",
81      "hdi_connection/adapter/src/sensor_event_callback.cpp",
82      "hdi_connection/interface/src/sensor_hdi_connection.cpp",
83      "src/sensor_data_processer.cpp",
84    ]
85
86    include_dirs += [
87      "$SUBSYSTEM_DIR/services/hdi_connection/interface/include",
88      "$SUBSYSTEM_DIR/services/hdi_connection/adapter/include",
89    ]
90
91    if (sensor_build_eng) {
92      sources += [
93        "hdi_connection/adapter/src/compatible_connection.cpp",
94        "hdi_connection/hardware/src/hdi_service_impl.cpp",
95      ]
96
97      include_dirs +=
98          [ "$SUBSYSTEM_DIR/services/hdi_connection/hardware/include" ]
99    }
100
101    external_deps += [ "drivers_interface_sensor:libsensor_proxy_2.0" ]
102  }
103
104  shlib_type = "sa"
105  part_name = "sensor"
106  subsystem_name = "sensors"
107}
108
109##########################################################################
110ohos_static_library("libsensor_service_static") {
111  sources = [
112    "src/client_info.cpp",
113    "src/fifo_cache_data.cpp",
114    "src/flush_info_record.cpp",
115    "src/sensor_dump.cpp",
116    "src/sensor_manager.cpp",
117    "src/sensor_power_policy.cpp",
118    "src/sensor_service.cpp",
119    "src/sensor_service_stub.cpp",
120    "src/stream_server.cpp",
121  ]
122
123  include_dirs = [
124    "$SUBSYSTEM_DIR/frameworks/native/include",
125    "$SUBSYSTEM_DIR/interfaces/inner_api",
126    "$SUBSYSTEM_DIR/services/include",
127    "$SUBSYSTEM_DIR/utils/common/include",
128    "$SUBSYSTEM_DIR/utils/ipc/include",
129  ]
130
131  branch_protector_ret = "pac_ret"
132  sanitize = {
133    cfi = true
134    cfi_cross_dso = true
135    debug = false
136  }
137
138  defines = sensor_default_defines
139
140  deps = [
141    "$SUBSYSTEM_DIR/utils/common:libsensor_utils",
142    "$SUBSYSTEM_DIR/utils/ipc:libsensor_ipc",
143  ]
144
145  if (sensor_rust_socket_ipc) {
146    deps +=
147        [ "$SUBSYSTEM_DIR/rust/utils/socket_ipc_rust_ffi:sensor_rust_util_ffi" ]
148  }
149
150  external_deps = [
151    "access_token:libaccesstoken_sdk",
152    "access_token:libtokenid_sdk",
153    "c_utils:utils",
154    "hilog:libhilog",
155    "hisysevent:libhisysevent",
156    "hitrace:hitrace_meter",
157    "ipc:ipc_single",
158    "safwk:system_ability_fwk",
159    "samgr:samgr_proxy",
160  ]
161
162  if (sensor_memmgr_enable) {
163    defines += [ "MEMMGR_ENABLE" ]
164    external_deps += [ "memmgr:memmgrclient" ]
165  }
166
167  if (sensor_access_token_enable) {
168    defines += [ "ACCESS_TOKEN_ENABLE" ]
169  }
170
171  if (hdf_drivers_interface_sensor) {
172    sources += [
173      "hdi_connection/adapter/src/hdi_connection.cpp",
174      "hdi_connection/adapter/src/sensor_event_callback.cpp",
175      "hdi_connection/interface/src/sensor_hdi_connection.cpp",
176      "src/sensor_data_processer.cpp",
177    ]
178
179    include_dirs += [
180      "$SUBSYSTEM_DIR/services/hdi_connection/interface/include",
181      "$SUBSYSTEM_DIR/services/hdi_connection/adapter/include",
182    ]
183
184    if (sensor_build_eng) {
185      sources += [
186        "hdi_connection/adapter/src/compatible_connection.cpp",
187        "hdi_connection/hardware/src/hdi_service_impl.cpp",
188      ]
189
190      include_dirs +=
191          [ "$SUBSYSTEM_DIR/services/hdi_connection/hardware/include" ]
192    }
193
194    external_deps += [ "drivers_interface_sensor:libsensor_proxy_2.0" ]
195  }
196
197  part_name = "sensor"
198  subsystem_name = "sensors"
199}
200group("sensor_service_target") {
201  deps = [
202    ":libsensor_service",
203    ":libsensor_service_static",
204  ]
205}
206