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