• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_1.1",
78    "drivers_interface_usb:usb_idl_headers_1.2",
79  ]
80  external_deps = [
81    "c_utils:utils",
82    "drivers_interface_usb:libserial_proxy_1.0",
83    "drivers_interface_usb:libserial_stub_1.0",
84    "drivers_interface_usb:usb_idl_headers_1.1",
85    "drivers_interface_usb:usb_idl_headers_1.2",
86    "hilog:libhilog",
87    "ipc:ipc_core",
88    "samgr:samgr_proxy",
89  ]
90  subsystem_name = "usb"
91  innerapi_tags = [ "platformsdk" ]
92  part_name = "usb_manager"
93}
94
95config("usbsrv_private_config") {
96  include_dirs = [ "native/include" ]
97}
98
99config("usb_inner_public_config") {
100  include_dirs = [
101    "${target_gen_dir}",
102    "${usb_manager_path}/services/native/include",
103    "${usb_manager_path}/utils/native/include",
104  ]
105}
106
107ohos_source_set("usb_server_stub") {
108  sanitize = {
109    cfi = true
110    cfi_cross_dso = true
111    debug = false
112  }
113  configs = [
114    "${utils_path}:utils_config",
115    ":usbsrv_private_config",
116  ]
117  defines = []
118  if (usb_manager_feature_host) {
119    defines += [ "USB_MANAGER_FEATURE_HOST" ]
120  }
121  if (usb_manager_feature_device) {
122    defines += [ "USB_MANAGER_FEATURE_DEVICE" ]
123  }
124  if (usb_manager_feature_port) {
125    defines += [ "USB_MANAGER_FEATURE_PORT" ]
126  }
127  public_configs = [ ":usb_inner_public_config" ]
128  output_values = get_target_outputs(":usb_server_interface")
129  sources = filter_include(output_values,
130                           [
131                             "*_stub.cpp",
132                             "*_types.cpp",
133                           ])
134  deps = [ ":usb_server_interface" ]
135  external_deps = [
136    "cJSON:cjson",
137    "c_utils:utils",
138    "drivers_interface_usb:libusb_proxy_1.1",
139    "drivers_interface_usb:libusb_proxy_1.2",
140    "hilog:libhilog",
141    "ipc:ipc_single",
142    "samgr:samgr_proxy",
143  ]
144  subsystem_name = "usb"
145  part_name = "usb_manager"
146}
147