libusb 0.6.4-x86-mingw32 → 0.7.1-x86-mingw32

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: b014aa2b8c3a259881afea188d917c6863e9c031cb5e3deab0ecd748aa85b68d
4
- data.tar.gz: ef03bfed73f2d41ca9a01b976076800b0a802454da0d25e8e0366ecfa6a76cb6
3
+ metadata.gz: 6c5eaee13200735ec0c245f01a166d6b288562351687ca84d55ebf82739947be
4
+ data.tar.gz: a7855b3dec9923bc15036c1bfdf3892283165a3ed50ae3af59ec1277cfa5b3c0
5
5
  SHA512:
6
- metadata.gz: e63d3b27090e84c87bf6869bb063b0c9e0841a1c0dd641395efc48d6242dc57ad6b4d7017f1e3b6d5d9180ff1fc89c2381107dc8eca032d1bad2f60b42747157
7
- data.tar.gz: 06d28a7e221cf45f131dc694d1580788c3c06c7b7355e3b5cb02cfc20fc61f6368b9cee12cfebb5d6a45a19644e9e3cf2527d9add4369913597b188dcd715cad
6
+ metadata.gz: 3ccf31aa140ea34ee19ecb27e537e1e3ffe22b0caf4ba5b4ef81fd14c4f279400116589a1912ae3ec04ce50bf76bd720e4805e39a8213bf0529581a9eed453ba
7
+ data.tar.gz: c96f97716568bd138cdfadc1398ed8ba247ff492058ad080fef9aa96079c26a4d2725299772e5669761eaebae7cafc75189f27dbd4340e38758eae2a98df00e1
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,49 @@
1
+ 0.7.1 / 2024-04-20
2
+ ------------------
3
+
4
+ Changed:
5
+ * Fix unreferencing LIBUSB::Context from Call::Transfer.
6
+ This prevented freeing of Context objects, as soon as a transfer was executed.
7
+
8
+
9
+ 0.7.0 / 2024-04-18
10
+ ------------------
11
+
12
+ Added:
13
+ * Garbage collect LIBUSB::Context objects. #47
14
+ Context objects were intentionally not garbage collected previously, since it led to segfauls, when the context was freed before other libusb objects.
15
+ Now refcounting all objects bound to a particular Context ensures that the underlying libusb context is always freed at last, avoiding any segfaults.
16
+ Registered log callback and pollfd callbacks are disabled before garbage collecting LIBUSB::Context.
17
+ * Cancel USB transfers on any exceptions not only LIBUSB::Error, but also Interrupt or IRB::Abort, etc.
18
+ Otherwise incomplete transfers lead to LIBUSB::ERROR_BUSY at the next command.
19
+ * Update Windows binary support for ruby up to 3.3.x
20
+ * Update bundled libusb version to 1.0.27.
21
+ * Add support for new functions of libusb-1.0.27
22
+ They are:
23
+ - libusb_init_context
24
+ - libusb_set_log_cb
25
+ - libusb_wrap_sys_device
26
+ * Add global Libusb.set_option and Libusb.set_options . #42
27
+ * Add LIBUSB::Device.max_alt_packet_size. #42
28
+ Introduced in libusb-1.0.27 as libusb_get_max_alt_packet_size()
29
+ * Add BOS platform descriptor introduced in libusb-1.0.27. #49
30
+ * Add enums for all BOS descripors of the USB-3.2-V1.1 spec. #49
31
+
32
+ Changed:
33
+ * Set minimum Ruby version requirement to 2.5.0.
34
+ * Fix a circular reference in ZeroCopyMemory.
35
+ This circular reference blocked all objects referenced by a LIBUSB::Transfer to be released by the garbage collector.
36
+ * Make ZeroCopyMemory an opt-in rather then enforcing it
37
+ In therory libusb_dev_mem_alloc shouldn't provide a pointer unless zero-copy-memory is supported by the linux kernel.
38
+ But in practice this has been a repeating cause of issues, since some kernels don't handle these transfers.
39
+ So it's better to enable it on request only.
40
+ For instance older raspberry pi kernels didn't handle zero-copy-memory.
41
+ * Fix struct member size in Bos::SsUsbDeviceCapability. #48
42
+ The bmAttributes member is defined as uint8_t not uint32_t.
43
+ * Fix context reference in device of hotplug notification callback.
44
+ * Deregister pollfd callbacks in eventmachine_unregister.
45
+
46
+
1
47
  0.6.4 / 2018-05-05
2
48
  ------------------
3
49
 
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,39 +7,53 @@ 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'],
41
- ['x86-linux', 'i686-linux-gnu', 'lib/libusb-1.0.so'],
42
- ['x86_64-linux', 'x86_64-linux-gnu', 'lib/libusb-1.0.so'],
54
+ ['x64-mingw-ucrt', 'x86_64-w64-mingw32', 'bin/libusb-1.0.dll'],
55
+ # ['x86-linux', 'i686-linux-gnu', 'lib/libusb-1.0.so'],
56
+ # ['x86_64-linux', 'x86_64-linux-gnu', 'lib/libusb-1.0.so'],
43
57
  ].map do |ruby_platform, host_platform, libusb_dll|
44
58
  LIBUSB::CrossLibrary.new ruby_platform, host_platform, libusb_dll
45
59
  end
@@ -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