1# Copyright (c) 2021-2022 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("./../../usbmgr.gni") 16 17idl_gen_interface("usb_server_interface") { 18 sources = [ "IUsbServer.idl" ] 19 sources_common = [ "UsbServerTypes.idl" ] 20 log_domainid = "0xD002A03" 21 log_tag = "UsbSrvClient" 22} 23 24config("usbsrv_public_config") { 25 include_dirs = [ 26 "native/include", 27 "${target_gen_dir}", 28 "${usb_manager_path}/utils/native/include", 29 ] 30} 31 32ohos_shared_library("usbsrv_client") { 33 sanitize = { 34 integer_overflow = true 35 ubsan = true 36 boundary_sanitize = true 37 } 38 output_values = get_target_outputs(":usb_server_interface") 39 sources = [ 40 "native/src/usb_device_pipe.cpp", 41 "native/src/usb_interface_type.cpp", 42 "native/src/usb_request.cpp", 43 "native/src/usb_srv_client.cpp", 44 "native/src/usbd_bulk_callback.cpp", 45 ] 46 sources += filter_include(output_values, 47 [ 48 "*_proxy.cpp", 49 "*_types.cpp", 50 ]) 51 configs = [ 52 "${utils_path}:utils_config", 53 ":usbsrv_public_config", 54 ] 55 56 defines = [] 57 if (usb_manager_feature_host) { 58 defines += [ "USB_MANAGER_FEATURE_HOST" ] 59 sources += [ 60 "${utils_path}/native/src/struct_parcel.cpp", 61 "native/src/usbd_callback_server.cpp", 62 "native/src/usbd_callback_stub.cpp", 63 ] 64 } 65 if (usb_manager_feature_device) { 66 defines += [ "USB_MANAGER_FEATURE_DEVICE" ] 67 } 68 if (usb_manager_feature_port) { 69 defines += [ "USB_MANAGER_FEATURE_PORT" ] 70 } 71 deps = [ ":usb_server_interface" ] 72 public_configs = [ ":usbsrv_public_config" ] 73 public_external_deps = [ 74 "cJSON:cjson", 75 "drivers_interface_usb:libserial_proxy_1.0", 76 "drivers_interface_usb:libserial_stub_1.0", 77 "drivers_interface_usb:usb_idl_headers", 78 "drivers_interface_usb:usb_idl_headers_1.1", 79 "drivers_interface_usb:usb_idl_headers_1.2", 80 ] 81 external_deps = [ 82 "c_utils:utils", 83 "drivers_interface_usb:libserial_proxy_1.0", 84 "drivers_interface_usb:libserial_stub_1.0", 85 "drivers_interface_usb:usb_idl_headers", 86 "drivers_interface_usb:usb_idl_headers_1.1", 87 "drivers_interface_usb:usb_idl_headers_1.2", 88 "hilog:libhilog", 89 "ipc:ipc_core", 90 "samgr:samgr_proxy", 91 ] 92 subsystem_name = "usb" 93 innerapi_tags = [ "platformsdk" ] 94 part_name = "usb_manager" 95} 96 97config("usbsrv_private_config") { 98 include_dirs = [ "native/include" ] 99} 100 101config("usb_inner_public_config") { 102 include_dirs = [ 103 "${target_gen_dir}", 104 "${usb_manager_path}/services/native/include", 105 "${usb_manager_path}/utils/native/include", 106 ] 107} 108 109ohos_source_set("usb_server_stub") { 110 sanitize = { 111 cfi = true 112 cfi_cross_dso = true 113 debug = false 114 } 115 branch_protector_ret = "pac_ret" 116 configs = [ 117 "${utils_path}:utils_config", 118 ":usbsrv_private_config", 119 ] 120 defines = [] 121 if (usb_manager_feature_host) { 122 defines += [ "USB_MANAGER_FEATURE_HOST" ] 123 } 124 if (usb_manager_feature_device) { 125 defines += [ "USB_MANAGER_FEATURE_DEVICE" ] 126 } 127 if (usb_manager_feature_port) { 128 defines += [ "USB_MANAGER_FEATURE_PORT" ] 129 } 130 public_configs = [ ":usb_inner_public_config" ] 131 output_values = get_target_outputs(":usb_server_interface") 132 sources = filter_include(output_values, 133 [ 134 "*_stub.cpp", 135 "*_types.cpp", 136 ]) 137 deps = [ ":usb_server_interface" ] 138 external_deps = [ 139 "cJSON:cjson", 140 "c_utils:utils", 141 "drivers_interface_usb:libusb_proxy_1.1", 142 "drivers_interface_usb:libusb_proxy_1.2", 143 "hilog:libhilog", 144 "ipc:ipc_single", 145 "samgr:samgr_proxy", 146 ] 147 subsystem_name = "usb" 148 part_name = "usb_manager" 149} 150