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/hdi/hdi.gni") 15import("//build/ohos.gni") 16import("./../usb.gni") 17 18group("libusb_core") { 19 deps = [ 20 ":libusb_ddk_device", 21 ":libusb_ddk_host", 22 ":libusb_pnp_manager", 23 ] 24} 25 26ohos_shared_library("libusb_ddk_host") { 27 sanitize = { 28 integer_overflow = true 29 ubsan = true 30 boundary_sanitize = true 31 cfi = true 32 cfi_cross_dso = true 33 debug = false 34 } 35 branch_protector_ret = "pac_ret" 36 37 include_dirs = [ 38 "device/include", 39 "//drivers/hdf_core/framework/model/usb/include", 40 "host/include", 41 "./../interfaces/ddk/common", 42 "./../interfaces/ddk/device", 43 "./../interfaces/ddk/host", 44 "./../utils/include", 45 ] 46 sources = [ 47 "host/src/linux_adapter.c", 48 "host/src/usb_interface_pool.c", 49 "host/src/usb_io_manage.c", 50 "host/src/usb_protocol.c", 51 "host/src/usb_raw_api.c", 52 "host/src/usb_raw_api_library.c", 53 ] 54 55 if (drivers_peripheral_usb_feature_linux_native_model) { 56 if (defined(defines)) { 57 defines += [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ] 58 } else { 59 defines = [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ] 60 } 61 } 62 63 if (is_standard_system) { 64 external_deps = [ 65 "hdf_core:libhdf_host", 66 "hdf_core:libhdf_utils", 67 "hilog:libhilog", 68 ] 69 70 if (usb_c_utils_enable) { 71 external_deps += [ "c_utils:utils" ] 72 } 73 } else { 74 external_deps = [ "hilog:libhilog" ] 75 } 76 77 install_images = [ chipset_base_dir ] 78 subsystem_name = "hdf" 79 part_name = "drivers_peripheral_usb" 80} 81 82config("public_headers") { 83 include_dirs = [ "//drivers/hdf_core/framework/model/usb/include" ] 84} 85 86ohos_shared_library("libusb_pnp_manager") { 87 sanitize = { 88 integer_overflow = true 89 ubsan = true 90 boundary_sanitize = true 91 cfi = true 92 cfi_cross_dso = true 93 debug = false 94 } 95 branch_protector_ret = "pac_ret" 96 97 include_dirs = [ 98 "host/include", 99 "device/include", 100 "./../utils/include", 101 ] 102 public_configs = [ ":public_headers" ] 103 sources = [ 104 "//drivers/hdf_core/framework/model/usb/src/usb_ddk_pnp_loader.c", 105 "//drivers/hdf_core/framework/model/usb/src/usb_wrapper.cpp", 106 "device/src/usbfn_uevent_handle.c", 107 "host/src/ddk_device_manager.c", 108 "host/src/ddk_pnp_listener_mgr.c", 109 "host/src/ddk_sysfs_device.c", 110 "host/src/ddk_uevent_handle.c", 111 "host/src/usb_pnp_manager.c", 112 ] 113 114 if (drivers_peripheral_usb_feature_linux_native_model) { 115 if (defined(defines)) { 116 defines += [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ] 117 } else { 118 defines = [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ] 119 } 120 sources += [ "host/src/ddk_uevent_queue.cpp" ] 121 } 122 123 if (drivers_peripheral_usb_feature_emulator_mode) { 124 if (defined(defines)) { 125 defines += [ "USB_EMULATOR_MODE" ] 126 } else { 127 defines = [ "USB_EMULATOR_MODE" ] 128 } 129 } 130 131 if (is_standard_system) { 132 external_deps = [ 133 "hdf_core:libhdf_host", 134 "hdf_core:libhdf_utils", 135 "hilog:libhilog", 136 ] 137 138 if (usb_hisysevent_enable) { 139 external_deps += [ "hisysevent:libhisysevent" ] 140 141 if (defined(defines)) { 142 defines += [ "USB_ENABLE_HISYSEVENT" ] 143 } else { 144 defines = [ "USB_ENABLE_HISYSEVENT" ] 145 } 146 } 147 if (usb_c_utils_enable) { 148 external_deps += [ "c_utils:utils" ] 149 } 150 } else { 151 external_deps = [ "hilog:libhilog" ] 152 } 153 154 install_images = [ chipset_base_dir ] 155 subsystem_name = "hdf" 156 part_name = "drivers_peripheral_usb" 157} 158 159ohos_shared_library("libusb_ddk_device") { 160 sanitize = { 161 integer_overflow = true 162 ubsan = true 163 boundary_sanitize = true 164 cfi = true 165 cfi_cross_dso = true 166 debug = false 167 } 168 branch_protector_ret = "pac_ret" 169 170 include_dirs = [ 171 "device/include", 172 "host/include", 173 "./../interfaces/ddk/common", 174 "./../interfaces/ddk/device", 175 "./../interfaces/ddk/host", 176 "./../utils/include", 177 ] 178 179 sources = [ 180 "device/src/adapter_if.c", 181 "device/src/usbfn_cfg_mgr.c", 182 "device/src/usbfn_dev_mgr.c", 183 "device/src/usbfn_io_mgr.c", 184 "device/src/usbfn_sdk_if.c", 185 ] 186 187 if (is_standard_system) { 188 external_deps = [ 189 "hdf_core:libhdf_utils", 190 "hilog:libhilog", 191 ] 192 if (usb_c_utils_enable) { 193 external_deps += [ "c_utils:utils" ] 194 } 195 } else { 196 external_deps = [ "hilog:libhilog" ] 197 } 198 199 if (drivers_peripheral_usb_feature_linux_native_model) { 200 if (defined(defines)) { 201 defines += [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ] 202 } else { 203 defines = [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ] 204 } 205 } 206 207 install_images = [ chipset_base_dir ] 208 subsystem_name = "hdf" 209 part_name = "drivers_peripheral_usb" 210} 211