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("./../usbmgr.gni")
15
16config("usbsrv_private_config") {
17  include_dirs = [ "${usb_manager_path}/interfaces/innerkits/native/include" ]
18}
19
20config("usbsrv_public_config") {
21  include_dirs = [
22    "native/include",
23    "${usb_manager_path}/services/zidl/include",
24    "${usb_manager_path}/utils/native/include",
25  ]
26}
27
28ohos_shared_library("usbservice") {
29  sanitize = {
30    integer_overflow = true
31    ubsan = true
32    boundary_sanitize = true
33    cfi = true
34    cfi_cross_dso = true
35    debug = false
36  }
37  branch_protector_ret = "pac_ret"
38
39  install_enable = true
40  sources = [
41    "${usb_manager_path}/services/zidl/src/usb_srv_stub.cpp",
42    "native/src/usb_accessory_manager.cpp",
43    "native/src/usb_descriptor_parser.cpp",
44    "native/src/usb_device_manager.cpp",
45    "native/src/usb_function_switch_window.cpp",
46    "native/src/usb_host_manager.cpp",
47    "native/src/usb_port_manager.cpp",
48    "native/src/usb_report_sys_event.cpp",
49    "native/src/usb_right_database.cpp",
50    "native/src/usb_right_db_helper.cpp",
51    "native/src/usb_right_manager.cpp",
52    "native/src/usb_serial_reader.cpp",
53    "native/src/usb_service.cpp",
54    "native/src/usb_service_subscriber.cpp",
55    "native/src/usbd_bulkcallback_impl.cpp",
56  ]
57
58  if (distributed_notification_enable) {
59    sources += [ "native/src/usb_mass_storage_notification.cpp" ]
60  }
61
62  configs = [
63    "${utils_path}:utils_config",
64    ":usbsrv_private_config",
65  ]
66
67  public_configs = [ ":usbsrv_public_config" ]
68
69  defines = []
70
71  external_deps = [
72    "ability_base:base",
73    "ability_base:want",
74    "ability_base:zuri",
75    "ability_runtime:ability_connect_callback_stub",
76    "ability_runtime:ability_manager",
77    "ability_runtime:wantagent_innerkits",
78    "access_token:libaccesstoken_sdk",
79    "access_token:libtokenid_sdk",
80    "bundle_framework:appexecfwk_base",
81    "bundle_framework:appexecfwk_core",
82    "cJSON:cjson",
83    "c_utils:utils",
84    "common_event_service:cesfwk_innerkits",
85    "drivers_interface_usb:libusb_proxy_1.1",
86    "drivers_peripheral_usb:libusb_interface_service_1.1",
87    "hilog:libhilog",
88    "hisysevent:libhisysevent",
89    "hitrace:hitrace_meter",
90    "init:libbegetutil",
91    "ipc:ipc_single",
92    "memmgr:memmgrclient",
93    "napi:ace_napi",
94    "os_account:os_account_innerkits",
95    "relational_store:native_rdb",
96    "safwk:system_ability_fwk",
97    "samgr:samgr_proxy",
98  ]
99
100  if (distributed_notification_enable) {
101    external_deps += [
102      "distributed_notification_service:ans_innerkits",
103      "i18n:intl_util",
104      "resource_management:global_resmgr",
105    ]
106    defines += [ "USB_NOTIFICATION_ENABLE" ]
107  }
108
109  if (usb_manager_feature_pop_up_func_switch_model) {
110    defines += [ "USB_FUNC_SWITCH_MODE" ]
111  }
112  subsystem_name = "usb"
113  part_name = "usb_manager"
114}
115
116ohos_prebuilt_etc("usb_service.init") {
117  source = "usb_service.cfg"
118  relative_install_dir = "init"
119  subsystem_name = "usb"
120  part_name = "usb_manager"
121}
122