Roll src/third_party/WebKit 787a07c:716df21 (svn 201034:201036)
[chromium-blink-merge.git] / third_party / libusb / BUILD.gn
blobc7f4083d6b7b09d9d782e9fbae3d5d491a3baeb5
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 static_library("libusb") {
14   sources = [
15     "src/config.h",
16     "src/libusb/core.c",
17     "src/libusb/descriptor.c",
18     "src/libusb/hotplug.c",
19     "src/libusb/hotplug.h",
20     "src/libusb/interrupt.c",
21     "src/libusb/interrupt.h",
22     "src/libusb/io.c",
23     "src/libusb/libusb.h",
24     "src/libusb/libusbi.h",
25     "src/libusb/os/darwin_usb.c",
26     "src/libusb/os/darwin_usb.h",
27     "src/libusb/os/poll_posix.c",
28     "src/libusb/os/poll_posix.h",
29     "src/libusb/os/poll_windows.c",
30     "src/libusb/os/poll_windows.h",
31     "src/libusb/os/threads_posix.c",
32     "src/libusb/os/threads_posix.h",
33     "src/libusb/os/threads_windows.c",
34     "src/libusb/os/threads_windows.h",
35     "src/libusb/os/windows_common.h",
36     "src/libusb/os/windows_usb.c",
37     "src/libusb/os/windows_usb.h",
38     "src/libusb/strerror.c",
39     "src/libusb/sync.c",
40     "src/libusb/version.h",
41     "src/libusb/version_nano.h",
42     "src/msvc/config.h",
43     "src/msvc/inttypes.h",
44     "src/msvc/stdint.h",
45   ]
46   deps = []
47   include_dirs = [ "src/libusb/os" ]
49   config("libusb_warnings") {
50     if (is_clang) {
51       # guid_eq in windows_usb.c is unused.
52       cflags = [ "-Wno-unused-function" ]
53       if (is_linux && !use_udev) {
54         cflags += [ "-Wno-pointer-sign" ]
55       }
56     }
57   }
58   configs -= [ "//build/config/compiler:chromium_code" ]
59   configs += [ "//build/config/compiler:no_chromium_code" ]
60   configs += [ ":libusb_warnings" ]
62   public_configs = [ ":libusb_config" ]
64   if (is_posix) {
65     defines = [
66       "DEFAULT_VISIBILITY=",
67       "HAVE_GETTIMEOFDAY=1",
68       "HAVE_POLL_H=1",
69       "HAVE_SYS_TIME_H=1",
70       "LIBUSB_DESCRIBE=\"1.0.16\"",
71       "POLL_NFDS_TYPE=nfds_t",
72       "THREADS_POSIX=1",
73     ]
74   }
76   if (is_mac) {
77     defines += [ "OS_DARWIN=1" ]
78   } else {
79     sources -= [
80       "src/libusb/os/darwin_usb.c",
81       "src/libusb/os/darwin_usb.h",
82     ]
83   }
85   if (is_linux) {
86     sources += [
87       "src/libusb/os/linux_usbfs.c",
88       "src/libusb/os/linux_usbfs.h",
89     ]
90     defines += [
91       "OS_LINUX=1",
92       "_GNU_SOURCE=1",
93     ]
94   }
96   if (use_udev) {
97     sources += [ "src/libusb/os/linux_udev.cc" ]
98     defines += [
99       "HAVE_LIBUDEV=1",
100       "USE_UDEV=1",
101     ]
102     deps += [ "//build/config/linux:udev" ]
103   }
105   if (is_linux && !use_udev) {
106     sources += [ "src/libusb/os/linux_netlink.c" ]
107     defines += [ "HAVE_LINUX_NETLINK_H" ]
108   }
110   if (is_win) {
111     include_dirs += [ "src/msvc" ]
112     sources -= [
113       "src/libusb/os/poll_posix.c",
114       "src/libusb/os/threads_posix.c",
115     ]
116     libs = [ "setupapi.lib" ]
117   } else {
118     include_dirs += [ "src" ]
119     sources -= [
120       "src/libusb/os/poll_windows.c",
121       "src/libusb/os/poll_windows.h",
122       "src/libusb/os/threads_windows.c",
123       "src/libusb/os/threads_windows.h",
124       "src/libusb/os/windows_common.h",
125       "src/libusb/os/windows_usb.c",
126       "src/libusb/os/windows_usb.h",
127       "src/msvc/config.h",
128       "src/msvc/inttypes.h",
129       "src/msvc/stdint.h",
130     ]
131   }