--- third_party/libusb/BUILD.gn.orig 2019-09-16 10:03:44 UTC +++ third_party/libusb/BUILD.gn @@ -1,174 +1,24 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. +# Copyright 2016 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# libusb is only used by //services/device/usb on Windows and macOS. -assert(is_win || is_mac) +import("//build/config/linux/pkg_config.gni") +import("//build/shim_headers.gni") -import("//build/config/features.gni") - -config("libusb_config") { - include_dirs = [ "src/libusb" ] +pkg_config("system_libusb") { + packages = [ "libusb-1.0" ] } -config("libusb_linker_config") { - if (is_win) { - ldflags = [ - "/DELAYLOAD:advapi32.dll", - "/DELAYLOAD:cfgmgr32.dll", - "/DELAYLOAD:ole32.dll", - "/DELAYLOAD:setupapi.dll", - "/DELAYLOAD:winusb.dll", - ] - } +shim_headers("libusb_shim") { + root_path = "src/libusb" + headers = [ + "libusb.h", + ] } -config("libusb_warnings") { - visibility = [ ":*" ] - if (is_clang) { - # guid_eq in windows_usb.c is unused. - cflags = [ "-Wno-unused-function" ] - if (is_linux && !use_udev) { - cflags += [ "-Wno-pointer-sign" ] - } - } -} - -static_library("libusb") { - visibility = [ - "//services/device:tests", - "//services/device/usb", +source_set("libusb") { + deps = [ + ":libusb_shim", ] - sources = [ - "src/config.h", - "src/libusb/core.c", - "src/libusb/descriptor.c", - "src/libusb/hotplug.c", - "src/libusb/hotplug.h", - "src/libusb/interrupt.c", - "src/libusb/interrupt.h", - "src/libusb/io.c", - "src/libusb/libusb.h", - "src/libusb/libusbi.h", - "src/libusb/os/darwin_usb.c", - "src/libusb/os/darwin_usb.h", - "src/libusb/os/poll_posix.c", - "src/libusb/os/poll_posix.h", - "src/libusb/os/poll_windows.c", - "src/libusb/os/poll_windows.h", - "src/libusb/os/threads_posix.c", - "src/libusb/os/threads_posix.h", - "src/libusb/os/threads_windows.c", - "src/libusb/os/threads_windows.h", - "src/libusb/os/windows_common.h", - "src/libusb/os/windows_usb.c", - "src/libusb/os/windows_usb.h", - "src/libusb/strerror.c", - "src/libusb/sync.c", - "src/libusb/version.h", - "src/libusb/version_nano.h", - "src/msvc/config.h", - "src/msvc/inttypes.h", - "src/msvc/stdint.h", - ] - deps = [] - include_dirs = [ "src/libusb/os" ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - - # Must be after no_chromium_code for warning flags to be ordered correctly. - ":libusb_warnings", - ] - - public_configs = [ ":libusb_config" ] - all_dependent_configs = [ ":libusb_linker_config" ] - - if (is_posix) { - defines = [ - "DEFAULT_VISIBILITY=", - "HAVE_GETTIMEOFDAY=1", - "HAVE_POLL_H=1", - "HAVE_SYS_TIME_H=1", - "LIBUSB_DESCRIBE=\"1.0.16\"", - "POLL_NFDS_TYPE=nfds_t", - "THREADS_POSIX=1", - ] - } - - if (is_mac) { - defines += [ - "OS_DARWIN=1", - - # Needed on OSX 10.12 to silence a deprecation warning. - "OBJC_SILENCE_GC_DEPRECATIONS=1", - ] - libs = [ - "CoreFoundation.framework", - "IOKit.framework", - ] - } else { - sources -= [ - "src/libusb/os/darwin_usb.c", - "src/libusb/os/darwin_usb.h", - ] - } - - if (is_linux) { - sources += [ - "src/libusb/os/linux_usbfs.c", - "src/libusb/os/linux_usbfs.h", - ] - defines += [ - "OS_LINUX=1", - "_GNU_SOURCE=1", - ] - } - - if (is_chromeos) { - defines += [ "USBI_TIMERFD_AVAILABLE" ] - } - - if (use_udev) { - sources += [ "src/libusb/os/linux_udev.cc" ] - defines += [ - "HAVE_LIBUDEV=1", - "USE_UDEV=1", - ] - deps += [ "//build/linux/libudev" ] - } - - if (is_linux && !use_udev) { - sources += [ "src/libusb/os/linux_netlink.c" ] - defines += [ "HAVE_LINUX_NETLINK_H" ] - } - - if (is_win) { - include_dirs += [ "src/msvc" ] - sources -= [ - "src/libusb/os/poll_posix.c", - "src/libusb/os/threads_posix.c", - ] - libs = [ - "advapi32.lib", - "ole32.lib", - "setupapi.lib", - "winusb.lib", - ] - } else { - include_dirs += [ "src" ] - sources -= [ - "src/libusb/os/poll_windows.c", - "src/libusb/os/poll_windows.h", - "src/libusb/os/threads_windows.c", - "src/libusb/os/threads_windows.h", - "src/libusb/os/windows_common.h", - "src/libusb/os/windows_usb.c", - "src/libusb/os/windows_usb.h", - "src/msvc/config.h", - "src/msvc/inttypes.h", - "src/msvc/stdint.h", - ] - } + public_configs = [ ":system_libusb" ] }