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