1# Copyright (c) 2021 Huawei Device Co., Ltd. 2# 3# Permission is hereby granted, free of charge, to any person obtaining a copy 4# of this software and associated documentation files (the "Software"), to 5# deal in the Software without restriction, including without limitation the 6# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7# sell copies of the Software, and to permit persons to whom the Software is 8# furnished to do so, subject to the following conditions: 9# 10# The above copyright notice and this permission notice shall be included in 11# all copies or substantial portions of the Software. 12# 13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19# IN THE SOFTWARE. 20 21import("//build/ohos.gni") 22 23common_source = [ 24 "libusb/core.c", 25 "libusb/descriptor.c", 26 "libusb/hotplug.c", 27 "libusb/io.c", 28 "libusb/sync.c", 29 "libusb/strerror.c", 30] 31 32# Configuration for libusb itself. 33config("libusb_config") { 34 include_dirs = [ 35 "include", 36 "libusb", 37 "libusb/os", 38 ] 39 cflags = [ 40 "-U__ANDROID__", 41 "-UUSE_UDEV", 42 "-Wno-#warnings", 43 "-Wno-error=sign-compare", 44 "-Wno-error=switch", 45 "-Wno-error=pragma-pack", 46 ] 47 if (is_linux || is_ohos) { 48 include_dirs += [ "linux" ] 49 cflags += [ "-DPLATFORM_POSIX" ] 50 } else if (is_mingw || is_win) { 51 cflags += [ 52 "-Werror", 53 "-Wno-unused-function", 54 "-Wno-unused-parameter", 55 "-DPLATFORM_WINDOWS", 56 ] 57 include_dirs += [ "windows" ] 58 } else if (is_mac) { 59 cflags += [ 60 "-Wno-unused-parameter", 61 "-Wno-deprecated-declarations", 62 "-DPLATFORM_POSIX", 63 ] 64 include_dirs += [ "darwin" ] 65 libs = [ 66 "CoreFoundation.framework", 67 "IOKit.framework", 68 "objc", 69 ] 70 } 71} 72 73ohos_source_set("libusb_source") { 74 configs = [ ":libusb_config" ] 75 sources = common_source 76 77 if (is_mac) { 78 sources += [ 79 "libusb/os/darwin_usb.c", 80 "libusb/os/events_posix.c", 81 "libusb/os/threads_posix.c", 82 ] 83 } else if (is_mingw || is_win) { 84 sources += [ 85 "libusb/os/events_windows.c", 86 "libusb/os/threads_windows.c", 87 "libusb/os/windows_common.c", 88 "libusb/os/windows_usbdk.c", 89 "libusb/os/windows_winusb.c", 90 ] 91 } else if (is_linux || is_ohos) { 92 sources += [ 93 "libusb/os/events_posix.c", 94 "libusb/os/linux_netlink.c", 95 "libusb/os/linux_usbfs.c", 96 "libusb/os/threads_posix.c", 97 ] 98 } 99} 100 101config("libusb_public_config") { 102 include_dirs = [ "./" ] 103} 104 105ohos_shared_library("libusb") { 106 deps = [ ":libusb_source" ] 107 public_configs = [ ":libusb_public_config" ] 108 output_name = "libusb_shared" 109} 110