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 18config("usbd_private_config") { 19 include_dirs = [] 20} 21 22config("usbd_public_config") { 23 include_dirs = [ 24 "${usb_driver_path}/hdi_service/include", 25 "${usb_driver_path}/ddk/host/include", 26 "${usb_driver_path}/interfaces/ddk/host", 27 "${usb_driver_path}/interfaces/ddk/common", 28 "${usb_driver_path}/gadget/function/include", 29 "${usb_driver_path}/gadget/function/mtp/include", 30 "${usb_driver_path}/hdf_usb/include", 31 "${usb_driver_path}/hdi_service", 32 "${usb_driver_path}/interfaces/ddk/common/include", 33 "${usb_driver_path}/interfaces/ddk/device", 34 "${usb_driver_path}/utils/include", 35 ] 36} 37 38ohos_shared_library("libusb_interface_service_1.1") { 39 shlib_type = "hdi" 40 version_script = "usb_interface_service.map" 41 sanitize = { 42 integer_overflow = true 43 ubsan = true 44 boundary_sanitize = true 45 cfi = true 46 cfi_cross_dso = true 47 debug = false 48 } 49 branch_protector_ret = "pac_ret" 50 51 sources = [ 52 "src/usb_impl.cpp", 53 "src/usbd_accessory.cpp", 54 "src/usbd_dispatcher.cpp", 55 "src/usbd_function.cpp", 56 "src/usbd_load_usb_service.cpp", 57 "src/usbd_port.cpp", 58 ] 59 60 configs = [ ":usbd_private_config" ] 61 62 public_configs = [ ":usbd_public_config" ] 63 64 deps = [ 65 "${usb_driver_path}/ddk:libusb_ddk_host", 66 "${usb_driver_path}/ddk:libusb_pnp_manager", 67 "./../gadget/function/mtp:libusbfn_mtp_interface_service_1.0", 68 ] 69 70 if (is_standard_system) { 71 external_deps = [ 72 "drivers_interface_usb:usb_idl_headers_1.1", 73 "drivers_interface_usb:usbfn_mtp_idl_headers", 74 "hdf_core:libhdf_host", 75 "hdf_core:libhdf_ipc_adapter", 76 "hdf_core:libhdf_utils", 77 "hdf_core:libhdi", 78 "hilog:libhilog", 79 "hitrace:hitrace_meter", 80 "init:libbegetutil", 81 "ipc:ipc_single", 82 ] 83 if (usb_hisysevent_enable) { 84 external_deps += [ "hisysevent:libhisysevent" ] 85 86 if (defined(defines)) { 87 defines += [ "USB_ENABLE_HISYSEVENT" ] 88 } else { 89 defines = [ "USB_ENABLE_HISYSEVENT" ] 90 } 91 } 92 93 if (usb_samgr_enable) { 94 external_deps += [ "samgr:samgr_proxy" ] 95 96 if (defined(defines)) { 97 defines += [ "USB_ENABLE_SAMGR" ] 98 } else { 99 defines = [ "USB_ENABLE_SAMGR" ] 100 } 101 } 102 103 if (usb_c_utils_enable) { 104 external_deps += [ "c_utils:utils" ] 105 } 106 } else { 107 external_deps = [ 108 "drivers_interface_usb:libusbfn_mtp_stub_1.0", 109 "hilog:libhilog", 110 "ipc:ipc_single", 111 ] 112 } 113 114 install_images = [ chipset_base_dir ] 115 subsystem_name = "hdf" 116 part_name = "drivers_peripheral_usb" 117} 118 119ohos_shared_library("libusb_driver") { 120 sanitize = { 121 integer_overflow = true 122 ubsan = true 123 boundary_sanitize = true 124 cfi = true 125 cfi_cross_dso = true 126 debug = false 127 } 128 branch_protector_ret = "pac_ret" 129 130 sources = [ "src/usb_interface_driver.cpp" ] 131 132 public_deps = [ ":libusb_interface_service_1.1" ] 133 134 shlib_type = "hdi" 135 136 configs = [ ":usbd_private_config" ] 137 138 public_configs = [ ":usbd_public_config" ] 139 140 if (is_standard_system) { 141 external_deps = [ 142 "drivers_interface_usb:libusb_stub_1.1", 143 "hdf_core:libhdf_host", 144 "hdf_core:libhdf_ipc_adapter", 145 "hdf_core:libhdf_utils", 146 "hdf_core:libhdi", 147 "hilog:libhilog", 148 "ipc:ipc_single", 149 "samgr:samgr_proxy", 150 ] 151 if (usb_c_utils_enable) { 152 external_deps += [ "c_utils:utils" ] 153 } 154 } else { 155 external_deps = [ 156 "drivers_interface_usb:libusb_stub_1.1", 157 "hilog:libhilog", 158 "ipc:ipc_single", 159 ] 160 } 161 162 install_images = [ chipset_base_dir ] 163 subsystem_name = "hdf" 164 part_name = "drivers_peripheral_usb" 165} 166 167group("hdi_usb_service") { 168 deps = [ 169 ":libusb_driver", 170 ":libusb_interface_service_1.1", 171 ] 172} 173