Skip to content

Commit 4273c8e

Browse files
committed
Bundle libusb as a submodule
1 parent ca4c6d4 commit 4273c8e

File tree

4 files changed

+127
-46
lines changed

4 files changed

+127
-46
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "libusb"]
2+
path = libusb
3+
url = https://github.com/kevinmehall/libusb.git

binding.gyp

Lines changed: 122 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
'variables': {
33
'target_arch%': 'ia32', # built for a 32-bit CPU by default
4+
'use_udev%': 1,
45
},
56
'targets': [
67
{
@@ -21,26 +22,16 @@
2122
'src/',
2223
"<!(node -e \"require('nan')\")",
2324
],
25+
'dependencies': [
26+
'libusb',
27+
],
2428
'conditions' : [
2529
['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-
],
3230
'defines': [
3331
#'USE_POLL',
3432
]
3533
}],
3634
['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-
],
4435
'xcode_settings': {
4536
'OTHER_CFLAGS': [ '--std=c++1y' ],
4637
'OTHER_LDFLAGS': [ '-framework', 'CoreFoundation', '-framework', 'IOKit' ],
@@ -49,17 +40,9 @@
4940
},
5041
}],
5142
['OS=="win"', {
52-
'variables': {
53-
# Path to extracted libusbx windows binary package from http://libusbx.org/
54-
'libusb_path': "C:/Program Files/libusb"
55-
},
5643
'defines':[
5744
'WIN32_LEAN_AND_MEAN'
5845
],
59-
'include_dirs+': [
60-
'<(libusb_path)/include/libusbx-1.0',
61-
'<(libusb_path)/include/libusb-1.0',
62-
],
6346
'default_configuration': 'Debug',
6447
'configurations': {
6548
'Debug': {
@@ -84,32 +67,125 @@
8467
'AdditionalOptions': [ '/EHsc' ],
8568
},
8669
},
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-
]
11170
}]
11271
]
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+
},
114190
]
115191
}

libusb

Submodule libusb added at 0c3d17c

libusb_config/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Nothing. Configured by gyp. */

0 commit comments

Comments
 (0)