• 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("./../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}/utils/native/include",
24  ]
25}
26
27ohos_shared_library("usbservice") {
28  sanitize = {
29    integer_overflow = true
30    ubsan = true
31    boundary_sanitize = true
32    cfi = true
33    cfi_cross_dso = true
34    debug = false
35  }
36  branch_protector_ret = "pac_ret"
37
38  install_enable = true
39  sources = [
40    "${utils_path}/native/src/usb_settings_datashare.cpp",
41    "native/src/serial_manager.cpp",
42    "native/src/usb_connection_notifier.cpp",
43    "native/src/usb_report_sys_event.cpp",
44    "native/src/usb_right_database.cpp",
45    "native/src/usb_right_db_helper.cpp",
46    "native/src/usb_right_manager.cpp",
47    "native/src/usb_service.cpp",
48    "native/src/usb_service_subscriber.cpp",
49  ]
50
51  configs = [
52    "${utils_path}:utils_config",
53    ":usbsrv_private_config",
54  ]
55
56  public_configs = [ ":usbsrv_public_config" ]
57  deps = [ "${usb_manager_path}/interfaces/innerkits:usb_server_stub" ]
58  defines = []
59  if (usb_manager_pass_through) {
60    defines += [
61      "USB_MANAGER_PASS_THROUGH",
62      "USB_MANAGER_V2_0",
63    ]
64    sources += [ "native/src/usb_manager_subscriber.cpp" ]
65  }
66  if (usb_manager_feature_host) {
67    defines += [ "USB_MANAGER_FEATURE_HOST" ]
68    sources += [
69      "${utils_path}/native/src/struct_parcel.cpp",
70      "native/src/usb_descriptor_parser.cpp",
71      "native/src/usb_host_manager.cpp",
72      "native/src/usb_serial_reader.cpp",
73      "native/src/usbd_bulkcallback_impl.cpp",
74      "native/src/usbd_transfer_callback_impl.cpp",
75    ]
76    if (usb_manager_pass_through) {
77      sources += [
78        "native/src/usb_bulkcallback_impl.cpp",
79        "native/src/usb_transfer_callback_impl.cpp",
80      ]
81    }
82  }
83  if (usb_manager_feature_device) {
84    defines += [ "USB_MANAGER_FEATURE_DEVICE" ]
85    sources += [
86      "native/src/usb_accessory_manager.cpp",
87      "native/src/usb_device_manager.cpp",
88      "native/src/usb_function_switch_window.cpp",
89    ]
90  }
91  if (usb_manager_feature_port) {
92    defines += [ "USB_MANAGER_FEATURE_PORT" ]
93    sources += [ "native/src/usb_port_manager.cpp" ]
94  }
95
96  external_deps = [
97    "ability_base:base",
98    "ability_base:want",
99    "ability_runtime:ability_connect_callback_stub",
100    "ability_runtime:ability_manager",
101    "ability_runtime:wantagent_innerkits",
102    "access_token:libaccesstoken_sdk",
103    "access_token:libtokenid_sdk",
104    "bundle_framework:appexecfwk_base",
105    "bundle_framework:appexecfwk_core",
106    "cJSON:cjson",
107    "c_utils:utils",
108    "common_event_service:cesfwk_innerkits",
109    "data_share:datashare_common",
110    "data_share:datashare_consumer",
111    "drivers_interface_usb:libserial_proxy_1.0",
112    "drivers_interface_usb:libserial_stub_1.0",
113    "drivers_interface_usb:libusb_proxy_1.1",
114    "drivers_interface_usb:libusb_proxy_1.2",
115    "drivers_peripheral_usb:libserial_interface_service_1.0",
116    "drivers_peripheral_usb:libusb_interface_service_1.2",
117    "hilog:libhilog",
118    "hisysevent:libhisysevent",
119    "hitrace:hitrace_meter",
120    "i18n:intl_util",
121    "init:libbeget_proxy",
122    "init:libbegetutil",
123    "ipc:ipc_single",
124    "memmgr:memmgrclient",
125    "napi:ace_napi",
126    "os_account:os_account_innerkits",
127    "relational_store:native_rdb",
128    "safwk:system_ability_fwk",
129    "samgr:samgr_proxy",
130  ]
131  if (true) {
132    external_deps += [ "distributed_notification_service:ans_innerkits" ]
133  }
134  if (usb_manager_pass_through) {
135    external_deps += [
136      "drivers_interface_usb:libusb_proxy_2.0",
137      "drivers_peripheral_usb:libusb_device_interface_service_2.0",
138      "drivers_peripheral_usb:libusb_port_interface_service_2.0",
139    ]
140  }
141
142  if (usb_manager_feature_pop_up_func_switch_model) {
143    defines += [ "USB_FUNC_SWITCH_MODE" ]
144  }
145  shlib_type = "sa"
146  version_script = "usbservice.map"
147  subsystem_name = "usb"
148  part_name = "usb_manager"
149}
150
151ohos_prebuilt_etc("usb_service.init") {
152  source = "usb_service.cfg"
153  relative_install_dir = "init"
154  subsystem_name = "usb"
155  part_name = "usb_manager"
156}
157