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/config/components/idl_tool/idl.gni") 15import("//build/ohos.gni") 16import("./../../sensor.gni") 17 18idl_gen_interface("sensor_service_interface") { 19 sources = [ "ISensorService.idl" ] 20 log_domainid = "0xD002700" 21 log_tag = "ISensorServiceIdl" 22 part_name = "sensor" 23 subsystem_name = "sensors" 24} 25 26ohos_source_set("sensor_service_stub") { 27 public_configs = [ ":sensor_private_config" ] 28 branch_protector_ret = "pac_ret" 29 sanitize = { 30 cfi = true 31 cfi_cross_dso = true 32 debug = false 33 } 34 output_values = get_target_outputs(":sensor_service_interface") 35 sources = filter_include(output_values, [ "*_stub.cpp" ]) 36 deps = [ ":sensor_service_interface" ] 37 external_deps = [ 38 "c_utils:utils", 39 "hilog:libhilog", 40 "ipc:ipc_single", 41 "samgr:samgr_proxy", 42 ] 43 part_name = "sensor" 44 subsystem_name = "sensors" 45} 46 47ohos_shared_library("libsensor_client") { 48 output_values = get_target_outputs(":sensor_service_interface") 49 sources = [ 50 "src/fd_listener.cpp", 51 "src/sensor_agent_proxy.cpp", 52 "src/sensor_client_stub.cpp", 53 "src/sensor_data_channel.cpp", 54 "src/sensor_event_handler.cpp", 55 "src/sensor_file_descriptor_listener.cpp", 56 "src/sensor_service_client.cpp", 57 ] 58 sources += filter_include(output_values, [ "*_proxy.cpp" ]) 59 60 include_dirs = [ 61 "${target_gen_dir}", 62 "$SUBSYSTEM_DIR/frameworks/native/include", 63 "$SUBSYSTEM_DIR/interfaces/inner_api", 64 "$SUBSYSTEM_DIR/utils/common/include", 65 "$SUBSYSTEM_DIR/utils/ipc/include", 66 ] 67 68 branch_protector_ret = "pac_ret" 69 sanitize = { 70 cfi = true 71 cfi_cross_dso = true 72 debug = false 73 } 74 75 defines = sensor_default_defines 76 77 deps = [ 78 ":sensor_service_interface", 79 "$SUBSYSTEM_DIR/utils/common:libsensor_utils", 80 "$SUBSYSTEM_DIR/utils/ipc:libsensor_ipc", 81 ] 82 83 if (sensor_rust_socket_ipc) { 84 deps += 85 [ "$SUBSYSTEM_DIR/rust/utils/socket_ipc_rust_ffi:sensor_rust_util_ffi" ] 86 } 87 88 external_deps = [ 89 "c_utils:utils", 90 "eventhandler:libeventhandler", 91 "hicollie:libhicollie", 92 "hilog:libhilog", 93 "ipc:ipc_single", 94 "samgr:samgr_proxy", 95 ] 96 97 if (hiviewdfx_hisysevent_enable) { 98 external_deps += [ "hisysevent:libhisysevent" ] 99 } 100 101 if (hiviewdfx_hitrace_enable) { 102 external_deps += [ "hitrace:hitrace_meter" ] 103 } 104 105 innerapi_tags = [ "platformsdk_indirect" ] 106 part_name = "sensor" 107 subsystem_name = "sensors" 108} 109ohos_ndk_library("libsensor_ndk") { 110 output_name = "sensor" 111 ndk_description_file = "./libsensor.json" 112 min_compact_version = "6" 113} 114 115config("sensor_private_config") { 116 include_dirs = [ 117 "${target_gen_dir}", 118 "$SUBSYSTEM_DIR/frameworks/native/include", 119 "$SUBSYSTEM_DIR/interfaces/inner_api", 120 "$SUBSYSTEM_DIR/utils/common/include", 121 ] 122} 123config("sensor_public_config") { 124 include_dirs = [ "$SUBSYSTEM_DIR/interfaces/inner_api" ] 125} 126 127ohos_shared_library("sensor_interface_native") { 128 output_name = "sensor_agent" 129 sources = [ 130 "src/geomagnetic_field.cpp", 131 "src/sensor_agent.cpp", 132 "src/sensor_algorithm.cpp", 133 ] 134 135 configs = [ ":sensor_private_config" ] 136 public_configs = [ ":sensor_public_config" ] 137 138 branch_protector_ret = "pac_ret" 139 sanitize = { 140 cfi = true 141 cfi_cross_dso = true 142 debug = false 143 boundary_sanitize = true 144 integer_overflow = true 145 ubsan = true 146 } 147 148 deps = [ "$SUBSYSTEM_DIR/frameworks/native:libsensor_client" ] 149 150 external_deps = [ 151 "c_utils:utils", 152 "eventhandler:libeventhandler", 153 "hilog:libhilog", 154 "ipc:ipc_single", 155 ] 156 157 part_name = "sensor" 158 innerapi_tags = [ "platformsdk" ] 159 subsystem_name = "sensors" 160} 161 162config("ohsensor_public_config") { 163 include_dirs = [ "$SUBSYSTEM_DIR/interfaces/kits/c" ] 164} 165 166ohos_shared_library("ohsensor") { 167 sources = [ "src/native_sensor.cpp" ] 168 output_extension = "so" 169 defines = [ "API_EXPORT=__attribute__((visibility (\"default\")))" ] 170 171 configs = [ ":sensor_private_config" ] 172 public_configs = [ ":ohsensor_public_config" ] 173 174 branch_protector_ret = "pac_ret" 175 sanitize = { 176 cfi = true 177 cfi_cross_dso = true 178 debug = false 179 } 180 181 deps = [ 182 "$SUBSYSTEM_DIR/frameworks/native:libsensor_client", 183 "$SUBSYSTEM_DIR/frameworks/native:sensor_interface_native", 184 "$SUBSYSTEM_DIR/utils/ipc:libsensor_ipc", 185 ] 186 187 external_deps = [ 188 "c_utils:utils", 189 "eventhandler:libeventhandler", 190 "hilog:libhilog", 191 "ipc:ipc_single", 192 ] 193 194 relative_install_dir = "ndk" 195 part_name = "sensor" 196 subsystem_name = "sensors" 197} 198 199group("sensor_target") { 200 deps = [ 201 ":libsensor_client", 202 ":sensor_interface_native", 203 ] 204} 205