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
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    "//drivers/hdf_core/framework/model/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    "//drivers/hdf_core/framework/model/usb/include",
99    "host/include",
100    "device/include",
101    "./../utils/include",
102  ]
103  sources = [
104    "//drivers/hdf_core/framework/model/usb/src/usb_ddk_pnp_loader.c",
105    "//drivers/hdf_core/framework/model/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_device.c",
111    "host/src/ddk_uevent_handle.c",
112    "host/src/usb_pnp_manager.c",
113  ]
114
115  if (drivers_peripheral_usb_feature_linux_native_model) {
116    if (defined(defines)) {
117      defines += [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ]
118    } else {
119      defines = [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ]
120    }
121    sources += [ "host/src/ddk_uevent_queue.cpp" ]
122  }
123
124  if (drivers_peripheral_usb_feature_emulator_mode) {
125    if (defined(defines)) {
126      defines += [ "USB_EMULATOR_MODE" ]
127    } else {
128      defines = [ "USB_EMULATOR_MODE" ]
129    }
130  }
131
132  if (is_standard_system) {
133    external_deps = [
134      "hdf_core:libhdf_host",
135      "hdf_core:libhdf_utils",
136      "hilog:libhilog",
137    ]
138
139    if (usb_hisysevent_enable) {
140      external_deps += [ "hisysevent:libhisysevent" ]
141
142      if (defined(defines)) {
143        defines += [ "USB_ENABLE_HISYSEVENT" ]
144      } else {
145        defines = [ "USB_ENABLE_HISYSEVENT" ]
146      }
147    }
148    if (usb_c_utils_enable) {
149      external_deps += [ "c_utils:utils" ]
150    }
151  } else {
152    external_deps = [ "hilog:libhilog" ]
153  }
154
155  install_images = [ chipset_base_dir ]
156  subsystem_name = "hdf"
157  part_name = "drivers_peripheral_usb"
158}
159
160ohos_shared_library("libusb_ddk_device") {
161  sanitize = {
162    integer_overflow = true
163    ubsan = true
164    boundary_sanitize = true
165    cfi = true
166    cfi_cross_dso = true
167    debug = false
168  }
169  branch_protector_ret = "pac_ret"
170
171  include_dirs = [
172    "device/include",
173    "host/include",
174    "./../interfaces/ddk/common",
175    "./../interfaces/ddk/device",
176    "./../interfaces/ddk/host",
177    "./../utils/include",
178  ]
179
180  sources = [
181    "device/src/adapter_if.c",
182    "device/src/usbfn_cfg_mgr.c",
183    "device/src/usbfn_dev_mgr.c",
184    "device/src/usbfn_io_mgr.c",
185    "device/src/usbfn_sdk_if.c",
186  ]
187
188  if (is_standard_system) {
189    external_deps = [
190      "hdf_core:libhdf_utils",
191      "hilog:libhilog",
192    ]
193    if (usb_c_utils_enable) {
194      external_deps += [ "c_utils:utils" ]
195    }
196  } else {
197    external_deps = [ "hilog:libhilog" ]
198  }
199
200  if (drivers_peripheral_usb_feature_linux_native_model) {
201    if (defined(defines)) {
202      defines += [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ]
203    } else {
204      defines = [ "USB_EVENT_NOTIFY_LINUX_NATIVE_MODE" ]
205    }
206  }
207
208  install_images = [ chipset_base_dir ]
209  subsystem_name = "hdf"
210  part_name = "drivers_peripheral_usb"
211}
212