• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2025 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
18group("libusb_core") {
19  deps = [
20    ":libusb_ddk_device",
21    ":libusb_ddk_host",
22    ":libusb_pnp_manager",
23  ]
24}
25
26ohos_shared_library("libusb_ddk_host") {
27  sanitize = {
28    integer_overflow = true
29    ubsan = true
30    boundary_sanitize = true
31    cfi = true
32    cfi_cross_dso = true
33    debug = false
34  }
35  branch_protector_ret = "pac_ret"
36
37  include_dirs = [
38    "device/include",
39    "./../hdf_usb/include",
40    "host/include",
41    "./../interfaces/ddk/common",
42    "./../interfaces/ddk/device",
43    "./../interfaces/ddk/host",
44    "./../utils/include",
45  ]
46  sources = [
47    "host/src/linux_adapter.c",
48    "host/src/usb_interface_pool.c",
49    "host/src/usb_io_manage.c",
50    "host/src/usb_protocol.c",
51    "host/src/usb_raw_api.c",
52    "host/src/usb_raw_api_library.c",
53  ]
54
55  if (drivers_peripheral_usb_feature_linux_native_model) {
56    if (defined(defines)) {
57      defines += [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ]
58    } else {
59      defines = [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ]
60    }
61  }
62
63  if (is_standard_system) {
64    external_deps = [
65      "hdf_core:libhdf_host",
66      "hdf_core:libhdf_utils",
67      "hilog:libhilog",
68    ]
69
70    if (usb_c_utils_enable) {
71      external_deps += [ "c_utils:utils" ]
72    }
73  } else {
74    external_deps = [ "hilog:libhilog" ]
75  }
76
77  install_images = [ chipset_base_dir ]
78  subsystem_name = "hdf"
79  part_name = "drivers_peripheral_usb"
80}
81
82config("public_headers") {
83  include_dirs = [ "//drivers/hdf_core/framework/model/usb/include" ]
84}
85
86ohos_shared_library("libusb_pnp_manager") {
87  sanitize = {
88    integer_overflow = true
89    ubsan = true
90    boundary_sanitize = true
91    cfi = true
92    cfi_cross_dso = true
93    debug = false
94  }
95  branch_protector_ret = "pac_ret"
96
97  include_dirs = [
98    "./../hdf_usb/include",
99    "host/include",
100    "device/include",
101    "./../utils/include",
102  ]
103  sources = [
104    "./../hdf_usb/src/usb_ddk_pnp_loader.c",
105    "./../hdf_usb/src/usb_wrapper.cpp",
106    "device/src/usb_accessory_uevent_handle.c",
107    "device/src/usbfn_uevent_handle.c",
108    "host/src/ddk_device_manager.c",
109    "host/src/ddk_pnp_listener_mgr.c",
110    "host/src/ddk_sysfs_dev_node.cpp",
111    "host/src/ddk_sysfs_device.c",
112    "host/src/ddk_uevent_handle.c",
113    "host/src/usb_pnp_manager.c",
114  ]
115
116  if (drivers_peripheral_usb_feature_linux_native_model) {
117    if (defined(defines)) {
118      defines += [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ]
119    } else {
120      defines = [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ]
121    }
122    sources += [ "host/src/ddk_uevent_queue.cpp" ]
123  }
124
125  if (drivers_peripheral_usb_feature_emulator_mode) {
126    if (defined(defines)) {
127      defines += [ "USB_EMULATOR_MODE" ]
128    } else {
129      defines = [ "USB_EMULATOR_MODE" ]
130    }
131  }
132
133  if (is_standard_system) {
134    external_deps = [
135      "hdf_core:libhdf_host",
136      "hdf_core:libhdf_utils",
137      "hilog:libhilog",
138    ]
139
140    if (usb_hisysevent_enable) {
141      external_deps += [ "hisysevent:libhisysevent" ]
142
143      if (defined(defines)) {
144        defines += [ "USB_ENABLE_HISYSEVENT" ]
145      } else {
146        defines = [ "USB_ENABLE_HISYSEVENT" ]
147      }
148    }
149    if (usb_c_utils_enable) {
150      external_deps += [ "c_utils:utils" ]
151    }
152  } else {
153    external_deps = [ "hilog:libhilog" ]
154  }
155
156  install_images = [ chipset_base_dir ]
157  subsystem_name = "hdf"
158  part_name = "drivers_peripheral_usb"
159}
160
161ohos_shared_library("libusb_ddk_device") {
162  sanitize = {
163    integer_overflow = true
164    ubsan = true
165    boundary_sanitize = true
166    cfi = true
167    cfi_cross_dso = true
168    debug = false
169  }
170  branch_protector_ret = "pac_ret"
171
172  include_dirs = [
173    "device/include",
174    "host/include",
175    "./../interfaces/ddk/common",
176    "./../interfaces/ddk/device",
177    "./../interfaces/ddk/host",
178    "./../utils/include",
179  ]
180
181  sources = [
182    "device/src/adapter_if.c",
183    "device/src/usbfn_cfg_mgr.c",
184    "device/src/usbfn_dev_mgr.c",
185    "device/src/usbfn_io_mgr.c",
186    "device/src/usbfn_sdk_if.c",
187  ]
188
189  if (is_standard_system) {
190    external_deps = [
191      "hdf_core:libhdf_utils",
192      "hilog:libhilog",
193    ]
194    if (usb_c_utils_enable) {
195      external_deps += [ "c_utils:utils" ]
196    }
197  } else {
198    external_deps = [ "hilog:libhilog" ]
199  }
200
201  if (drivers_peripheral_usb_feature_linux_native_model) {
202    if (defined(defines)) {
203      defines += [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ]
204    } else {
205      defines = [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ]
206    }
207  }
208
209  install_images = [ chipset_base_dir ]
210  subsystem_name = "hdf"
211  part_name = "drivers_peripheral_usb"
212}
213