Permission message rules: Each rule must have >= 1 required permissions
[chromium-blink-merge.git] / third_party / libusb / BUILD.gn
blob82aeabd3790b918739d20f690143322320ec31cc
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 assert(!is_android && !is_ios)
7 import("//build/config/features.gni")
9 config("libusb_config") {
10   include_dirs = [ "src/libusb" ]
13 config("libusb_warnings") {
14   visibility = [ ":*" ]
15   if (is_clang) {
16     # guid_eq in windows_usb.c is unused.
17     cflags = [ "-Wno-unused-function" ]
18     if (is_linux && !use_udev) {
19       cflags += [ "-Wno-pointer-sign" ]
20     }
21   }
24 static_library("libusb") {
25   sources = [
26     "src/config.h",
27     "src/libusb/core.c",
28     "src/libusb/descriptor.c",
29     "src/libusb/hotplug.c",
30     "src/libusb/hotplug.h",
31     "src/libusb/interrupt.c",
32     "src/libusb/interrupt.h",
33     "src/libusb/io.c",
34     "src/libusb/libusb.h",
35     "src/libusb/libusbi.h",
36     "src/libusb/os/darwin_usb.c",
37     "src/libusb/os/darwin_usb.h",
38     "src/libusb/os/poll_posix.c",
39     "src/libusb/os/poll_posix.h",
40     "src/libusb/os/poll_windows.c",
41     "src/libusb/os/poll_windows.h",
42     "src/libusb/os/threads_posix.c",
43     "src/libusb/os/threads_posix.h",
44     "src/libusb/os/threads_windows.c",
45     "src/libusb/os/threads_windows.h",
46     "src/libusb/os/windows_common.h",
47     "src/libusb/os/windows_usb.c",
48     "src/libusb/os/windows_usb.h",
49     "src/libusb/strerror.c",
50     "src/libusb/sync.c",
51     "src/libusb/version.h",
52     "src/libusb/version_nano.h",
53     "src/msvc/config.h",
54     "src/msvc/inttypes.h",
55     "src/msvc/stdint.h",
56   ]
57   deps = []
58   include_dirs = [ "src/libusb/os" ]
60   configs -= [ "//build/config/compiler:chromium_code" ]
61   configs += [ "//build/config/compiler:no_chromium_code" ]
62   configs += [ ":libusb_warnings" ]
64   public_configs = [ ":libusb_config" ]
66   if (is_posix) {
67     defines = [
68       "DEFAULT_VISIBILITY=",
69       "HAVE_GETTIMEOFDAY=1",
70       "HAVE_POLL_H=1",
71       "HAVE_SYS_TIME_H=1",
72       "LIBUSB_DESCRIBE=\"1.0.16\"",
73       "POLL_NFDS_TYPE=nfds_t",
74       "THREADS_POSIX=1",
75     ]
76   }
78   if (is_mac) {
79     defines += [ "OS_DARWIN=1" ]
80   } else {
81     sources -= [
82       "src/libusb/os/darwin_usb.c",
83       "src/libusb/os/darwin_usb.h",
84     ]
85   }
87   if (is_linux) {
88     sources += [
89       "src/libusb/os/linux_usbfs.c",
90       "src/libusb/os/linux_usbfs.h",
91     ]
92     defines += [
93       "OS_LINUX=1",
94       "_GNU_SOURCE=1",
95     ]
96   }
98   if (use_udev) {
99     sources += [ "src/libusb/os/linux_udev.cc" ]
100     defines += [
101       "HAVE_LIBUDEV=1",
102       "USE_UDEV=1",
103     ]
104     deps += [ "//build/linux:udev" ]
105   }
107   if (is_linux && !use_udev) {
108     sources += [ "src/libusb/os/linux_netlink.c" ]
109     defines += [ "HAVE_LINUX_NETLINK_H" ]
110   }
112   if (is_win) {
113     include_dirs += [ "src/msvc" ]
114     sources -= [
115       "src/libusb/os/poll_posix.c",
116       "src/libusb/os/threads_posix.c",
117     ]
118     libs = [ "setupapi.lib" ]
119   } else {
120     include_dirs += [ "src" ]
121     sources -= [
122       "src/libusb/os/poll_windows.c",
123       "src/libusb/os/poll_windows.h",
124       "src/libusb/os/threads_windows.c",
125       "src/libusb/os/threads_windows.h",
126       "src/libusb/os/windows_common.h",
127       "src/libusb/os/windows_usb.c",
128       "src/libusb/os/windows_usb.h",
129       "src/msvc/config.h",
130       "src/msvc/inttypes.h",
131       "src/msvc/stdint.h",
132     ]
133   }