|
1 | 1 | { |
2 | 2 | 'variables': { |
3 | 3 | 'target_arch%': 'ia32', # built for a 32-bit CPU by default |
| 4 | + 'use_udev%': 1, |
4 | 5 | }, |
5 | 6 | 'targets': [ |
6 | 7 | { |
|
21 | 22 | 'src/', |
22 | 23 | "<!(node -e \"require('nan')\")", |
23 | 24 | ], |
| 25 | + 'dependencies': [ |
| 26 | + 'libusb', |
| 27 | + ], |
24 | 28 | 'conditions' : [ |
25 | 29 | ['OS=="linux"', { |
26 | | - 'include_dirs+': [ |
27 | | - '<!@(pkg-config libusb-1.0 --cflags-only-I | sed s/-I//g)' |
28 | | - ], |
29 | | - 'libraries': [ |
30 | | - '<!@(pkg-config libusb-1.0 --libs)' |
31 | | - ], |
32 | 30 | 'defines': [ |
33 | 31 | #'USE_POLL', |
34 | 32 | ] |
35 | 33 | }], |
36 | 34 | ['OS=="mac"', { |
37 | | - 'include_dirs+': [ |
38 | | - '<!@(pkg-config libusb-1.0 --cflags-only-I | sed s/-I//g)' |
39 | | - ], |
40 | | - 'libraries': [ |
41 | | - # Force static library linkage |
42 | | - '<!@(pkg-config libusb-1.0 --libs | sed s/-L//g | sed "s/ -l/\/lib/g").a' |
43 | | - ], |
44 | 35 | 'xcode_settings': { |
45 | 36 | 'OTHER_CFLAGS': [ '--std=c++1y' ], |
46 | 37 | 'OTHER_LDFLAGS': [ '-framework', 'CoreFoundation', '-framework', 'IOKit' ], |
|
49 | 40 | }, |
50 | 41 | }], |
51 | 42 | ['OS=="win"', { |
52 | | - 'variables': { |
53 | | - # Path to extracted libusbx windows binary package from http://libusbx.org/ |
54 | | - 'libusb_path': "C:/Program Files/libusb" |
55 | | - }, |
56 | 43 | 'defines':[ |
57 | 44 | 'WIN32_LEAN_AND_MEAN' |
58 | 45 | ], |
59 | | - 'include_dirs+': [ |
60 | | - '<(libusb_path)/include/libusbx-1.0', |
61 | | - '<(libusb_path)/include/libusb-1.0', |
62 | | - ], |
63 | 46 | 'default_configuration': 'Debug', |
64 | 47 | 'configurations': { |
65 | 48 | 'Debug': { |
|
84 | 67 | 'AdditionalOptions': [ '/EHsc' ], |
85 | 68 | }, |
86 | 69 | }, |
87 | | - "conditions" : [ |
88 | | - ["target_arch=='ia32'", { |
89 | | - 'libraries': [ |
90 | | - '<(libusb_path)/MS32/dll/libusb-1.0.lib' |
91 | | - ], |
92 | | - "copies": [ |
93 | | - { |
94 | | - "destination": "<(PRODUCT_DIR)", |
95 | | - 'files': [ '<(libusb_path)/MS32/dll/libusb-1.0.dll' ] |
96 | | - } |
97 | | - ] |
98 | | - }], |
99 | | - ["target_arch=='x64'", { |
100 | | - 'libraries': [ |
101 | | - '<(libusb_path)/MS64/dll/libusb-1.0.lib' |
102 | | - ], |
103 | | - "copies": [ |
104 | | - { |
105 | | - "destination": "<(PRODUCT_DIR)", |
106 | | - 'files': [ '<(libusb_path)/MS64/dll/libusb-1.0.dll' ] |
107 | | - } |
108 | | - ] |
109 | | - }] |
110 | | - ] |
111 | 70 | }] |
112 | 71 | ] |
113 | | - } |
| 72 | + }, |
| 73 | + { |
| 74 | + # Based on https://chromium.googlesource.com/chromium/src/+/master/third_party/libusb/libusb.gyp |
| 75 | + 'target_name': 'libusb', |
| 76 | + 'type': 'static_library', |
| 77 | + 'sources': [ |
| 78 | + 'libusb_config/config.h', |
| 79 | + 'libusb/libusb/core.c', |
| 80 | + 'libusb/libusb/descriptor.c', |
| 81 | + 'libusb/libusb/hotplug.c', |
| 82 | + 'libusb/libusb/hotplug.h', |
| 83 | + 'libusb/libusb/io.c', |
| 84 | + 'libusb/libusb/libusb.h', |
| 85 | + 'libusb/libusb/libusbi.h', |
| 86 | + 'libusb/libusb/strerror.c', |
| 87 | + 'libusb/libusb/sync.c', |
| 88 | + 'libusb/libusb/version.h', |
| 89 | + 'libusb/libusb/version_nano.h', |
| 90 | + ], |
| 91 | + 'include_dirs': [ |
| 92 | + 'libusb_config', |
| 93 | + 'libusb/libusb', |
| 94 | + 'libusb/libusb/os', |
| 95 | + ], |
| 96 | + 'direct_dependent_settings': { |
| 97 | + 'include_dirs': [ |
| 98 | + 'libusb/libusb', |
| 99 | + ], |
| 100 | + }, |
| 101 | + 'conditions': [ |
| 102 | + [ 'OS == "linux" or OS == "android" or OS == "mac"', { |
| 103 | + 'sources': [ |
| 104 | + 'libusb/libusb/os/poll_posix.c', |
| 105 | + 'libusb/libusb/os/poll_posix.h', |
| 106 | + 'libusb/libusb/os/threads_posix.c', |
| 107 | + 'libusb/libusb/os/threads_posix.h', |
| 108 | + ], |
| 109 | + 'defines': [ |
| 110 | + 'DEFAULT_VISIBILITY=', |
| 111 | + 'HAVE_GETTIMEOFDAY=1', |
| 112 | + 'HAVE_POLL_H=1', |
| 113 | + 'HAVE_SYS_TIME_H=1', |
| 114 | + 'LIBUSB_DESCRIBE="1.0.17"', |
| 115 | + 'POLL_NFDS_TYPE=nfds_t', |
| 116 | + 'THREADS_POSIX=1', |
| 117 | + ], |
| 118 | + }], |
| 119 | + [ 'OS == "linux" or OS == "android"', { |
| 120 | + 'sources': [ |
| 121 | + 'libusb/libusb/os/linux_usbfs.c', |
| 122 | + 'libusb/libusb/os/linux_usbfs.h', |
| 123 | + ], |
| 124 | + 'defines': [ |
| 125 | + 'OS_LINUX=1', |
| 126 | + '_GNU_SOURCE=1', |
| 127 | + ], |
| 128 | + }], |
| 129 | + [ 'OS == "linux" and use_udev == 1 or OS == "android"', { |
| 130 | + 'sources': [ |
| 131 | + 'libusb/libusb/os/linux_udev.c', |
| 132 | + ], |
| 133 | + 'defines': [ |
| 134 | + 'HAVE_LIBUDEV=1', |
| 135 | + 'USE_UDEV=1', |
| 136 | + ], |
| 137 | + 'direct_dependent_settings': { |
| 138 | + 'libraries': [ |
| 139 | + '-ludev', |
| 140 | + ] |
| 141 | + } |
| 142 | + }], |
| 143 | + [ 'OS == "linux" and use_udev == 0', { |
| 144 | + 'sources': [ |
| 145 | + 'libusb/libusb/os/linux_netlink.c', |
| 146 | + ], |
| 147 | + 'defines': [ |
| 148 | + 'HAVE_LINUX_NETLINK_H', |
| 149 | + ], |
| 150 | + 'conditions': [ |
| 151 | + ['clang==1', { |
| 152 | + 'cflags': [ |
| 153 | + '-Wno-pointer-sign', |
| 154 | + ] |
| 155 | + }] |
| 156 | + ], |
| 157 | + }], |
| 158 | + [ 'OS == "mac"', { |
| 159 | + 'sources': [ |
| 160 | + 'libusb/libusb/os/darwin_usb.c', |
| 161 | + 'libusb/libusb/os/darwin_usb.h', |
| 162 | + ], |
| 163 | + 'defines': [ |
| 164 | + 'OS_DARWIN=1', |
| 165 | + ], |
| 166 | + }], |
| 167 | + [ 'OS == "win"', { |
| 168 | + 'sources': [ |
| 169 | + 'libusb/libusb/os/poll_windows.c', |
| 170 | + 'libusb/libusb/os/poll_windows.h', |
| 171 | + 'libusb/libusb/os/threads_windows.c', |
| 172 | + 'libusb/libusb/os/threads_windows.h', |
| 173 | + 'libusb/libusb/os/windows_common.h', |
| 174 | + 'libusb/libusb/os/windows_usb.c', |
| 175 | + 'libusb/libusb/os/windows_usb.h', |
| 176 | + 'libusb/msvc/config.h', |
| 177 | + 'libusb/msvc/inttypes.h', |
| 178 | + 'libusb/msvc/stdint.h', |
| 179 | + ], |
| 180 | + 'include_dirs!': [ |
| 181 | + 'libusb_config', |
| 182 | + ], |
| 183 | + 'include_dirs': [ |
| 184 | + 'libusb/msvc', |
| 185 | + ], |
| 186 | + 'msvs_disabled_warnings': [ 4267 ], |
| 187 | + }], |
| 188 | + ], |
| 189 | + }, |
114 | 190 | ] |
115 | 191 | } |
0 commit comments