libusb 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d40d1cf55c220e3db032cf0d01264b370865fb840186ae518aeaf701dfd8434
4
- data.tar.gz: d4ad70aa5044bf2a733da31b31a6d500e6faa614158095ab53dfee904cb7823a
3
+ metadata.gz: a9f860cd6e9affa3e425cec4c19af7ba3ef489aa5ad29775d52e6cc9dbc032af
4
+ data.tar.gz: 45863d812a7e27c925c5514b003689b548473275c3e7d81513020f59075068a7
5
5
  SHA512:
6
- metadata.gz: 41ebadc85b22529aa2170cfd3daf282a68897148786cf9717483d7fc1e3fab663fef4f328c9c8163273558d517d34bca534f70a4874aa4564005da0a17a9a83c
7
- data.tar.gz: dc0b95995415319ea711668a550e575638b180bd99ebedc796d4316022dd38a70b55ca04f2e4e7ec20531148bff0761b2278bf87fcafdfb73fb2bb9232614c4e
6
+ metadata.gz: fe3a508e7c7a5359a26893a56a90f4d697b438510dd0a8ee62977960254b75d79a136b882abca364bc3c8baa7039e7a74bba131fdec4f792ccd1b93d2824b37b
7
+ data.tar.gz: a31f536e4956e5a4e3094cb881ed835b22bc03815d8229f9bebf1c4c5c2660b920880c858ba9d7f17a6d4f138fd281b714f38e53d2ac3114d11de87239c292cd
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,4 @@
1
+ gN_lU�>�̎]��zM��
2
+ ڏ�(I���k�}z�h��8"[.�w���{��b|�
3
+ ���~y���5��U_�3e[t�Q��!�GdC�7=ѪZ(_��)B� ��<���� �[W��2+B~5ܝ}a�I���UxR�k]��Yt9�@�j��A�����̵��~Bp�є��;��&V�A�P<!.�Q�3�v��w�k��]ۋwF��o��{�9� �J�I� �����������[ܕ�Pӿ�z��!TOolx��6�[q'p<=+��p$�V��O�Z�k�-�l;Lxsn3����F/X8�!HI���iQ��Xů� ���K�������N2��T���e1�!��^<��/�|�Zt��[�j�
4
+ r�5L��[߫�
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
@@ -1,6 +1,7 @@
1
1
  *.gem
2
2
  .bundle
3
3
  Gemfile.lock
4
+ ports/*
4
5
  pkg/*
5
6
  lib/libusb-1.0*
6
7
  lib/pkgconfig
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
+
2
3
  sudo: false
3
- dist: trusty
4
+
5
+ dist: xenial
4
6
  matrix:
5
7
  include:
6
8
  - rvm: ruby-head
@@ -9,13 +11,16 @@ matrix:
9
11
  - rvm: 2.4.3
10
12
  env:
11
13
  - RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
12
- - rvm: 2.0
13
- - rvm: 2.1
14
- - rvm: 2.2.5
14
+ - rvm: 3.0
15
+ env:
16
+ - RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
17
+ - rvm: 2.7
18
+ - rvm: 2.6
15
19
  - rvm: 2.3.1
16
- - rvm: jruby-9.1.5.0
17
- - rvm: rbx-3
20
+ - rvm: jruby-9.2.14.0
21
+ - rvm: truffleruby
22
+
18
23
  allow_failures:
19
- - rvm: rbx-3
20
24
  - rvm: ruby-head
25
+
21
26
  script: bundle exec rake travis
data/Gemfile CHANGED
@@ -8,7 +8,10 @@ group :test do
8
8
  gem 'minitest'
9
9
  end
10
10
 
11
- gem 'rake-compiler-dock', '~> 0.6.0'
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'
12
15
 
13
16
  # For some reason this is required in addition to the gemspec
14
17
  # when 'bundle config force_ruby_platform true' is active:
data/History.md CHANGED
@@ -1,3 +1,41 @@
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
+
1
39
  0.6.4 / 2018-05-05
2
40
  ------------------
3
41
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <!-- -*- coding: utf-8 -*- -->
2
2
 
3
- [![Build Status](https://travis-ci.org/larskanis/libusb.svg?branch=master)](https://travis-ci.org/larskanis/libusb)
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,7 +59,7 @@ 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 1.9/2.x, JRuby or recent version of Rubinius
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:
@@ -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
- Cross compiling for Windows
129
+ Binary gems for Windows and Linux
130
130
  ---------------------------
131
131
 
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) .
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 :test=>:compile do
21
- sh "ruby -w -W2 -I. -Ilib -e \"#{Dir["test/test_*.rb"].map{|f| "require '#{f}';"}.join}\" -- -v"
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
- travis_tests = %w[test_libusb.rb test_libusb_structs.rb]
25
- task :travis=>:compile do
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
- task 'gem:native' do
31
- sh "bundle package"
32
- RakeCompilerDock.sh <<-EOT
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
data/ext/extconf.rb CHANGED
@@ -92,6 +92,7 @@ EOT
92
92
 
93
93
  if libusb_path
94
94
  mf.puts <<-EOT
95
+ mkdir -p $(RUBYARCHDIR)
95
96
  cp -r #{libusb_path.dump}/*/* $(RUBYARCHDIR)
96
97
  EOT
97
98
  end