• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    "${usb_driver_path}/libusb_adapter/include",
36  ]
37}
38
39ohos_shared_library("libusb_interface_service_1.2") {
40  shlib_type = "hdi"
41  version_script = "usb_interface_service.map"
42  sanitize = {
43    integer_overflow = true
44    ubsan = true
45    boundary_sanitize = true
46    cfi = true
47    cfi_cross_dso = true
48    debug = false
49  }
50  branch_protector_ret = "pac_ret"
51
52  sources = [
53    "src/usb_impl.cpp",
54    "src/usb_report_sys_event.cpp",
55    "src/usbd_accessory.cpp",
56    "src/usbd_dispatcher.cpp",
57    "src/usbd_function.cpp",
58    "src/usbd_load_usb_service.cpp",
59    "src/usbd_port.cpp",
60    "src/usbd_ports.cpp",
61  ]
62
63  configs = [ ":usbd_private_config" ]
64
65  public_configs = [ ":usbd_public_config" ]
66
67  deps = [
68    "${usb_driver_path}/ddk:libusb_ddk_device",
69    "${usb_driver_path}/ddk:libusb_ddk_host",
70    "${usb_driver_path}/ddk:libusb_pnp_manager",
71    "${usb_driver_path}/libusb_adapter:libusb_adapter",
72    "./../gadget/function/mtp:libusbfn_mtp_interface_service_1.0",
73  ]
74
75  if (is_standard_system) {
76    external_deps = [
77      "drivers_interface_usb:libusb_proxy_2.0",
78      "drivers_interface_usb:libusb_stub_2.0",
79      "drivers_interface_usb:usb_idl_headers_1.2",
80      "drivers_interface_usb:usbfn_mtp_idl_headers",
81      "hdf_core:libhdf_host",
82      "hdf_core:libhdf_ipc_adapter",
83      "hdf_core:libhdf_utils",
84      "hdf_core:libhdi",
85      "hilog:libhilog",
86      "hitrace:hitrace_meter",
87      "init:libbegetutil",
88      "ipc:ipc_single",
89      "libusb:libusb",
90    ]
91    if (usb_hisysevent_enable) {
92      external_deps += [ "hisysevent:libhisysevent" ]
93
94      if (defined(defines)) {
95        defines += [ "USB_ENABLE_HISYSEVENT" ]
96      } else {
97        defines = [ "USB_ENABLE_HISYSEVENT" ]
98      }
99    }
100    if (libusb_enable) {
101      defines += [ "LIBUSB_ENABLE" ]
102    }
103    if (usb_samgr_enable) {
104      external_deps += [ "samgr:samgr_proxy" ]
105
106      if (defined(defines)) {
107        defines += [ "USB_ENABLE_SAMGR" ]
108      } else {
109        defines = [ "USB_ENABLE_SAMGR" ]
110      }
111    }
112
113    if (usb_c_utils_enable) {
114      external_deps += [ "c_utils:utils" ]
115    }
116  } else {
117    external_deps = [
118      "drivers_interface_usb:libusbfn_mtp_stub_1.0",
119      "hilog:libhilog",
120      "ipc:ipc_single",
121    ]
122  }
123
124  install_images = [ chipset_base_dir ]
125  subsystem_name = "hdf"
126  part_name = "drivers_peripheral_usb"
127}
128
129ohos_shared_library("libusb_driver") {
130  sanitize = {
131    integer_overflow = true
132    ubsan = true
133    boundary_sanitize = true
134    cfi = true
135    cfi_cross_dso = true
136    debug = false
137  }
138  branch_protector_ret = "pac_ret"
139
140  sources = [ "src/usb_interface_driver.cpp" ]
141
142  public_deps = [ ":libusb_interface_service_1.2" ]
143
144  shlib_type = "hdi"
145
146  configs = [ ":usbd_private_config" ]
147
148  public_configs = [ ":usbd_public_config" ]
149
150  if (is_standard_system) {
151    external_deps = [
152      "drivers_interface_usb:libusb_stub_1.0",
153      "drivers_interface_usb:libusb_stub_1.1",
154      "drivers_interface_usb:libusb_stub_1.2",
155      "hdf_core:libhdf_host",
156      "hdf_core:libhdf_ipc_adapter",
157      "hdf_core:libhdf_utils",
158      "hdf_core:libhdi",
159      "hilog:libhilog",
160      "ipc:ipc_single",
161      "samgr:samgr_proxy",
162    ]
163    if (usb_c_utils_enable) {
164      external_deps += [ "c_utils:utils" ]
165    }
166  } else {
167    external_deps = [
168      "drivers_interface_usb:libusb_stub_1.0",
169      "drivers_interface_usb:libusb_stub_1.1",
170      "drivers_interface_usb:libusb_stub_1.2",
171      "hilog:libhilog",
172      "ipc:ipc_single",
173    ]
174  }
175
176  install_images = [ chipset_base_dir ]
177  subsystem_name = "hdf"
178  part_name = "drivers_peripheral_usb"
179}
180
181ohos_shared_library("libusb_port_interface_service_2.0") {
182  sanitize = {
183    integer_overflow = true
184    ubsan = true
185    boundary_sanitize = true
186    cfi = true
187    cfi_cross_dso = true
188    debug = false
189  }
190  branch_protector_ret = "pac_ret"
191
192  sources = [
193    "src/usb_port_impl.cpp",
194    "src/usb_report_sys_event.cpp",
195    "src/usbd_load_usb_service.cpp",
196    "src/usbd_port.cpp",
197    "src/usbd_ports.cpp",
198  ]
199
200  configs = [ ":usbd_private_config" ]
201
202  public_configs = [ ":usbd_public_config" ]
203
204  deps = [
205    "${usb_driver_path}/ddk:libusb_ddk_device",
206    "${usb_driver_path}/ddk:libusb_ddk_host",
207    "${usb_driver_path}/ddk:libusb_pnp_manager",
208  ]
209
210  if (is_standard_system) {
211    external_deps = [
212      "drivers_interface_usb:libusb_proxy_2.0",
213      "drivers_interface_usb:libusb_stub_2.0",
214      "hdf_core:libhdf_host",
215      "hdf_core:libhdf_ipc_adapter",
216      "hdf_core:libhdf_utils",
217      "hdf_core:libhdi",
218      "hilog:libhilog",
219      "hitrace:hitrace_meter",
220      "init:libbegetutil",
221      "ipc:ipc_single",
222      "samgr:samgr_proxy",
223    ]
224    if (usb_hisysevent_enable) {
225      external_deps += [ "hisysevent:libhisysevent" ]
226
227      if (defined(defines)) {
228        defines += [ "USB_ENABLE_HISYSEVENT" ]
229      } else {
230        defines = [ "USB_ENABLE_HISYSEVENT" ]
231      }
232    }
233
234    if (usb_samgr_enable) {
235      if (defined(defines)) {
236        defines += [ "USB_ENABLE_SAMGR" ]
237      } else {
238        defines = [ "USB_ENABLE_SAMGR" ]
239      }
240    }
241
242    if (usb_c_utils_enable) {
243      external_deps += [ "c_utils:utils" ]
244    }
245  } else {
246    external_deps = [
247      "drivers_interface_usb:libusbfn_mtp_stub_1.0",
248      "hilog:libhilog",
249      "ipc:ipc_single",
250    ]
251  }
252
253  install_images = [ chipset_base_dir ]
254  subsystem_name = "hdf"
255  part_name = "drivers_peripheral_usb"
256}
257
258ohos_shared_library("libusb_port_driver") {
259  sanitize = {
260    integer_overflow = true
261    ubsan = true
262    boundary_sanitize = true
263    cfi = true
264    cfi_cross_dso = true
265    debug = false
266  }
267  branch_protector_ret = "pac_ret"
268
269  sources = [ "src/usb_port_interface_driver.cpp" ]
270
271  public_deps = [ ":libusb_port_interface_service_2.0" ]
272
273  shlib_type = "hdi"
274
275  configs = [ ":usbd_private_config" ]
276
277  public_configs = [ ":usbd_public_config" ]
278
279  if (is_standard_system) {
280    external_deps = [
281      "drivers_interface_usb:libusb_stub_2.0",
282      "drivers_interface_usb:libusb_stub_1.0",
283      "hdf_core:libhdf_host",
284      "hdf_core:libhdf_ipc_adapter",
285      "hdf_core:libhdf_utils",
286      "hdf_core:libhdi",
287      "hilog:libhilog",
288      "ipc:ipc_single",
289      "samgr:samgr_proxy",
290    ]
291    if (usb_c_utils_enable) {
292      external_deps += [ "c_utils:utils" ]
293    }
294  } else {
295    external_deps = [
296      "drivers_interface_usb:libusb_stub_2.0",
297      "hilog:libhilog",
298      "ipc:ipc_single",
299    ]
300  }
301
302  install_images = [ chipset_base_dir ]
303  subsystem_name = "hdf"
304  part_name = "drivers_peripheral_usb"
305}
306
307ohos_shared_library("libusb_host_interface_service_2.0") {
308  sanitize = {
309    integer_overflow = true
310    ubsan = true
311    boundary_sanitize = true
312    cfi = true
313    cfi_cross_dso = true
314    debug = false
315  }
316  branch_protector_ret = "pac_ret"
317
318  sources = [
319    "src/usb_host_impl.cpp",
320    "src/usb_report_sys_event.cpp",
321    "src/usb_transfer_callback.cpp",
322    "src/usbd_function.cpp",
323    "src/usbd_load_usb_service.cpp",
324    "src/usbd_port.cpp",
325    "src/usbd_ports.cpp",
326  ]
327
328  configs = [ ":usbd_private_config" ]
329
330  public_configs = [ ":usbd_public_config" ]
331
332  deps = [
333    "${usb_driver_path}/ddk:libusb_ddk_device",
334    "${usb_driver_path}/libusb_adapter:libusb_adapter",
335    "./../gadget/function/mtp:libusbfn_mtp_interface_service_1.0",
336  ]
337
338  if (is_standard_system) {
339    external_deps = [
340      "drivers_interface_usb:libusb_proxy_2.0",
341      "drivers_interface_usb:libusb_stub_2.0",
342      "drivers_interface_usb:usbfn_mtp_idl_headers",
343      "hdf_core:libhdf_host",
344      "hdf_core:libhdf_ipc_adapter",
345      "hdf_core:libhdf_utils",
346      "hdf_core:libhdi",
347      "hilog:libhilog",
348      "hitrace:hitrace_meter",
349      "init:libbegetutil",
350      "ipc:ipc_single",
351      "libusb:libusb",
352      "samgr:samgr_proxy",
353    ]
354    if (usb_hisysevent_enable) {
355      external_deps += [ "hisysevent:libhisysevent" ]
356
357      if (defined(defines)) {
358        defines += [ "USB_ENABLE_HISYSEVENT" ]
359      } else {
360        defines = [ "USB_ENABLE_HISYSEVENT" ]
361      }
362    }
363
364    if (usb_samgr_enable) {
365      if (defined(defines)) {
366        defines += [ "USB_ENABLE_SAMGR" ]
367      } else {
368        defines = [ "USB_ENABLE_SAMGR" ]
369      }
370    }
371
372    if (usb_c_utils_enable) {
373      external_deps += [ "c_utils:utils" ]
374    }
375  } else {
376    external_deps = [
377      "drivers_interface_usb:libusbfn_mtp_stub_1.0",
378      "hilog:libhilog",
379      "ipc:ipc_single",
380    ]
381  }
382
383  install_images = [ chipset_base_dir ]
384  innerapi_tags = [ "passthrough_indirect" ]
385  subsystem_name = "hdf"
386  part_name = "drivers_peripheral_usb"
387}
388
389ohos_shared_library("libusb_device_interface_service_2.0") {
390  sanitize = {
391    integer_overflow = true
392    ubsan = true
393    boundary_sanitize = true
394    cfi = true
395    cfi_cross_dso = true
396    debug = false
397  }
398  branch_protector_ret = "pac_ret"
399
400  sources = [
401    "src/usb_device_impl.cpp",
402    "src/usb_report_sys_event.cpp",
403    "src/usb_sa_subscriber.cpp",
404    "src/usbd_accessory.cpp",
405    "src/usbd_function.cpp",
406    "src/usbd_load_usb_service.cpp",
407  ]
408
409  configs = [ ":usbd_private_config" ]
410
411  public_configs = [ ":usbd_public_config" ]
412
413  deps = [
414    "${usb_driver_path}/ddk:libusb_ddk_device",
415    "${usb_driver_path}/ddk:libusb_ddk_host",
416    "${usb_driver_path}/ddk:libusb_pnp_manager",
417    "${usb_driver_path}/libusb_adapter:libusb_adapter",
418    "./../gadget/function/mtp:libusbfn_mtp_interface_service_1.0",
419  ]
420
421  if (is_standard_system) {
422    external_deps = [
423      "drivers_interface_usb:libusb_proxy_2.0",
424      "drivers_interface_usb:libusb_stub_2.0",
425      "drivers_interface_usb:usbfn_mtp_idl_headers",
426      "hdf_core:libhdf_host",
427      "hdf_core:libhdf_ipc_adapter",
428      "hdf_core:libhdf_utils",
429      "hdf_core:libhdi",
430      "hilog:libhilog",
431      "hitrace:hitrace_meter",
432      "init:libbegetutil",
433      "ipc:ipc_single",
434      "libusb:libusb",
435      "samgr:samgr_proxy",
436    ]
437    if (usb_hisysevent_enable) {
438      external_deps += [ "hisysevent:libhisysevent" ]
439
440      if (defined(defines)) {
441        defines += [ "USB_ENABLE_HISYSEVENT" ]
442      } else {
443        defines = [ "USB_ENABLE_HISYSEVENT" ]
444      }
445    }
446
447    if (usb_samgr_enable) {
448      if (defined(defines)) {
449        defines += [ "USB_ENABLE_SAMGR" ]
450      } else {
451        defines = [ "USB_ENABLE_SAMGR" ]
452      }
453    }
454
455    if (usb_c_utils_enable) {
456      external_deps += [ "c_utils:utils" ]
457    }
458  } else {
459    external_deps = [
460      "drivers_interface_usb:libusbfn_mtp_stub_1.0",
461      "hilog:libhilog",
462      "ipc:ipc_single",
463    ]
464  }
465
466  install_images = [ chipset_base_dir ]
467  subsystem_name = "hdf"
468  part_name = "drivers_peripheral_usb"
469}
470
471ohos_shared_library("libusb_device_driver") {
472  sanitize = {
473    integer_overflow = true
474    ubsan = true
475    boundary_sanitize = true
476    cfi = true
477    cfi_cross_dso = true
478    debug = false
479  }
480  branch_protector_ret = "pac_ret"
481
482  sources = [ "src/usb_device_interface_driver.cpp" ]
483
484  public_deps = [ ":libusb_device_interface_service_2.0" ]
485
486  shlib_type = "hdi"
487
488  configs = [ ":usbd_private_config" ]
489
490  public_configs = [ ":usbd_public_config" ]
491
492  if (is_standard_system) {
493    external_deps = [
494      "drivers_interface_usb:libusb_stub_2.0",
495      "hdf_core:libhdf_host",
496      "hdf_core:libhdf_ipc_adapter",
497      "hdf_core:libhdf_utils",
498      "hdf_core:libhdi",
499      "hilog:libhilog",
500      "ipc:ipc_single",
501      "samgr:samgr_proxy",
502    ]
503    if (usb_c_utils_enable) {
504      external_deps += [ "c_utils:utils" ]
505    }
506  } else {
507    external_deps = [
508      "drivers_interface_usb:libusb_stub_2.0",
509      "hilog:libhilog",
510      "ipc:ipc_single",
511    ]
512  }
513
514  install_images = [ chipset_base_dir ]
515  subsystem_name = "hdf"
516  part_name = "drivers_peripheral_usb"
517}
518
519group("hdi_usb_service") {
520  if (usb_drivers_pass_through) {
521    deps = [
522      ":libusb_device_driver",
523      ":libusb_device_interface_service_2.0",
524      ":libusb_host_interface_service_2.0",
525      ":libusb_port_driver",
526      ":libusb_port_interface_service_2.0",
527    ]
528  } else {
529    deps = [
530      ":libusb_driver",
531      ":libusb_interface_service_1.2",
532    ]
533  }
534}
535