libusb 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +8 -2
- data/Gemfile +2 -0
- data/History.md +12 -0
- data/README.md +25 -14
- data/Rakefile +64 -109
- data/appveyor.yml +23 -0
- data/ext/extconf.rb +10 -12
- data/ext/libusb_recipe.rb +29 -0
- data/lib/libusb/call.rb +14 -11
- data/lib/libusb/compat.rb +9 -9
- data/lib/libusb/context.rb +16 -1
- data/lib/libusb/dependencies.rb +7 -0
- data/lib/libusb/dev_handle.rb +13 -3
- data/lib/libusb/eventmachine.rb +4 -4
- data/lib/libusb/transfer.rb +71 -10
- data/lib/libusb/version_gem.rb +1 -1
- data/libusb.gemspec +7 -5
- data/ports/archives/libusb-1.0.21.tar.bz2 +0 -0
- data/test/test_libusb_bulk_stream_transfer.rb +1 -1
- data/test/test_libusb_descriptors.rb +4 -4
- data/test/test_libusb_event_machine.rb +7 -7
- data/test/test_libusb_hotplug.rb +15 -3
- data/test/test_libusb_iso_transfer.rb +1 -1
- data/test/test_libusb_mass_storage.rb +19 -19
- data/test/test_libusb_mass_storage2.rb +1 -1
- data/test/test_libusb_structs.rb +13 -0
- data/test/test_libusb_threads.rb +2 -2
- data/wireshark-usb-sniffer.png +0 -0
- metadata +32 -156
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ext/libusb-1.0.20/AUTHORS +0 -89
- data/ext/libusb-1.0.20/COPYING +0 -504
- data/ext/libusb-1.0.20/ChangeLog +0 -227
- data/ext/libusb-1.0.20/INSTALL +0 -234
- data/ext/libusb-1.0.20/Makefile.am +0 -28
- data/ext/libusb-1.0.20/Makefile.in +0 -897
- data/ext/libusb-1.0.20/NEWS +0 -2
- data/ext/libusb-1.0.20/PORTING +0 -94
- data/ext/libusb-1.0.20/README +0 -29
- data/ext/libusb-1.0.20/TODO +0 -2
- data/ext/libusb-1.0.20/Xcode/common.xcconfig +0 -49
- data/ext/libusb-1.0.20/Xcode/config.h +0 -28
- data/ext/libusb-1.0.20/Xcode/debug.xcconfig +0 -29
- data/ext/libusb-1.0.20/Xcode/libusb.xcconfig +0 -21
- data/ext/libusb-1.0.20/Xcode/libusb.xcodeproj/project.pbxproj +0 -865
- data/ext/libusb-1.0.20/Xcode/libusb_debug.xcconfig +0 -21
- data/ext/libusb-1.0.20/Xcode/libusb_release.xcconfig +0 -21
- data/ext/libusb-1.0.20/Xcode/release.xcconfig +0 -30
- data/ext/libusb-1.0.20/aclocal.m4 +0 -1193
- data/ext/libusb-1.0.20/android/README +0 -114
- data/ext/libusb-1.0.20/android/config.h +0 -81
- data/ext/libusb-1.0.20/android/jni/Android.mk +0 -23
- data/ext/libusb-1.0.20/android/jni/Application.mk +0 -24
- data/ext/libusb-1.0.20/android/jni/examples.mk +0 -134
- data/ext/libusb-1.0.20/android/jni/libusb.mk +0 -54
- data/ext/libusb-1.0.20/android/jni/tests.mk +0 -56
- data/ext/libusb-1.0.20/compile +0 -347
- data/ext/libusb-1.0.20/config.guess +0 -1421
- data/ext/libusb-1.0.20/config.h.in +0 -155
- data/ext/libusb-1.0.20/config.sub +0 -1807
- data/ext/libusb-1.0.20/configure +0 -15466
- data/ext/libusb-1.0.20/configure.ac +0 -326
- data/ext/libusb-1.0.20/depcomp +0 -791
- data/ext/libusb-1.0.20/doc/Makefile.am +0 -9
- data/ext/libusb-1.0.20/doc/Makefile.in +0 -456
- data/ext/libusb-1.0.20/doc/doxygen.cfg.in +0 -2334
- data/ext/libusb-1.0.20/examples/Makefile.am +0 -19
- data/ext/libusb-1.0.20/examples/Makefile.in +0 -713
- data/ext/libusb-1.0.20/examples/dpfp.c +0 -506
- data/ext/libusb-1.0.20/examples/dpfp_threaded.c +0 -549
- data/ext/libusb-1.0.20/examples/ezusb.c +0 -831
- data/ext/libusb-1.0.20/examples/ezusb.h +0 -120
- data/ext/libusb-1.0.20/examples/fxload.c +0 -308
- data/ext/libusb-1.0.20/examples/getopt/getopt.c +0 -1060
- data/ext/libusb-1.0.20/examples/getopt/getopt.h +0 -180
- data/ext/libusb-1.0.20/examples/getopt/getopt1.c +0 -188
- data/ext/libusb-1.0.20/examples/hotplugtest.c +0 -122
- data/ext/libusb-1.0.20/examples/listdevs.c +0 -71
- data/ext/libusb-1.0.20/examples/sam3u_benchmark.c +0 -193
- data/ext/libusb-1.0.20/examples/xusb.c +0 -1130
- data/ext/libusb-1.0.20/install-sh +0 -501
- data/ext/libusb-1.0.20/libusb-1.0.pc.in +0 -11
- data/ext/libusb-1.0.20/libusb/Makefile.am +0 -90
- data/ext/libusb-1.0.20/libusb/Makefile.in +0 -1053
- data/ext/libusb-1.0.20/libusb/core.c +0 -2452
- data/ext/libusb-1.0.20/libusb/descriptor.c +0 -1201
- data/ext/libusb-1.0.20/libusb/hotplug.c +0 -344
- data/ext/libusb-1.0.20/libusb/hotplug.h +0 -90
- data/ext/libusb-1.0.20/libusb/io.c +0 -2760
- data/ext/libusb-1.0.20/libusb/libusb-1.0.def +0 -168
- data/ext/libusb-1.0.20/libusb/libusb-1.0.rc +0 -61
- data/ext/libusb-1.0.20/libusb/libusb.h +0 -1999
- data/ext/libusb-1.0.20/libusb/libusbi.h +0 -1102
- data/ext/libusb-1.0.20/libusb/os/darwin_usb.c +0 -1969
- data/ext/libusb-1.0.20/libusb/os/darwin_usb.h +0 -158
- data/ext/libusb-1.0.20/libusb/os/haiku/Makefile.am +0 -5
- data/ext/libusb-1.0.20/libusb/os/haiku/Makefile.in +0 -810
- data/ext/libusb-1.0.20/libusb/os/haiku/aclocal.m4 +0 -1193
- data/ext/libusb-1.0.20/libusb/os/haiku/compile +0 -347
- data/ext/libusb-1.0.20/libusb/os/haiku/config.guess +0 -1421
- data/ext/libusb-1.0.20/libusb/os/haiku/config.sub +0 -1807
- data/ext/libusb-1.0.20/libusb/os/haiku/configure +0 -17579
- data/ext/libusb-1.0.20/libusb/os/haiku/configure.ac +0 -8
- data/ext/libusb-1.0.20/libusb/os/haiku/depcomp +0 -791
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_pollfs.cpp +0 -378
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb.h +0 -112
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_backend.cpp +0 -550
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_raw.cpp +0 -255
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_raw.h +0 -180
- data/ext/libusb-1.0.20/libusb/os/haiku/install-sh +0 -501
- data/ext/libusb-1.0.20/libusb/os/haiku/ltmain.sh +0 -9655
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/libtool.m4 +0 -7992
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/ltoptions.m4 +0 -384
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/ltsugar.m4 +0 -123
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/ltversion.m4 +0 -23
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/lt~obsolete.m4 +0 -98
- data/ext/libusb-1.0.20/libusb/os/haiku/missing +0 -215
- data/ext/libusb-1.0.20/libusb/os/linux_netlink.c +0 -369
- data/ext/libusb-1.0.20/libusb/os/linux_udev.c +0 -306
- data/ext/libusb-1.0.20/libusb/os/linux_usbfs.c +0 -2692
- data/ext/libusb-1.0.20/libusb/os/linux_usbfs.h +0 -192
- data/ext/libusb-1.0.20/libusb/os/netbsd_usb.c +0 -674
- data/ext/libusb-1.0.20/libusb/os/openbsd_usb.c +0 -768
- data/ext/libusb-1.0.20/libusb/os/poll_posix.c +0 -53
- data/ext/libusb-1.0.20/libusb/os/poll_posix.h +0 -11
- data/ext/libusb-1.0.20/libusb/os/poll_windows.c +0 -728
- data/ext/libusb-1.0.20/libusb/os/poll_windows.h +0 -131
- data/ext/libusb-1.0.20/libusb/os/threads_posix.c +0 -82
- data/ext/libusb-1.0.20/libusb/os/threads_posix.h +0 -50
- data/ext/libusb-1.0.20/libusb/os/threads_windows.c +0 -214
- data/ext/libusb-1.0.20/libusb/os/threads_windows.h +0 -87
- data/ext/libusb-1.0.20/libusb/os/wince_usb.c +0 -869
- data/ext/libusb-1.0.20/libusb/os/wince_usb.h +0 -131
- data/ext/libusb-1.0.20/libusb/os/windows_common.h +0 -108
- data/ext/libusb-1.0.20/libusb/os/windows_usb.c +0 -4643
- data/ext/libusb-1.0.20/libusb/os/windows_usb.h +0 -973
- data/ext/libusb-1.0.20/libusb/strerror.c +0 -202
- data/ext/libusb-1.0.20/libusb/sync.c +0 -308
- data/ext/libusb-1.0.20/libusb/version.h +0 -18
- data/ext/libusb-1.0.20/libusb/version_nano.h +0 -1
- data/ext/libusb-1.0.20/ltmain.sh +0 -9655
- data/ext/libusb-1.0.20/m4/libtool.m4 +0 -7992
- data/ext/libusb-1.0.20/m4/ltoptions.m4 +0 -384
- data/ext/libusb-1.0.20/m4/ltsugar.m4 +0 -123
- data/ext/libusb-1.0.20/m4/ltversion.m4 +0 -23
- data/ext/libusb-1.0.20/m4/lt~obsolete.m4 +0 -98
- data/ext/libusb-1.0.20/missing +0 -215
- data/ext/libusb-1.0.20/tests/Makefile.am +0 -6
- data/ext/libusb-1.0.20/tests/Makefile.in +0 -596
- data/ext/libusb-1.0.20/tests/libusb_testlib.h +0 -107
- data/ext/libusb-1.0.20/tests/stress.c +0 -160
- data/ext/libusb-1.0.20/tests/testlib.c +0 -277
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5e5f9e0c5d8b081434798fc6043348862276ed6c
|
|
4
|
+
data.tar.gz: d7d1324fd8f0718c83abd011cf2840b8259cfda5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bcff1f67a785ea9b9605c031153fec3c457bb5b33c283ac3c0228a1d78c20050922cf798fb2d3dc75c3676702f9e97c99a4a5fae0f036e0fbce1e138f5527155
|
|
7
|
+
data.tar.gz: d11ed544f2813e8c221b232e19b6ad393c94a31dc9d0e66995c0f5dc28cb4261cb61b391bfd8e1096fe47ae681066cf5bf668e71f717106717233b573bb0d40b
|
data/.travis.yml
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
language: ruby
|
|
2
2
|
sudo: false
|
|
3
3
|
rvm:
|
|
4
|
-
- "1.8.7"
|
|
5
4
|
- "1.9.3"
|
|
6
5
|
- "2.0.0"
|
|
7
6
|
- "2.1"
|
|
8
7
|
- "2.2"
|
|
9
|
-
-
|
|
8
|
+
- "2.3.1"
|
|
9
|
+
- "2.3.1-clang"
|
|
10
|
+
- jruby-1.7.26
|
|
11
|
+
- jruby-9.1.5.0
|
|
10
12
|
- rbx
|
|
13
|
+
matrix:
|
|
14
|
+
allow_failures:
|
|
15
|
+
- rvm: rbx
|
|
16
|
+
- rvm: "2.3.1-clang"
|
|
11
17
|
script: bundle exec rake travis
|
data/Gemfile
CHANGED
data/History.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
0.6.0 / 2016-12-09
|
|
2
|
+
------------------
|
|
3
|
+
* Update bundled libusb version to 1.0.21.
|
|
4
|
+
* Set minimum Ruby version requirement to 1.9.3.
|
|
5
|
+
* Add binary gems for Linux in addition to Windows.
|
|
6
|
+
* Switch to mini_portile2 for (cross-) builing the libusb library.
|
|
7
|
+
* Add Context#interrupt_event_handler new in libusb-1.0.21
|
|
8
|
+
* Add support for persistent/zerocopy device memory for transfers.
|
|
9
|
+
It is new in libusb-1.0.21 and enabled by default for DevHandle#*_transfer methods.
|
|
10
|
+
* Raise a more meaningful exception in case of bulk stream transfers on too old libusb versions.
|
|
11
|
+
* Prefer the bundled libusb-dll over installed system library.
|
|
12
|
+
|
|
1
13
|
0.5.1 / 2015-09-29
|
|
2
14
|
------------------
|
|
3
15
|
* Add ability to force use of the system or builtin libusb-1.0 library.
|
data/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<!-- -*- coding: utf-8 -*- -->
|
|
2
2
|
|
|
3
3
|
[](https://travis-ci.org/larskanis/libusb)
|
|
4
|
+
[](https://ci.appveyor.com/project/larskanis/libusb)
|
|
4
5
|
|
|
5
6
|
Access USB devices from Ruby
|
|
6
7
|
============================
|
|
@@ -23,15 +24,13 @@ Features
|
|
|
23
24
|
|
|
24
25
|
Synopsis
|
|
25
26
|
--------
|
|
26
|
-
See [the documentation](http://rubydoc.info/gems/libusb/frames) for a full API description.
|
|
27
|
-
|
|
28
27
|
```ruby
|
|
29
28
|
require "libusb"
|
|
30
29
|
|
|
31
30
|
usb = LIBUSB::Context.new
|
|
32
|
-
device = usb.devices(:
|
|
31
|
+
device = usb.devices(idVendor: 0x04b4, idProduct: 0x8613).first
|
|
33
32
|
device.open_interface(0) do |handle|
|
|
34
|
-
handle.control_transfer(:
|
|
33
|
+
handle.control_transfer(bmRequestType: 0x40, bRequest: 0xa0, wValue: 0xe600, wIndex: 0x0000, dataOut: 1.chr)
|
|
35
34
|
end
|
|
36
35
|
```
|
|
37
36
|
{LIBUSB::Context#devices} is used to get all or only particular devices.
|
|
@@ -55,18 +54,20 @@ Each {LIBUSB::Setting} specifies it's own set of communication endpoints.
|
|
|
55
54
|
Each {LIBUSB::Endpoint} specifies the type of transfer, direction, polling interval and
|
|
56
55
|
maximum packet size.
|
|
57
56
|
|
|
57
|
+
See [the documentation](http://rubydoc.info/gems/libusb/frames) for a full API description.
|
|
58
58
|
|
|
59
59
|
Prerequisites
|
|
60
60
|
-------------
|
|
61
61
|
|
|
62
|
-
* Linux,
|
|
63
|
-
* Optionally: [libusb](http://libusb.info)
|
|
62
|
+
* Linux, MacOS or Windows system with Ruby MRI 1.9/2.x, JRuby or recent version of Rubinius
|
|
63
|
+
* Optionally: [libusb](http://libusb.info) C-library version 1.0.8 or any newer version.
|
|
64
|
+
The system libusb library can be installed like so:
|
|
64
65
|
* Debian or Ubuntu:
|
|
65
66
|
|
|
66
67
|
```
|
|
67
68
|
$ sudo apt-get install libusb-1.0-0-dev
|
|
68
69
|
```
|
|
69
|
-
*
|
|
70
|
+
* MacOS: install with homebrew:
|
|
70
71
|
|
|
71
72
|
```
|
|
72
73
|
$ brew install libusb
|
|
@@ -83,7 +84,7 @@ Install
|
|
|
83
84
|
|
|
84
85
|
$ gem install libusb
|
|
85
86
|
|
|
86
|
-
While ```gem install``` the system is checked for a usable libusb
|
|
87
|
+
While ```gem install``` the system is checked for a usable libusb library installation.
|
|
87
88
|
If none could be found, a bundled libusb version is built and used, instead.
|
|
88
89
|
|
|
89
90
|
Latest code can be used in this way:
|
|
@@ -92,11 +93,21 @@ Latest code can be used in this way:
|
|
|
92
93
|
$ bundle
|
|
93
94
|
$ rake install_gem
|
|
94
95
|
|
|
96
|
+
Troubleshooting
|
|
97
|
+
------------------------
|
|
98
|
+
In order to implement a driver for a USB device, it's essential to have a look at the packets that are send to and received back from the USB device. [Wireshark](https://www.wireshark.org) has builtin capabilities to sniff USB traffic. On Linux you possibly need to load the usbmon kernel module before start:
|
|
99
|
+
```
|
|
100
|
+
sudo modprobe usbmon
|
|
101
|
+
```
|
|
102
|
+
On Windows it's possible to sniff USB, if the USB kernel driver was installed by the Wireshark setup.
|
|
103
|
+
|
|
104
|
+

|
|
105
|
+
|
|
95
106
|
Device hotplug support
|
|
96
107
|
----------------------
|
|
97
108
|
|
|
98
109
|
Support for device hotplugging can be used, if ```LIBUSB.has_capability?(:CAP_HAS_HOTPLUG)``` returns ```true```.
|
|
99
|
-
This requires libusb
|
|
110
|
+
This requires libusb-1.0.16 or newer on Linux or MacOS. Windows support is [still on the way](https://github.com/libusbx/libusbx/issues/9).
|
|
100
111
|
|
|
101
112
|
A hotplug event handler can be registered with {LIBUSB::Context#on_hotplug_event}.
|
|
102
113
|
You then need to call {LIBUSB::Context#handle_events} in order to receive any events.
|
|
@@ -109,21 +120,21 @@ Usage on Windows
|
|
|
109
120
|
|
|
110
121
|
In contrast to Linux, any access to an USB device by LIBUSB on Windows requires a proper driver
|
|
111
122
|
installed in the system. Fortunately creating such a driver is quite easy with
|
|
112
|
-
[Zadig](http://
|
|
123
|
+
[Zadig](http://zadig.akeo.ie/). Select the interesting USB device,
|
|
113
124
|
choose WinUSB driver and press "Install Driver". That's it. You may take the generated output directory
|
|
114
|
-
with it's INI-file and use it for driver
|
|
125
|
+
with it's INI-file and use it for driver installations on other 32 or 64 bit Windows
|
|
115
126
|
systems.
|
|
116
127
|
|
|
117
128
|
|
|
118
129
|
Cross compiling for Windows
|
|
119
130
|
---------------------------
|
|
120
131
|
|
|
121
|
-
Libusb-gem can be cross built for
|
|
132
|
+
Libusb-gem can be cross built for Windows and Linux operating systems, using the [rake-compiler-dock](https://github.com/larskanis/rake-compiler-dock) .
|
|
122
133
|
Just run:
|
|
123
134
|
|
|
124
|
-
$ rake gem:
|
|
135
|
+
$ rake gem:native
|
|
125
136
|
|
|
126
|
-
If everything works, there
|
|
137
|
+
If everything works, there are several platform specific gem files (like `libusb-VERSION-x64-mingw32.gem`) in the pkg
|
|
127
138
|
directory.
|
|
128
139
|
|
|
129
140
|
EventMachine integration
|
data/Rakefile
CHANGED
|
@@ -8,10 +8,11 @@ require 'uri'
|
|
|
8
8
|
require 'ostruct'
|
|
9
9
|
require 'rake/clean'
|
|
10
10
|
require 'rake_compiler_dock'
|
|
11
|
+
require_relative 'ext/libusb_recipe'
|
|
11
12
|
|
|
12
13
|
task :gem => :build
|
|
13
14
|
task :compile do
|
|
14
|
-
sh "ruby ext/extconf.rb"
|
|
15
|
+
sh "ruby ext/extconf.rb --disable-system-libusb"
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
task :test=>:compile do
|
|
@@ -24,110 +25,64 @@ task :travis=>:compile do
|
|
|
24
25
|
end
|
|
25
26
|
task :default => :test
|
|
26
27
|
|
|
27
|
-
task
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
STATIC_SOURCESDIR = COMPILE_HOME + 'sources'
|
|
33
|
-
|
|
34
|
-
# Fetch tarball from sourceforge
|
|
35
|
-
LIBUSB_VERSION = ENV['LIBUSB_VERSION'] || '1.0.20'
|
|
36
|
-
LIBUSB_SOURCE_URI = URI( "http://downloads.sourceforge.net/project/libusb/libusb-1.0/libusb-#{LIBUSB_VERSION}/libusb-#{LIBUSB_VERSION}.tar.bz2" )
|
|
37
|
-
LIBUSB_TARBALL = STATIC_SOURCESDIR + File.basename( LIBUSB_SOURCE_URI.path )
|
|
38
|
-
|
|
39
|
-
# Fetch tarball from git repo
|
|
40
|
-
# LIBUSB_VERSION = ENV['LIBUSB_VERSION'] || '295c9d1'
|
|
41
|
-
# LIBUSB_SOURCE_URI = URI( "http://git.libusb.org/?p=libusb.git;a=snapshot;h=#{LIBUSB_VERSION};sf=tbz2" )
|
|
42
|
-
# LIBUSB_TARBALL = STATIC_SOURCESDIR + "libusb-#{LIBUSB_VERSION}.tar.bz2"
|
|
28
|
+
task "release:tag" do
|
|
29
|
+
hfile = "History.md"
|
|
30
|
+
version = LIBUSB::VERSION
|
|
31
|
+
reldate = Time.now.strftime("%Y-%m-%d")
|
|
32
|
+
headline = '([^\w]*)(\d+\.\d+\.\d+)([^\w]+)([2Y][0Y][0-9Y][0-9Y]-[0-1M][0-9M]-[0-3D][0-9D])([^\w]*|$)'
|
|
43
33
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
#
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
34
|
+
hin = File.read(hfile)
|
|
35
|
+
hout = hin.sub(/#{headline}/) do
|
|
36
|
+
raise "#{hfile} isn't up-to-date for version #{version}" unless $2==version
|
|
37
|
+
$1 + $2 + $3 + reldate + $5
|
|
38
|
+
end
|
|
39
|
+
if hout != hin
|
|
40
|
+
Bundler.ui.confirm "Updating #{hfile} for release."
|
|
41
|
+
File.write(hfile, hout)
|
|
42
|
+
sh "git", "commit", hfile, "-m", "Update release date in #{hfile}"
|
|
43
|
+
end
|
|
53
44
|
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
Bundler.ui.confirm "Tag release with annotation:"
|
|
46
|
+
m = hout.match(/(?<annotation>#{headline}.*?)#{headline}/m) || raise("Unable to find release notes in #{hfile}")
|
|
47
|
+
Bundler.ui.info(m[:annotation].gsub(/^/, " "))
|
|
48
|
+
IO.popen(["git", "tag", "--file=-", version], "w") do |fd|
|
|
49
|
+
fd.write m[:annotation]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
56
52
|
|
|
57
|
-
|
|
53
|
+
task "release:guard_clean" => "release:tag"
|
|
58
54
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
url = LIBUSB_SOURCE_URI
|
|
64
|
-
sh "wget '#{url}' -O #{LIBUSB_TARBALL}"
|
|
55
|
+
task "release:rubygem_push" => "gem:native" do
|
|
56
|
+
CrossLibraries.each do |ruby_platform, _|
|
|
57
|
+
gh = Bundler::GemHelper.new
|
|
58
|
+
gh.send(:rubygem_push, "pkg/#{gh.gemspec.name}-#{gh.gemspec.version}-#{ruby_platform}.gem")
|
|
65
59
|
end
|
|
66
60
|
end
|
|
67
61
|
|
|
62
|
+
task 'gem:native' do
|
|
63
|
+
sh "bundle package"
|
|
64
|
+
RakeCompilerDock.sh <<-EOT
|
|
65
|
+
sudo apt-get update &&
|
|
66
|
+
sudo apt-get -y install libudev-dev libudev-dev:i386 &
|
|
67
|
+
bundle --local &&
|
|
68
|
+
rake cross gem
|
|
69
|
+
EOT
|
|
70
|
+
end
|
|
68
71
|
|
|
69
72
|
class CrossLibrary < OpenStruct
|
|
70
73
|
include Rake::DSL
|
|
71
74
|
|
|
72
|
-
def initialize(ruby_platform, host_platform)
|
|
75
|
+
def initialize(ruby_platform, host_platform, libusb_dllname)
|
|
73
76
|
super()
|
|
74
77
|
|
|
75
|
-
self.ruby_platform
|
|
76
|
-
self.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
self.
|
|
80
|
-
|
|
81
|
-
# Static libusb build vars
|
|
82
|
-
self.static_libusb_builddir = static_builddir + LIBUSB_TARBALL.basename(".tar.bz2")
|
|
83
|
-
self.libusb_configure = static_libusb_builddir + 'configure'
|
|
84
|
-
self.libusb_makefile = static_libusb_builddir + 'Makefile'
|
|
85
|
-
self.libusb_dll = static_libusb_builddir + 'libusb/.libs/libusb-1.0.dll'
|
|
86
|
-
|
|
87
|
-
#
|
|
88
|
-
# Static libusb build tasks
|
|
89
|
-
#
|
|
90
|
-
CLEAN.include static_libusb_builddir.to_s
|
|
91
|
-
|
|
92
|
-
directory static_libusb_builddir.to_s
|
|
78
|
+
self.ruby_platform = ruby_platform
|
|
79
|
+
self.recipe = LibusbRecipe.new
|
|
80
|
+
recipe.host = host_platform
|
|
81
|
+
recipe.configure_options << "--host=#{recipe.host}"
|
|
82
|
+
self.libusb_dll = Pathname.new(recipe.path) + libusb_dllname
|
|
93
83
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
sh 'tar', '-xjf', LIBUSB_TARBALL.to_s, '-C', static_libusb_builddir.parent.to_s
|
|
97
|
-
libusb_makefile.unlink if libusb_makefile.exist?
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
file libusb_configure => static_libusb_builddir do |t|
|
|
101
|
-
Dir.chdir( static_libusb_builddir ) do
|
|
102
|
-
sh "sh autogen.sh && make distclean"
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
libusb_env = [
|
|
107
|
-
"CFLAGS='-fno-omit-frame-pointer'",
|
|
108
|
-
"LDFLAGS='-static-libgcc'",
|
|
109
|
-
"CC='#{host_platform}-gcc -static-libgcc'", # hack libtool, since it doesn't support -static-libgcc yet.
|
|
110
|
-
]
|
|
111
|
-
|
|
112
|
-
# generate the makefile in a clean build location
|
|
113
|
-
file libusb_makefile => libusb_configure do |t|
|
|
114
|
-
Dir.chdir( static_libusb_builddir ) do
|
|
115
|
-
options = [
|
|
116
|
-
"--target=#{host_platform}",
|
|
117
|
-
"--host=#{host_platform}",
|
|
118
|
-
"--build=#{ruby_build}",
|
|
119
|
-
]
|
|
120
|
-
|
|
121
|
-
configure_path = static_libusb_builddir + 'configure'
|
|
122
|
-
sh "env #{[libusb_env, configure_path.to_s, *options].join(" ")}"
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
# make libusb-1.0.dll
|
|
127
|
-
task libusb_dll => [ libusb_makefile ] do |t|
|
|
128
|
-
Dir.chdir( static_libusb_builddir ) do
|
|
129
|
-
sh 'make'
|
|
130
|
-
end
|
|
84
|
+
file libusb_dll do
|
|
85
|
+
recipe.cook
|
|
131
86
|
end
|
|
132
87
|
|
|
133
88
|
task "libusb_dll:#{ruby_platform}" => libusb_dll
|
|
@@ -137,9 +92,17 @@ class CrossLibrary < OpenStruct
|
|
|
137
92
|
spec = Gem::Specification::load("libusb.gemspec").dup
|
|
138
93
|
spec.platform = Gem::Platform.new(ruby_platform)
|
|
139
94
|
spec.extensions = []
|
|
95
|
+
|
|
96
|
+
# Remove files unnecessary for native gems
|
|
140
97
|
spec.files -= `git ls-files ext`.split("\n")
|
|
98
|
+
spec.files.reject!{|f| f.start_with?('ports') }
|
|
141
99
|
spec_text_files = spec.files.dup
|
|
142
|
-
|
|
100
|
+
|
|
101
|
+
# Add native libusb-dll
|
|
102
|
+
spec.files << "lib/#{libusb_dll.basename}"
|
|
103
|
+
|
|
104
|
+
# MiniPortile isn't required for native gems
|
|
105
|
+
spec.dependencies.reject!{|d| d.name=="mini_portile2" }
|
|
143
106
|
|
|
144
107
|
# Generate a package for this gem
|
|
145
108
|
pkg = Gem::PackageTask.new(spec) do |pkg|
|
|
@@ -161,32 +124,24 @@ class CrossLibrary < OpenStruct
|
|
|
161
124
|
end
|
|
162
125
|
|
|
163
126
|
# copy libusb.dll to pkg directory
|
|
164
|
-
f = "#{pkg.package_dir_path}/lib/#{
|
|
127
|
+
f = "#{pkg.package_dir_path}/lib/#{libusb_dll.basename}"
|
|
165
128
|
mkdir_p File.dirname(f)
|
|
166
129
|
rm_f f
|
|
167
|
-
safe_ln libusb_dll, f
|
|
130
|
+
safe_ln libusb_dll.realpath, f
|
|
168
131
|
end
|
|
169
132
|
|
|
170
|
-
file "lib/#{
|
|
133
|
+
file "lib/#{libusb_dll.basename}" => [libusb_dll]
|
|
171
134
|
end
|
|
172
135
|
end
|
|
173
136
|
end
|
|
174
137
|
|
|
175
138
|
CrossLibraries = [
|
|
176
|
-
['
|
|
177
|
-
['x64-mingw32', 'x86_64-w64-mingw32'],
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
desc "Download and update bundled libusb"
|
|
183
|
-
task :update_libusb => LIBUSB_TARBALL do
|
|
184
|
-
sh 'rm', '-r', (EXT_BUILDDIR + "libusb-*").to_s do end
|
|
185
|
-
sh 'git', 'rm', '-rfq', (EXT_BUILDDIR + "libusb-*").to_s do end
|
|
186
|
-
sh 'tar', '-xjf', LIBUSB_TARBALL.to_s, '-C', EXT_LIBUSB_BUILDDIR.parent.to_s
|
|
187
|
-
drops = %w[msvc].map{|f| (EXT_LIBUSB_BUILDDIR+f).to_s }
|
|
188
|
-
sh 'rm', '-r', '-f', *drops
|
|
189
|
-
sh 'git', 'add', EXT_LIBUSB_BUILDDIR.to_s
|
|
139
|
+
['x86-mingw32', 'i686-w64-mingw32', 'bin/libusb-1.0.dll'],
|
|
140
|
+
['x64-mingw32', 'x86_64-w64-mingw32', 'bin/libusb-1.0.dll'],
|
|
141
|
+
['x86-linux', 'i686-linux-gnu', 'lib/libusb-1.0.so'],
|
|
142
|
+
['x86_64-linux', 'x86_64-linux-gnu', 'lib/libusb-1.0.so'],
|
|
143
|
+
].each do |ruby_platform, host_platform, libusb_dll|
|
|
144
|
+
CrossLibrary.new ruby_platform, host_platform, libusb_dll
|
|
190
145
|
end
|
|
191
146
|
|
|
192
147
|
# vim: syntax=ruby
|
data/appveyor.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
init:
|
|
2
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
|
3
|
+
- SET PATH=C:\MinGW\msys\1.0\bin;%PATH%
|
|
4
|
+
- SET RAKEOPT=-rdevkit
|
|
5
|
+
install:
|
|
6
|
+
- ruby --version
|
|
7
|
+
- gem --version
|
|
8
|
+
- bundle install
|
|
9
|
+
build_script:
|
|
10
|
+
- bundle exec rake compile
|
|
11
|
+
test_script:
|
|
12
|
+
- bundle exec rake travis
|
|
13
|
+
environment:
|
|
14
|
+
matrix:
|
|
15
|
+
- ruby_version: "193"
|
|
16
|
+
- ruby_version: "200"
|
|
17
|
+
- ruby_version: "200-x64"
|
|
18
|
+
- ruby_version: "21"
|
|
19
|
+
- ruby_version: "21-x64"
|
|
20
|
+
- ruby_version: "22"
|
|
21
|
+
- ruby_version: "22-x64"
|
|
22
|
+
- ruby_version: "23"
|
|
23
|
+
- ruby_version: "23-x64"
|
data/ext/extconf.rb
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
require 'ffi'
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
|
|
7
|
+
include FileUtils
|
|
5
8
|
|
|
6
9
|
if RUBY_PLATFORM =~ /java/
|
|
7
10
|
# JRuby's C extension support is disabled by default, so we can not easily test
|
|
@@ -50,7 +53,7 @@ def libusb_usable?
|
|
|
50
53
|
prefix = FFI::Platform::LIBPREFIX.empty? ? 'lib' : FFI::Platform::LIBPREFIX
|
|
51
54
|
bundled_dll = File.join(root_path, "lib/#{prefix}usb-1.0.#{ext}")
|
|
52
55
|
bundled_dll_cygwin = File.join(root_path, "bin/#{prefix}usb-1.0.#{ext}")
|
|
53
|
-
ffi_lib(["#{prefix}usb-1.0"
|
|
56
|
+
ffi_lib([bundled_dll, bundled_dll_cygwin, "#{prefix}usb-1.0"])
|
|
54
57
|
end
|
|
55
58
|
true
|
|
56
59
|
rescue LoadError
|
|
@@ -59,23 +62,18 @@ def libusb_usable?
|
|
|
59
62
|
end
|
|
60
63
|
|
|
61
64
|
def build_bundled_libusb(have_udev)
|
|
62
|
-
libusb_dir = Dir[File.expand_path('../../ext/libusb-*', __FILE__)].first
|
|
63
|
-
root_dir = File.expand_path('../..', __FILE__)
|
|
64
|
-
raise "could not find embedded libusb sources" unless libusb_dir
|
|
65
|
-
|
|
66
65
|
# Enable udev for hot-plugging when it is available.
|
|
67
66
|
# This is the same check that is done in libusb's configure.ac file
|
|
68
67
|
# but we don't abort in case it's not available, but continue
|
|
69
68
|
# without hot-plugging.
|
|
70
69
|
have_udev &&= have_header('libudev.h') && have_library('udev', 'udev_new')
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Dir.chdir old_dir
|
|
71
|
+
require_relative 'libusb_recipe'
|
|
72
|
+
recipe = LibusbRecipe.new
|
|
73
|
+
recipe.configure_options << "--disable-udev" unless have_udev
|
|
74
|
+
recipe.cook_and_activate
|
|
75
|
+
|
|
76
|
+
cp_r File.join(recipe.path, '.'), '.', verbose: true, remove_destination: true
|
|
79
77
|
end
|
|
80
78
|
|
|
81
79
|
unless enable_config('system-libusb', libusb_usable?)
|