libusb 0.6.3-x64-mingw32 → 0.7.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.appveyor.yml +33 -0
- data/.github/workflows/ci.yml +185 -0
- data/.gitignore +1 -0
- data/.travis.yml +17 -10
- data/Gemfile +9 -1
- data/History.md +57 -0
- data/README.md +30 -5
- data/Rakefile +41 -12
- data/lib/libusb/bos.rb +85 -29
- data/lib/libusb/call.rb +192 -16
- data/lib/libusb/configuration.rb +3 -4
- data/lib/libusb/constants.rb +26 -16
- data/lib/libusb/context.rb +195 -45
- data/{test/test_libusb_capability.rb → lib/libusb/context_reference.rb} +20 -5
- data/lib/libusb/dependencies.rb +2 -2
- data/lib/libusb/dev_handle.rb +34 -24
- data/lib/libusb/device.rb +50 -8
- data/lib/libusb/endpoint.rb +3 -2
- data/lib/libusb/eventmachine.rb +8 -4
- data/lib/libusb/gem_helper.rb +9 -6
- data/lib/libusb/libusb_recipe.rb +2 -3
- data/lib/libusb/ss_companion.rb +9 -6
- data/lib/libusb/transfer.rb +48 -7
- data/lib/libusb/version_gem.rb +1 -1
- data/lib/libusb-1.0.dll +0 -0
- data/lib/libusb.rb +106 -18
- data/libusb.gemspec +2 -4
- data/test/{test_libusb_version.rb → test_libusb.rb} +12 -10
- data/test/test_libusb_bos.rb +22 -0
- data/test/test_libusb_bulk_stream_transfer.rb +23 -12
- data/test/test_libusb_context.rb +88 -0
- data/test/test_libusb_descriptors.rb +44 -11
- data/test/test_libusb_gc.rb +15 -0
- data/test/test_libusb_hotplug.rb +3 -1
- data/test/test_libusb_iso_transfer.rb +6 -0
- data/test/test_libusb_mass_storage.rb +6 -6
- data/test/test_libusb_structs.rb +32 -3
- metadata +11 -51
- data/appveyor.yml +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 13cb0f5eee03904372dfc17c7f990fc32c2a62e420e8d965ad14427bf1c050b7
|
4
|
+
data.tar.gz: e55f618c12d90e3a710b838ef2214322240bd5bb76cfaa118ce4852edb9a7fa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 914dbb583d8872226dd818b1ae9e10a6a0bb0de412ccb0ab4ec7ff1d9d74fbee347a4c7491620a1362ffd4458f95c48ad964d93f7dfcd352baa54c9b7a808e70
|
7
|
+
data.tar.gz: 807a866f2d62eab24b1718b6a2922a709aea22d77ae82c40c5a70a895fe5967f830f26f26cf09ab76001c7d081295a2aa84d8ad7c30d817c32040fa64ecf6e07
|
data/.appveyor.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
image: Visual Studio 2019
|
2
|
+
|
3
|
+
clone_depth: 1
|
4
|
+
|
5
|
+
init:
|
6
|
+
- SET PATH=C:/Ruby%ruby_version%/bin;%PATH%
|
7
|
+
install:
|
8
|
+
- ps: |
|
9
|
+
if ($env:ruby_version -like "*head*") {
|
10
|
+
$(new-object net.webclient).DownloadFile("https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-$env:ruby_version.exe", "$pwd/ruby-setup.exe")
|
11
|
+
cmd /c ruby-setup.exe /verysilent /currentuser /dir=C:/Ruby$env:ruby_version
|
12
|
+
}
|
13
|
+
- ruby --version
|
14
|
+
- gem --version
|
15
|
+
- ridk version
|
16
|
+
- ridk enable
|
17
|
+
- c:/msys64/usr/bin/bash -lc "pacman -S --noconfirm --needed ${MINGW_PACKAGE_PREFIX}-gcc ${MINGW_PACKAGE_PREFIX}-openssl"
|
18
|
+
- gcc -v
|
19
|
+
- gem install bundler --conservative
|
20
|
+
- bundle install
|
21
|
+
|
22
|
+
build_script:
|
23
|
+
- bundle exec rake compile
|
24
|
+
|
25
|
+
test_script:
|
26
|
+
- bundle exec rake ci
|
27
|
+
|
28
|
+
environment:
|
29
|
+
matrix:
|
30
|
+
- ruby_version: "head-x64"
|
31
|
+
- ruby_version: "33"
|
32
|
+
- ruby_version: "30-x64"
|
33
|
+
- ruby_version: "25"
|
@@ -0,0 +1,185 @@
|
|
1
|
+
name: Build docker images
|
2
|
+
concurrency:
|
3
|
+
group: "${{github.workflow}}-${{github.ref}}"
|
4
|
+
cancel-in-progress: true
|
5
|
+
on:
|
6
|
+
workflow_dispatch:
|
7
|
+
schedule:
|
8
|
+
- cron: "0 5 * * 3" # At 05:00 on Wednesday # https://crontab.guru/#0_5_*_*_3
|
9
|
+
push:
|
10
|
+
branches:
|
11
|
+
- master
|
12
|
+
tags:
|
13
|
+
- "*.*.*"
|
14
|
+
pull_request:
|
15
|
+
types: [opened, synchronize]
|
16
|
+
branches:
|
17
|
+
- "*"
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
# These jobs use Buildx layer caching
|
21
|
+
docker_build:
|
22
|
+
name: Build
|
23
|
+
|
24
|
+
strategy:
|
25
|
+
fail-fast: false
|
26
|
+
matrix:
|
27
|
+
platform:
|
28
|
+
- x86-mingw32
|
29
|
+
- x64-mingw-ucrt
|
30
|
+
- x64-mingw32
|
31
|
+
- x86-linux
|
32
|
+
- x86_64-linux
|
33
|
+
|
34
|
+
runs-on: ubuntu-latest
|
35
|
+
env:
|
36
|
+
PLATFORM: ${{ matrix.platform }}
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v4
|
39
|
+
|
40
|
+
- uses: ruby/setup-ruby@v1
|
41
|
+
with:
|
42
|
+
ruby-version: "3.3"
|
43
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
44
|
+
|
45
|
+
- name: Build libusb.gem
|
46
|
+
run: |
|
47
|
+
bundle exec rake gem:native:${PLATFORM}
|
48
|
+
|
49
|
+
- name: Upload binary gem
|
50
|
+
uses: actions/upload-artifact@v4
|
51
|
+
with:
|
52
|
+
name: gem-${{ matrix.platform }}
|
53
|
+
path: pkg/*-*-*.gem
|
54
|
+
|
55
|
+
- if: matrix.platform == 'jruby'
|
56
|
+
name: Upload source gem
|
57
|
+
uses: actions/upload-artifact@v4
|
58
|
+
with:
|
59
|
+
name: gem-ruby
|
60
|
+
path: pkg/*-?.?.?.gem
|
61
|
+
|
62
|
+
job_test_native:
|
63
|
+
name: Bin (${{matrix.ruby}}, ${{matrix.os}}, ${{matrix.platform}})
|
64
|
+
needs: docker_build
|
65
|
+
strategy:
|
66
|
+
fail-fast: false
|
67
|
+
matrix:
|
68
|
+
include:
|
69
|
+
- os: windows
|
70
|
+
ruby: "2.5"
|
71
|
+
platform: x64-mingw32
|
72
|
+
- os: windows
|
73
|
+
ruby: "3.3"
|
74
|
+
platform: x64-mingw-ucrt
|
75
|
+
- os: ubuntu
|
76
|
+
ruby: "2.5"
|
77
|
+
platform: x86_64-linux
|
78
|
+
- os: ubuntu
|
79
|
+
ruby: "3.3"
|
80
|
+
platform: x86_64-linux
|
81
|
+
|
82
|
+
runs-on: ${{ matrix.os }}-latest
|
83
|
+
steps:
|
84
|
+
- uses: actions/checkout@v4
|
85
|
+
- uses: ruby/setup-ruby@v1
|
86
|
+
with:
|
87
|
+
ruby-version: ${{ matrix.ruby }}
|
88
|
+
- run: ruby --version
|
89
|
+
- name: Download gem-${{matrix.platform}}
|
90
|
+
uses: actions/download-artifact@v4
|
91
|
+
with:
|
92
|
+
name: gem-${{ matrix.platform }}
|
93
|
+
- name: Install gem-${{matrix.platform}}
|
94
|
+
run: gem install *.gem --verbose
|
95
|
+
- name: bundle install
|
96
|
+
run: bundle install
|
97
|
+
- name: Generate Gemfile_libusb_gem to ensure the installed gem is used
|
98
|
+
run: bundle exec rake gemfile_libusb_gem
|
99
|
+
- name: Run tests
|
100
|
+
env:
|
101
|
+
BUNDLE_GEMFILE: Gemfile_libusb_gem
|
102
|
+
run: |
|
103
|
+
bundle exec rake ci
|
104
|
+
|
105
|
+
# These jobs use Buildx layer caching
|
106
|
+
source_gem:
|
107
|
+
name: Source gem
|
108
|
+
|
109
|
+
strategy:
|
110
|
+
fail-fast: false
|
111
|
+
|
112
|
+
runs-on: ubuntu-latest
|
113
|
+
steps:
|
114
|
+
- uses: actions/checkout@v4
|
115
|
+
|
116
|
+
- uses: ruby/setup-ruby@v1
|
117
|
+
with:
|
118
|
+
ruby-version: "3.3"
|
119
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
120
|
+
|
121
|
+
- name: Build libusb.gem
|
122
|
+
run: |
|
123
|
+
bundle exec rake gem
|
124
|
+
|
125
|
+
- name: Upload binary gem
|
126
|
+
uses: actions/upload-artifact@v4
|
127
|
+
with:
|
128
|
+
name: gem-ruby
|
129
|
+
path: pkg/*.gem
|
130
|
+
|
131
|
+
job_test_source:
|
132
|
+
name: Src (${{matrix.ruby}}, ${{matrix.os}}, ${{matrix.extconfopts}})
|
133
|
+
needs: source_gem
|
134
|
+
strategy:
|
135
|
+
fail-fast: false
|
136
|
+
matrix:
|
137
|
+
os:
|
138
|
+
- windows
|
139
|
+
- ubuntu
|
140
|
+
- macos
|
141
|
+
ruby:
|
142
|
+
- "3.3"
|
143
|
+
- "2.5"
|
144
|
+
- "head"
|
145
|
+
- "jruby"
|
146
|
+
- "truffleruby"
|
147
|
+
extconfopts: [ --disable-system-libusb, --enable-system-libusb ]
|
148
|
+
exclude:
|
149
|
+
- os: windows
|
150
|
+
ruby: "truffleruby"
|
151
|
+
- os: windows
|
152
|
+
ruby: "jruby"
|
153
|
+
# Fails to install libusb from MSYS2
|
154
|
+
extconfopts: --enable-system-libusb
|
155
|
+
- os: windows
|
156
|
+
ruby: "jruby"
|
157
|
+
# configure: error: unrecognized option: `--prefix\=D:/jruby-9.4.6.0/lib/ruby/gems/shared/gems/libusb-0.6.4/ports/x86_64-w64-mingw32/libusb/1.0.27'
|
158
|
+
extconfopts: --disable-system-libusb
|
159
|
+
|
160
|
+
runs-on: ${{ matrix.os }}-latest
|
161
|
+
steps:
|
162
|
+
- uses: actions/checkout@v4
|
163
|
+
- uses: ruby/setup-ruby@v1
|
164
|
+
with:
|
165
|
+
ruby-version: ${{ matrix.ruby }}
|
166
|
+
- run: ruby --version
|
167
|
+
- name: Download gem
|
168
|
+
uses: actions/download-artifact@v4
|
169
|
+
with:
|
170
|
+
name: gem-ruby
|
171
|
+
- name: Install libusb on Windows
|
172
|
+
if: matrix.os == 'windows' && matrix.extconfopts == '--enable-system-libusb'
|
173
|
+
shell: cmd
|
174
|
+
run: C:/msys64/usr/bin/sh -c "pacman --sync --refresh --needed --noconfirm ${MINGW_PACKAGE_PREFIX}-libusb"
|
175
|
+
- name: Install gem
|
176
|
+
run: gem install *.gem --verbose -- ${{ matrix.extconfopts }}
|
177
|
+
- name: bundle install
|
178
|
+
run: bundle install
|
179
|
+
- name: Generate Gemfile_libusb_gem to ensure the installed gem is used
|
180
|
+
run: bundle exec rake gemfile_libusb_gem
|
181
|
+
- name: Run tests
|
182
|
+
env:
|
183
|
+
BUNDLE_GEMFILE: Gemfile_libusb_gem
|
184
|
+
run: |
|
185
|
+
bundle exec rake ci
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,19 +1,26 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
2
3
|
sudo: false
|
3
|
-
|
4
|
+
|
5
|
+
dist: xenial
|
4
6
|
matrix:
|
5
7
|
include:
|
6
|
-
- rvm:
|
8
|
+
- rvm: ruby-head
|
7
9
|
env:
|
8
10
|
- RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
|
9
|
-
- rvm:
|
10
|
-
|
11
|
-
|
12
|
-
- rvm:
|
11
|
+
- rvm: 2.4.3
|
12
|
+
env:
|
13
|
+
- RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
|
14
|
+
- rvm: 3.0
|
15
|
+
env:
|
16
|
+
- RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
|
17
|
+
- rvm: 2.7
|
18
|
+
- rvm: 2.6
|
13
19
|
- rvm: 2.3.1
|
14
|
-
- rvm: jruby-
|
15
|
-
- rvm:
|
16
|
-
|
20
|
+
- rvm: jruby-9.2.14.0
|
21
|
+
- rvm: truffleruby
|
22
|
+
|
17
23
|
allow_failures:
|
18
|
-
- rvm:
|
24
|
+
- rvm: ruby-head
|
25
|
+
|
19
26
|
script: bundle exec rake travis
|
data/Gemfile
CHANGED
@@ -8,4 +8,12 @@ group :test do
|
|
8
8
|
gem 'minitest'
|
9
9
|
end
|
10
10
|
|
11
|
-
gem 'rake-compiler-dock', '~>
|
11
|
+
gem 'rake-compiler-dock', '~> 1.1'
|
12
|
+
gem 'rake-compiler', '~> 1.0'
|
13
|
+
gem 'bundler', '>= 1', '< 3'
|
14
|
+
gem 'yard', '~> 0.6', '>= 0.9.36'
|
15
|
+
|
16
|
+
# For some reason this is required in addition to the gemspec
|
17
|
+
# when 'bundle config force_ruby_platform true' is active:
|
18
|
+
gem 'ffi'
|
19
|
+
gem 'mini_portile2'
|
data/History.md
CHANGED
@@ -1,3 +1,60 @@
|
|
1
|
+
0.7.0 / 2024-04-18
|
2
|
+
------------------
|
3
|
+
|
4
|
+
Added:
|
5
|
+
* Garbage collect LIBUSB::Context objects. #47
|
6
|
+
Context objects were intentionally not garbage collected previously, since it led to segfauls, when the context was freed before other libusb objects.
|
7
|
+
Now refcounting all objects bound to a particular Context ensures that the underlying libusb context is always freed at last, avoiding any segfaults.
|
8
|
+
Registered log callback and pollfd callbacks are disabled before garbage collecting LIBUSB::Context.
|
9
|
+
* Cancel USB transfers on any exceptions not only LIBUSB::Error, but also Interrupt or IRB::Abort, etc.
|
10
|
+
Otherwise incomplete transfers lead to LIBUSB::ERROR_BUSY at the next command.
|
11
|
+
* Update Windows binary support for ruby up to 3.3.x
|
12
|
+
* Update bundled libusb version to 1.0.27.
|
13
|
+
* Add support for new functions of libusb-1.0.27
|
14
|
+
They are:
|
15
|
+
- libusb_init_context
|
16
|
+
- libusb_set_log_cb
|
17
|
+
- libusb_wrap_sys_device
|
18
|
+
* Add global Libusb.set_option and Libusb.set_options . #42
|
19
|
+
* Add LIBUSB::Device.max_alt_packet_size. #42
|
20
|
+
Introduced in libusb-1.0.27 as libusb_get_max_alt_packet_size()
|
21
|
+
* Add BOS platform descriptor introduced in libusb-1.0.27. #49
|
22
|
+
* Add enums for all BOS descripors of the USB-3.2-V1.1 spec. #49
|
23
|
+
|
24
|
+
Changed:
|
25
|
+
* Set minimum Ruby version requirement to 2.5.0.
|
26
|
+
* Fix a circular reference in ZeroCopyMemory.
|
27
|
+
This circular reference blocked all objects referenced by a LIBUSB::Transfer to be released by the garbage collector.
|
28
|
+
* Make ZeroCopyMemory an opt-in rather then enforcing it
|
29
|
+
In therory libusb_dev_mem_alloc shouldn't provide a pointer unless zero-copy-memory is supported by the linux kernel.
|
30
|
+
But in practice this has been a repeating cause of issues, since some kernels don't handle these transfers.
|
31
|
+
So it's better to enable it on request only.
|
32
|
+
For instance older raspberry pi kernels didn't handle zero-copy-memory.
|
33
|
+
* Fix struct member size in Bos::SsUsbDeviceCapability. #48
|
34
|
+
The bmAttributes member is defined as uint8_t not uint32_t.
|
35
|
+
* Fix context reference in device of hotplug notification callback.
|
36
|
+
* Deregister pollfd callbacks in eventmachine_unregister.
|
37
|
+
|
38
|
+
|
39
|
+
0.6.4 / 2018-05-05
|
40
|
+
------------------
|
41
|
+
|
42
|
+
Added:
|
43
|
+
* New function Context#set_option.
|
44
|
+
It is also available when running libusb < 1.0.22 and calls libusb_set_debug() in this case.
|
45
|
+
* Add definition for SUPER_SPEED_PLUS.
|
46
|
+
* Linux: Use system libusb even when only library but no dev package is installed.
|
47
|
+
* Add Transfer#dev_handle and #timeout
|
48
|
+
* Use system libusb even when no development package is installed.
|
49
|
+
Means "libusb-1.0-0" is enough, no need for "libusb-dev" on Ubuntu.
|
50
|
+
|
51
|
+
Changed:
|
52
|
+
* Update libusb to 1.0.22
|
53
|
+
|
54
|
+
Deprecated:
|
55
|
+
* Deprecate Context#debug= analogous to libusb_set_debug in libusb-1.0.22.
|
56
|
+
|
57
|
+
|
1
58
|
0.6.3 / 2017-08-20
|
2
59
|
------------------
|
3
60
|
* Fix compat with FreeBSD. #24
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<!-- -*- coding: utf-8 -*- -->
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.
|
3
|
+
[![Build Status](https://travis-ci.com/larskanis/libusb.svg?branch=master)](https://travis-ci.com/larskanis/libusb)
|
4
4
|
[![Build status](https://ci.appveyor.com/api/projects/status/mdfnfdwu4mil42o3/branch/master?svg=true)](https://ci.appveyor.com/project/larskanis/libusb/branch/master)
|
5
5
|
|
6
6
|
Access USB devices from Ruby
|
@@ -59,13 +59,13 @@ See [the documentation](http://rubydoc.info/gems/libusb/frames) for a full API d
|
|
59
59
|
Prerequisites
|
60
60
|
-------------
|
61
61
|
|
62
|
-
* Linux, MacOS or Windows system with Ruby MRI
|
62
|
+
* Linux, MacOS or Windows system with Ruby MRI 2.x/3.x, JRuby or recent version of Rubinius
|
63
63
|
* Optionally: [libusb](http://libusb.info) C-library version 1.0.8 or any newer version.
|
64
64
|
The system libusb library can be installed like so:
|
65
65
|
* Debian or Ubuntu:
|
66
66
|
|
67
67
|
```
|
68
|
-
$ sudo apt-get install libusb-1.0-0
|
68
|
+
$ sudo apt-get install libusb-1.0-0
|
69
69
|
```
|
70
70
|
* MacOS: install with homebrew:
|
71
71
|
|
@@ -126,10 +126,15 @@ with it's INI-file and use it for driver installations on other 32 or 64 bit Win
|
|
126
126
|
systems.
|
127
127
|
|
128
128
|
|
129
|
-
|
129
|
+
Binary gems for Windows and Linux
|
130
130
|
---------------------------
|
131
131
|
|
132
|
-
Libusb
|
132
|
+
The Libusb gem is provided as source gem and as binary gems for Windows and Linux operating systems on [rubygems.org](https://rubygems.org/gems/libusb).
|
133
|
+
The binary version is usually preferred, but the source version of the gem can be enforced by:
|
134
|
+
|
135
|
+
$ gem install libusb --platform ruby
|
136
|
+
|
137
|
+
Libusb gem can be cross built for Windows and Linux, using the [rake-compiler-dock](https://github.com/larskanis/rake-compiler-dock) .
|
133
138
|
Just run:
|
134
139
|
|
135
140
|
$ rake gem:native
|
@@ -145,6 +150,26 @@ That API is currently proof of concept - see {LIBUSB::Context#eventmachine_regis
|
|
145
150
|
If you're experienced with EventMachine, please leave a comment.
|
146
151
|
|
147
152
|
|
153
|
+
Testing LIBUSB gem
|
154
|
+
------------------
|
155
|
+
|
156
|
+
Libusb for Ruby has a bundled test suite which verifies proper working of many functions of the library.
|
157
|
+
Only a small subset of these tests are executed on Github Actions due to the missing USB functions in the CI environments.
|
158
|
+
They just verify that the libusb library can be installed and called and that very basic functions are working.
|
159
|
+
|
160
|
+
To run the tests against real devices the following procedure should be done:
|
161
|
+
|
162
|
+
```sh
|
163
|
+
$ # Connect a USB mass strorage device. It is used read-only.
|
164
|
+
$ sudo chown $USER /dev/bus/usb/*/*
|
165
|
+
$ rake test
|
166
|
+
```
|
167
|
+
|
168
|
+
While the tests are running a second arbitrary USB device is requested to be connected and shortly after disconnected again.
|
169
|
+
There are only 5 seconds timeout for connecting and disconnecting, so that the device should have be ready.
|
170
|
+
Some USB mass storage devices are not compatible to the tests, so that it's best to try out different models to find some that doesn't fail.
|
171
|
+
|
172
|
+
|
148
173
|
Resources
|
149
174
|
---------
|
150
175
|
|
data/Rakefile
CHANGED
@@ -7,37 +7,51 @@ require 'pathname'
|
|
7
7
|
require 'uri'
|
8
8
|
require 'ostruct'
|
9
9
|
require 'rake/clean'
|
10
|
-
require 'rake_compiler_dock'
|
11
10
|
require_relative 'lib/libusb/libusb_recipe'
|
12
11
|
require_relative 'lib/libusb/gem_helper'
|
13
12
|
|
13
|
+
CLOBBER.include 'pkg'
|
14
|
+
CLEAN.include 'ports'
|
15
|
+
CLEAN.include 'tmp'
|
16
|
+
CLEAN.include 'ext/tmp'
|
17
|
+
CLEAN.include 'lib/*.a'
|
18
|
+
CLEAN.include 'lib/*.so*'
|
19
|
+
CLEAN.include 'lib/*.dll*'
|
20
|
+
|
21
|
+
task :build do
|
22
|
+
require_relative 'lib/libusb/libusb_recipe'
|
23
|
+
recipe = LIBUSB::LibusbRecipe.new
|
24
|
+
recipe.download
|
25
|
+
end
|
26
|
+
|
14
27
|
task :gem => :build
|
15
28
|
task :compile do
|
16
29
|
sh "ruby -C ext extconf.rb --disable-system-libusb"
|
17
30
|
sh "make -C ext install RUBYARCHDIR=../lib"
|
18
31
|
end
|
19
32
|
|
20
|
-
task :
|
21
|
-
|
33
|
+
task :gemfile_libusb_gem do
|
34
|
+
gf = File.read("Gemfile")
|
35
|
+
gf.gsub!(/^(gemspec)$/, "# \\1")
|
36
|
+
gf << "\ngem 'libusb'\n"
|
37
|
+
File.write("Gemfile_libusb_gem", gf)
|
38
|
+
puts "Gemfile_libusb_gem written"
|
22
39
|
end
|
23
40
|
|
24
|
-
|
25
|
-
|
26
|
-
sh "ruby -w -W2 -I. -Ilib -e \"#{travis_tests.map{|f| "require 'test/#{f}';"}.join}\" -- -v"
|
41
|
+
task :test do
|
42
|
+
sh "ruby -w -W2 -I.:lib -e \"#{Dir["test/test_*.rb"].map{|f| "require '#{f}';"}.join}\" -- -v"
|
27
43
|
end
|
28
44
|
task :default => :test
|
29
45
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
bundle --local &&
|
34
|
-
rake cross gem
|
35
|
-
EOT
|
46
|
+
ci_tests = %w[test_libusb.rb test_libusb_structs.rb]
|
47
|
+
task :ci do
|
48
|
+
sh "ruby -w -W2 -I. -e \"#{ci_tests.map{|f| "require 'test/#{f}';"}.join}\" -- -v"
|
36
49
|
end
|
37
50
|
|
38
51
|
CrossLibraries = [
|
39
52
|
['x86-mingw32', 'i686-w64-mingw32', 'bin/libusb-1.0.dll'],
|
40
53
|
['x64-mingw32', 'x86_64-w64-mingw32', 'bin/libusb-1.0.dll'],
|
54
|
+
['x64-mingw-ucrt', 'x86_64-w64-mingw32', 'bin/libusb-1.0.dll'],
|
41
55
|
['x86-linux', 'i686-linux-gnu', 'lib/libusb-1.0.so'],
|
42
56
|
['x86_64-linux', 'x86_64-linux-gnu', 'lib/libusb-1.0.so'],
|
43
57
|
].map do |ruby_platform, host_platform, libusb_dll|
|
@@ -47,4 +61,19 @@ end
|
|
47
61
|
LIBUSB::GemHelper.install_tasks
|
48
62
|
Bundler::GemHelper.instance.cross_platforms = CrossLibraries.map(&:ruby_platform)
|
49
63
|
|
64
|
+
CrossLibraries.map(&:ruby_platform).each do |platform|
|
65
|
+
desc "Build windows and linux fat binary gems"
|
66
|
+
multitask 'gem:native' => "gem:native:#{platform}"
|
67
|
+
|
68
|
+
task "gem:native:#{platform}" do
|
69
|
+
require 'rake_compiler_dock'
|
70
|
+
sh "bundle package"
|
71
|
+
RakeCompilerDock.sh <<-EOT, platform: platform
|
72
|
+
bundle --local &&
|
73
|
+
#{ "sudo yum install -y libudev-devel &&" if platform=~/linux/ }
|
74
|
+
bundle exec rake --trace cross:#{platform} gem "MAKE=make V=1 -j`nproc`" || cat tmp/*/ports/libusb/*/*.log
|
75
|
+
EOT
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
50
79
|
# vim: syntax=ruby
|