libusb 0.6.0 → 0.6.1
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/History.md +4 -0
- data/Rakefile +10 -107
- data/ext/extconf.rb +18 -8
- data/lib/libusb/gem_helper.rb +147 -0
- data/lib/libusb/libusb_recipe.rb +30 -0
- data/lib/libusb/version_gem.rb +1 -1
- metadata +4 -3
- data/ext/libusb_recipe.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d10e2e32a39c91c08f9616235af0a6e20553caa5
|
4
|
+
data.tar.gz: 5c2984d326011377c7c4524a9bc67efdd5d6a92c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14d47a300ad5cd0300e613d06a935d235a4e11313f5eedc5e8949c06d10a45696a2ac10585e1a4a64b35bc27465d3e8866ab610c0a10ebdd0fca4ced96b73772
|
7
|
+
data.tar.gz: b9c5c9c227b3564cc4afbba4c6334532e923070ed3ce139f051c82ec4c0ead653b140b728aad702f58412fbbdf155fa6a1158bfbeacb9ed8edb864cab9d5c66f
|
data/History.md
CHANGED
data/Rakefile
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require 'bundler/
|
4
|
+
require 'bundler/gem_helper'
|
5
5
|
require 'rubygems/package_task'
|
6
6
|
require 'pathname'
|
7
7
|
require 'uri'
|
8
8
|
require 'ostruct'
|
9
9
|
require 'rake/clean'
|
10
10
|
require 'rake_compiler_dock'
|
11
|
-
require_relative '
|
11
|
+
require_relative 'lib/libusb/libusb_recipe'
|
12
|
+
require_relative 'lib/libusb/gem_helper'
|
12
13
|
|
13
14
|
task :gem => :build
|
14
15
|
task :compile do
|
15
|
-
sh "ruby ext
|
16
|
+
sh "ruby -C ext extconf.rb --disable-system-libusb"
|
17
|
+
sh "make -C ext install RUBYARCHDIR=../lib"
|
16
18
|
end
|
17
19
|
|
18
20
|
task :test=>:compile do
|
@@ -25,123 +27,24 @@ task :travis=>:compile do
|
|
25
27
|
end
|
26
28
|
task :default => :test
|
27
29
|
|
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]*|$)'
|
33
|
-
|
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
|
44
|
-
|
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
|
52
|
-
|
53
|
-
task "release:guard_clean" => "release:tag"
|
54
|
-
|
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")
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
30
|
task 'gem:native' do
|
63
31
|
sh "bundle package"
|
64
32
|
RakeCompilerDock.sh <<-EOT
|
65
|
-
sudo apt-get update &&
|
66
|
-
sudo apt-get -y install libudev-dev libudev-dev:i386 &
|
67
33
|
bundle --local &&
|
68
34
|
rake cross gem
|
69
35
|
EOT
|
70
36
|
end
|
71
37
|
|
72
|
-
class CrossLibrary < OpenStruct
|
73
|
-
include Rake::DSL
|
74
|
-
|
75
|
-
def initialize(ruby_platform, host_platform, libusb_dllname)
|
76
|
-
super()
|
77
|
-
|
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
|
83
|
-
|
84
|
-
file libusb_dll do
|
85
|
-
recipe.cook
|
86
|
-
end
|
87
|
-
|
88
|
-
task "libusb_dll:#{ruby_platform}" => libusb_dll
|
89
|
-
|
90
|
-
desc 'Cross compile libusb for win32'
|
91
|
-
task :cross => [ "libusb_dll:#{ruby_platform}" ] do |t|
|
92
|
-
spec = Gem::Specification::load("libusb.gemspec").dup
|
93
|
-
spec.platform = Gem::Platform.new(ruby_platform)
|
94
|
-
spec.extensions = []
|
95
|
-
|
96
|
-
# Remove files unnecessary for native gems
|
97
|
-
spec.files -= `git ls-files ext`.split("\n")
|
98
|
-
spec.files.reject!{|f| f.start_with?('ports') }
|
99
|
-
spec_text_files = spec.files.dup
|
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" }
|
106
|
-
|
107
|
-
# Generate a package for this gem
|
108
|
-
pkg = Gem::PackageTask.new(spec) do |pkg|
|
109
|
-
pkg.need_zip = false
|
110
|
-
pkg.need_tar = false
|
111
|
-
# Do not copy any files per PackageTask, because
|
112
|
-
# we need the files from the platform specific directory
|
113
|
-
pkg.package_files.clear
|
114
|
-
end
|
115
|
-
|
116
|
-
# copy files of the gem to pkg directory
|
117
|
-
file pkg.package_dir_path => spec_text_files do
|
118
|
-
spec_text_files.each do |fn|
|
119
|
-
f = File.join(pkg.package_dir_path, fn)
|
120
|
-
fdir = File.dirname(f)
|
121
|
-
mkdir_p(fdir) if !File.exist?(fdir)
|
122
|
-
rm_f f
|
123
|
-
safe_ln(fn, f)
|
124
|
-
end
|
125
|
-
|
126
|
-
# copy libusb.dll to pkg directory
|
127
|
-
f = "#{pkg.package_dir_path}/lib/#{libusb_dll.basename}"
|
128
|
-
mkdir_p File.dirname(f)
|
129
|
-
rm_f f
|
130
|
-
safe_ln libusb_dll.realpath, f
|
131
|
-
end
|
132
|
-
|
133
|
-
file "lib/#{libusb_dll.basename}" => [libusb_dll]
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
38
|
CrossLibraries = [
|
139
39
|
['x86-mingw32', 'i686-w64-mingw32', 'bin/libusb-1.0.dll'],
|
140
40
|
['x64-mingw32', 'x86_64-w64-mingw32', 'bin/libusb-1.0.dll'],
|
141
41
|
['x86-linux', 'i686-linux-gnu', 'lib/libusb-1.0.so'],
|
142
42
|
['x86_64-linux', 'x86_64-linux-gnu', 'lib/libusb-1.0.so'],
|
143
|
-
].
|
144
|
-
CrossLibrary.new ruby_platform, host_platform, libusb_dll
|
43
|
+
].map do |ruby_platform, host_platform, libusb_dll|
|
44
|
+
LIBUSB::CrossLibrary.new ruby_platform, host_platform, libusb_dll
|
145
45
|
end
|
146
46
|
|
47
|
+
LIBUSB::GemHelper.install_tasks
|
48
|
+
Bundler::GemHelper.instance.cross_platforms = CrossLibraries.map(&:ruby_platform)
|
49
|
+
|
147
50
|
# vim: syntax=ruby
|
data/ext/extconf.rb
CHANGED
@@ -68,21 +68,31 @@ def build_bundled_libusb(have_udev)
|
|
68
68
|
# without hot-plugging.
|
69
69
|
have_udev &&= have_header('libudev.h') && have_library('udev', 'udev_new')
|
70
70
|
|
71
|
-
require_relative 'libusb_recipe'
|
72
|
-
recipe = LibusbRecipe.new
|
71
|
+
require_relative '../lib/libusb/libusb_recipe'
|
72
|
+
recipe = LIBUSB::LibusbRecipe.new
|
73
73
|
recipe.configure_options << "--disable-udev" unless have_udev
|
74
74
|
recipe.cook_and_activate
|
75
|
-
|
76
|
-
cp_r File.join(recipe.path, '.'), '.', verbose: true, remove_destination: true
|
75
|
+
recipe.path
|
77
76
|
end
|
78
77
|
|
79
78
|
unless enable_config('system-libusb', libusb_usable?)
|
80
79
|
# Unable to load libusb library on this system,
|
81
80
|
# so we build our bundled version:
|
82
|
-
build_bundled_libusb(have_udev)
|
81
|
+
libusb_path = build_bundled_libusb(have_udev)
|
83
82
|
end
|
84
83
|
|
85
|
-
|
86
|
-
|
87
|
-
mf.puts
|
84
|
+
# Create a Makefile which copies the libusb library files to the gem's lib dir.
|
85
|
+
File.open("Makefile", "wb") do |mf|
|
86
|
+
mf.puts <<-EOT
|
87
|
+
RUBYARCHDIR = #{RbConfig::MAKEFILE_CONFIG['sitearchdir'].dump}
|
88
|
+
all:
|
89
|
+
clean:
|
90
|
+
install:
|
91
|
+
EOT
|
92
|
+
|
93
|
+
if libusb_path
|
94
|
+
mf.puts <<-EOT
|
95
|
+
cp -r #{File.join(libusb_path, "lib").dump}/* $(RUBYARCHDIR)
|
96
|
+
EOT
|
97
|
+
end
|
88
98
|
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# This file is part of Libusb for Ruby.
|
2
|
+
#
|
3
|
+
# Libusb for Ruby is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# Libusb for Ruby is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public License
|
14
|
+
# along with Libusb for Ruby. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
require "bundler/gem_helper"
|
17
|
+
|
18
|
+
module LIBUSB
|
19
|
+
class GemHelper < Bundler::GemHelper
|
20
|
+
attr_accessor :cross_platforms
|
21
|
+
|
22
|
+
def install
|
23
|
+
super
|
24
|
+
|
25
|
+
task "release:guard_clean" => ["release:update_history"]
|
26
|
+
|
27
|
+
task "release:update_history" do
|
28
|
+
update_history
|
29
|
+
end
|
30
|
+
|
31
|
+
task "release:rubygem_push" => ["gem:native"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def hfile
|
35
|
+
"History.md"
|
36
|
+
end
|
37
|
+
|
38
|
+
def headline
|
39
|
+
'([^\w]*)(\d+\.\d+\.\d+)([^\w]+)([2Y][0Y][0-9Y][0-9Y]-[0-1M][0-9M]-[0-3D][0-9D])([^\w]*|$)'
|
40
|
+
end
|
41
|
+
|
42
|
+
def reldate
|
43
|
+
Time.now.strftime("%Y-%m-%d")
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_history
|
47
|
+
hin = File.read(hfile)
|
48
|
+
hout = hin.sub(/#{headline}/) do
|
49
|
+
raise "#{hfile} isn't up-to-date for version #{version}" unless $2==version.to_s
|
50
|
+
$1 + $2 + $3 + reldate + $5
|
51
|
+
end
|
52
|
+
if hout != hin
|
53
|
+
Bundler.ui.confirm "Updating #{hfile} for release."
|
54
|
+
File.write(hfile, hout)
|
55
|
+
Rake::FileUtilsExt.sh "git", "commit", hfile, "-m", "Update release date in #{hfile}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def tag_version
|
60
|
+
Bundler.ui.confirm "Tag release with annotation:"
|
61
|
+
m = File.read(hfile).match(/(?<annotation>#{headline}.*?)#{headline}/m) || raise("Unable to find release notes in #{hfile}")
|
62
|
+
Bundler.ui.info(m[:annotation].gsub(/^/, " "))
|
63
|
+
IO.popen(["git", "tag", "--file=-", version_tag], "w") do |fd|
|
64
|
+
fd.write m[:annotation]
|
65
|
+
end
|
66
|
+
yield if block_given?
|
67
|
+
rescue
|
68
|
+
Bundler.ui.error "Untagging #{version_tag} due to error."
|
69
|
+
sh_with_code "git tag -d #{version_tag}"
|
70
|
+
raise
|
71
|
+
end
|
72
|
+
|
73
|
+
def rubygem_push(path)
|
74
|
+
cross_platforms.each do |ruby_platform|
|
75
|
+
super(path.gsub(/\.gem\z/, "-#{ruby_platform}.gem"))
|
76
|
+
end
|
77
|
+
super(path)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
class CrossLibrary < OpenStruct
|
83
|
+
include Rake::DSL
|
84
|
+
|
85
|
+
def initialize(ruby_platform, host_platform, libusb_dllname)
|
86
|
+
super()
|
87
|
+
|
88
|
+
self.ruby_platform = ruby_platform
|
89
|
+
self.recipe = LIBUSB::LibusbRecipe.new
|
90
|
+
recipe.host = host_platform
|
91
|
+
recipe.configure_options << "--host=#{recipe.host}"
|
92
|
+
self.libusb_dll = Pathname.new(recipe.path) + libusb_dllname
|
93
|
+
|
94
|
+
file libusb_dll do
|
95
|
+
recipe.cook
|
96
|
+
end
|
97
|
+
|
98
|
+
task "libusb_dll:#{ruby_platform}" => libusb_dll
|
99
|
+
|
100
|
+
desc 'Cross compile libusb for win32'
|
101
|
+
task :cross => [ "libusb_dll:#{ruby_platform}" ] do |t|
|
102
|
+
spec = Gem::Specification::load("libusb.gemspec").dup
|
103
|
+
spec.platform = Gem::Platform.new(ruby_platform)
|
104
|
+
spec.extensions = []
|
105
|
+
|
106
|
+
# Remove files unnecessary for native gems
|
107
|
+
spec.files -= `git ls-files ext`.split("\n")
|
108
|
+
spec.files.reject!{|f| f.start_with?('ports') }
|
109
|
+
spec_text_files = spec.files.dup
|
110
|
+
|
111
|
+
# Add native libusb-dll
|
112
|
+
spec.files << "lib/#{libusb_dll.basename}"
|
113
|
+
|
114
|
+
# MiniPortile isn't required for native gems
|
115
|
+
spec.dependencies.reject!{|d| d.name=="mini_portile2" }
|
116
|
+
|
117
|
+
# Generate a package for this gem
|
118
|
+
pkg = Gem::PackageTask.new(spec) do |pkg|
|
119
|
+
pkg.need_zip = false
|
120
|
+
pkg.need_tar = false
|
121
|
+
# Do not copy any files per PackageTask, because
|
122
|
+
# we need the files from the platform specific directory
|
123
|
+
pkg.package_files.clear
|
124
|
+
end
|
125
|
+
|
126
|
+
# copy files of the gem to pkg directory
|
127
|
+
file pkg.package_dir_path => spec_text_files do
|
128
|
+
spec_text_files.each do |fn|
|
129
|
+
f = File.join(pkg.package_dir_path, fn)
|
130
|
+
fdir = File.dirname(f)
|
131
|
+
mkdir_p(fdir) if !File.exist?(fdir)
|
132
|
+
rm_f f
|
133
|
+
safe_ln(fn, f)
|
134
|
+
end
|
135
|
+
|
136
|
+
# copy libusb.dll to pkg directory
|
137
|
+
f = "#{pkg.package_dir_path}/lib/#{libusb_dll.basename}"
|
138
|
+
mkdir_p File.dirname(f)
|
139
|
+
rm_f f
|
140
|
+
safe_ln libusb_dll.realpath, f
|
141
|
+
end
|
142
|
+
|
143
|
+
file "lib/#{libusb_dll.basename}" => [libusb_dll]
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'dependencies'
|
2
|
+
require 'rubygems'
|
3
|
+
# Keep the version constraint in sync with libusb.gemspec
|
4
|
+
gem "mini_portile2", LIBUSB::MINI_PORTILE_VERSION
|
5
|
+
require "mini_portile2"
|
6
|
+
|
7
|
+
module LIBUSB
|
8
|
+
class LibusbRecipe < MiniPortile
|
9
|
+
ROOT = File.expand_path('../../..', __FILE__)
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super("libusb", LIBUSB_VERSION)
|
13
|
+
self.target = File.join(ROOT, "ports")
|
14
|
+
self.files = [url: LIBUSB_SOURCE_URI, sha1: LIBUSB_SOURCE_SHA1]
|
15
|
+
self.configure_options = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def cook_and_activate
|
19
|
+
checkpoint = File.join(self.target, "#{self.name}-#{self.version}-#{self.host}.installed")
|
20
|
+
unless File.exist?(checkpoint)
|
21
|
+
self.cook
|
22
|
+
FileUtils.touch checkpoint
|
23
|
+
end
|
24
|
+
self.activate
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
public :files_hashs
|
29
|
+
end
|
30
|
+
end
|
data/lib/libusb/version_gem.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libusb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Kanis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -99,7 +99,6 @@ files:
|
|
99
99
|
- Rakefile
|
100
100
|
- appveyor.yml
|
101
101
|
- ext/extconf.rb
|
102
|
-
- ext/libusb_recipe.rb
|
103
102
|
- lib/libusb.rb
|
104
103
|
- lib/libusb/bos.rb
|
105
104
|
- lib/libusb/call.rb
|
@@ -112,7 +111,9 @@ files:
|
|
112
111
|
- lib/libusb/device.rb
|
113
112
|
- lib/libusb/endpoint.rb
|
114
113
|
- lib/libusb/eventmachine.rb
|
114
|
+
- lib/libusb/gem_helper.rb
|
115
115
|
- lib/libusb/interface.rb
|
116
|
+
- lib/libusb/libusb_recipe.rb
|
116
117
|
- lib/libusb/setting.rb
|
117
118
|
- lib/libusb/ss_companion.rb
|
118
119
|
- lib/libusb/stdio.rb
|
data/ext/libusb_recipe.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require_relative '../lib/libusb/dependencies'
|
2
|
-
require 'rubygems'
|
3
|
-
# NOTE: Keep this version constraint in sync with libusb.gemspec
|
4
|
-
gem "mini_portile2", LIBUSB::MINI_PORTILE_VERSION
|
5
|
-
require "mini_portile2"
|
6
|
-
|
7
|
-
class LibusbRecipe < MiniPortile
|
8
|
-
include LIBUSB
|
9
|
-
ROOT = File.expand_path('../..', __FILE__)
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
super("libusb", LIBUSB_VERSION)
|
13
|
-
self.target = File.join(ROOT, "ports")
|
14
|
-
self.files = [url: LIBUSB_SOURCE_URI, sha1: LIBUSB_SOURCE_SHA1]
|
15
|
-
self.configure_options = []
|
16
|
-
end
|
17
|
-
|
18
|
-
def cook_and_activate
|
19
|
-
checkpoint = File.join(self.target, "#{self.name}-#{self.version}-#{self.host}.installed")
|
20
|
-
unless File.exist?(checkpoint)
|
21
|
-
self.cook
|
22
|
-
FileUtils.touch checkpoint
|
23
|
-
end
|
24
|
-
self.activate
|
25
|
-
self
|
26
|
-
end
|
27
|
-
|
28
|
-
public :files_hashs
|
29
|
-
end
|