libusb 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c66fa9a97ecf163d05713d9e124447d8de0cef6e
4
+ data.tar.gz: 54c7ec8a19d226fbbd21fec0f2d0372252ba691c
5
+ SHA512:
6
+ metadata.gz: 7da5f1b663be5de6dd92d4d5c1e8487cfb8238d83e6e94201e4771bf378c82ff998fbcf55b8d568ae329f9de0165fcbdc064953523212c45eed19059735adedb
7
+ data.tar.gz: eacb7067b56c6e454178679e880b986a0f393b1548f111e5ad9eba3cc5f256c222f70c616dc4bcb5fcee2d0c205286486ca23f9bafb62d3960536443359a5e81
data/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.3.3 / 2013-04-05
2
+ ------------------
3
+ * Build and package binary x64 version of libusb for Windows in addition to x86.
4
+ * Fix build on Windows from source gem (although may take almost an hour).
5
+
1
6
  0.3.2 / 2013-02-16
2
7
  ------------------
3
8
  * Don't enforces DevKit installation on Windows.
data/Rakefile CHANGED
@@ -2,10 +2,11 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'bundler/gem_tasks'
5
+ require 'rubygems/package_task'
5
6
  require 'pathname'
6
7
  require 'uri'
7
- require 'rake/extensiontask'
8
- require 'rake/extensioncompiler'
8
+ require 'ostruct'
9
+ require 'rake/clean'
9
10
 
10
11
  task :gem => :build
11
12
  task :compile do
@@ -20,17 +21,8 @@ task :travis=>:compile do
20
21
  end
21
22
  task :default => :test
22
23
 
23
- # Cross-compilation constants
24
24
  COMPILE_HOME = Pathname( "./tmp" ).expand_path
25
25
  STATIC_SOURCESDIR = COMPILE_HOME + 'sources'
26
- STATIC_BUILDDIR = COMPILE_HOME + 'builds'
27
- RUBY_BUILD = RbConfig::CONFIG["host"]
28
- CROSS_PREFIX = begin
29
- Rake::ExtensionCompiler.mingw_host
30
- rescue => err
31
- $stderr.puts "Cross-compilation disabled -- %s" % [ err.message ]
32
- 'unknown'
33
- end
34
26
 
35
27
  # Fetch tarball from sourceforge
36
28
  # LIBUSB_VERSION = ENV['LIBUSB_VERSION'] || '1.0.9'
@@ -52,26 +44,11 @@ LIBUSB_TARBALL = STATIC_SOURCESDIR + File.basename( LIBUSB_SOURCE_URI
52
44
  # LIBUSB_SOURCE_URI = URI( "http://git.libusb.org/?p=libusb-pbatard.git;a=snapshot;h=#{LIBUSB_VERSION};sf=tbz2" )
53
45
  # LIBUSB_TARBALL = STATIC_SOURCESDIR + "libusb-pbatard-#{LIBUSB_VERSION}.tar.bz2"
54
46
 
55
- # Static libusb build vars
56
- STATIC_LIBUSB_BUILDDIR = STATIC_BUILDDIR + LIBUSB_TARBALL.basename(".tar.bz2")
57
- LIBUSB_CONFIGURE = STATIC_LIBUSB_BUILDDIR + 'configure'
58
- LIBUSB_MAKEFILE = STATIC_LIBUSB_BUILDDIR + 'Makefile'
59
- LIBUSB_DLL = STATIC_LIBUSB_BUILDDIR + 'libusb/.libs/libusb-1.0.dll'
60
-
61
47
  EXT_BUILDDIR = Pathname( "./ext" ).expand_path
62
48
  EXT_LIBUSB_BUILDDIR = EXT_BUILDDIR + LIBUSB_TARBALL.basename(".tar.bz2")
63
49
 
64
- #####################################################################
65
- ### C R O S S - C O M P I L A T I O N - T A S K S
66
- #####################################################################
67
-
68
50
  directory STATIC_SOURCESDIR.to_s
69
51
 
70
- #
71
- # Static libusb build tasks
72
- #
73
- directory STATIC_LIBUSB_BUILDDIR.to_s
74
-
75
52
  # libusb source file should be stored there
76
53
  file LIBUSB_TARBALL => STATIC_SOURCESDIR do |t|
77
54
  # download the source file using wget or curl
@@ -81,74 +58,118 @@ file LIBUSB_TARBALL => STATIC_SOURCESDIR do |t|
81
58
  end
82
59
  end
83
60
 
84
- # Extract the libusb builds
85
- file STATIC_LIBUSB_BUILDDIR => LIBUSB_TARBALL do |t|
86
- sh 'tar', '-xjf', LIBUSB_TARBALL.to_s, '-C', STATIC_LIBUSB_BUILDDIR.parent.to_s
87
- LIBUSB_MAKEFILE.unlink if LIBUSB_MAKEFILE.exist?
88
- end
89
61
 
90
- file LIBUSB_CONFIGURE => STATIC_LIBUSB_BUILDDIR do |t|
91
- Dir.chdir( STATIC_LIBUSB_BUILDDIR ) do
92
- sh "sh autogen.sh && make distclean"
93
- end
94
- end
62
+ class CrossLibrary < OpenStruct
63
+ include Rake::DSL
95
64
 
96
- LIBUSB_ENV = [
97
- "CFLAGS='-fno-omit-frame-pointer'",
98
- ]
99
-
100
- # generate the makefile in a clean build location
101
- file LIBUSB_MAKEFILE => LIBUSB_CONFIGURE do |t|
102
- Dir.chdir( STATIC_LIBUSB_BUILDDIR ) do
103
- options = [
104
- "--target=#{CROSS_PREFIX}",
105
- "--host=#{CROSS_PREFIX}",
106
- "--build=#{RUBY_BUILD}",
107
- ]
65
+ def initialize(ruby_platform, host_platform)
66
+ super()
108
67
 
109
- configure_path = STATIC_LIBUSB_BUILDDIR + 'configure'
110
- sh "env #{[LIBUSB_ENV, configure_path.to_s, *options].join(" ")}"
111
- end
112
- end
68
+ self.ruby_platform = ruby_platform
69
+ self.host_platform = host_platform
113
70
 
114
- # make libusb-1.0.a
115
- task LIBUSB_DLL => [ LIBUSB_MAKEFILE ] do |t|
116
- Dir.chdir( STATIC_LIBUSB_BUILDDIR ) do
117
- sh 'make'
118
- end
119
- end
71
+ self.static_builddir = COMPILE_HOME + 'builds' + ruby_platform
72
+ self.ruby_build = RbConfig::CONFIG["host"]
120
73
 
121
- # copy binary from temporary location to final lib
122
- task "copy:libusb_dll" => ['lib', LIBUSB_DLL] do
123
- install LIBUSB_DLL, "lib/#{File.basename(LIBUSB_DLL)}"
124
- end
74
+ # Static libusb build vars
75
+ self.static_libusb_builddir = static_builddir + LIBUSB_TARBALL.basename(".tar.bz2")
76
+ self.libusb_configure = static_libusb_builddir + 'configure'
77
+ self.libusb_makefile = static_libusb_builddir + 'Makefile'
78
+ self.libusb_dll = static_libusb_builddir + 'libusb/.libs/libusb-1.0.dll'
79
+
80
+ #
81
+ # Static libusb build tasks
82
+ #
83
+ CLEAN.include static_libusb_builddir.to_s
84
+
85
+ directory static_libusb_builddir.to_s
125
86
 
126
- desc "compile static libusb libraries"
127
- task :libusb_dll => [ "copy:libusb_dll" ]
128
-
129
- desc 'Cross compile libusb for win32'
130
- task :cross => [ :mingw32, :libusb_dll ] do |t|
131
- spec = Gem::Specification::load("libusb.gemspec")
132
- spec.instance_variable_set(:"@cache_file", nil) if spec.respond_to?(:cache_file)
133
- spec.platform = Gem::Platform.new('i386-mingw32')
134
- spec.files << "lib/#{File.basename(LIBUSB_DLL)}"
135
- spec.files -= `git ls-files ext`.split("\n")
136
- spec.extensions = []
137
-
138
- # Generate a package for this gem
139
- Gem::PackageTask.new(spec) do |pkg|
140
- pkg.need_zip = false
141
- pkg.need_tar = false
87
+ # Extract the libusb builds
88
+ file static_libusb_builddir => LIBUSB_TARBALL do |t|
89
+ sh 'tar', '-xjf', LIBUSB_TARBALL.to_s, '-C', static_libusb_builddir.parent.to_s
90
+ libusb_makefile.unlink if libusb_makefile.exist?
91
+ end
92
+
93
+ file libusb_configure => static_libusb_builddir do |t|
94
+ Dir.chdir( static_libusb_builddir ) do
95
+ sh "sh autogen.sh && make distclean"
96
+ end
97
+ end
98
+
99
+ libusb_env = [
100
+ "CFLAGS='-fno-omit-frame-pointer'",
101
+ ]
102
+
103
+ # generate the makefile in a clean build location
104
+ file libusb_makefile => libusb_configure do |t|
105
+ Dir.chdir( static_libusb_builddir ) do
106
+ options = [
107
+ "--target=#{host_platform}",
108
+ "--host=#{host_platform}",
109
+ "--build=#{ruby_build}",
110
+ ]
111
+
112
+ configure_path = static_libusb_builddir + 'configure'
113
+ sh "env #{[libusb_env, configure_path.to_s, *options].join(" ")}"
114
+ end
115
+ end
116
+
117
+ # make libusb-1.0.dll
118
+ task libusb_dll => [ libusb_makefile ] do |t|
119
+ Dir.chdir( static_libusb_builddir ) do
120
+ sh 'make'
121
+ end
122
+ end
123
+
124
+ task "libusb_dll:#{ruby_platform}" => libusb_dll
125
+
126
+ desc "compile static libusb libraries"
127
+ task :libusb_dll => "libusb_dll:#{ruby_platform}"
128
+
129
+ desc 'Cross compile libusb for win32'
130
+ task :cross => [ "libusb_dll:#{ruby_platform}" ] do |t|
131
+ spec = Gem::Specification::load("libusb.gemspec")
132
+ spec.instance_variable_set(:"@cache_file", nil) if spec.respond_to?(:cache_file)
133
+ spec.platform = Gem::Platform.new(ruby_platform)
134
+ spec.files << "lib/#{File.basename(libusb_dll)}"
135
+ spec.files -= `git ls-files ext`.split("\n")
136
+ spec.extensions = []
137
+
138
+ # Generate a package for this gem
139
+ pkg = Gem::PackageTask.new(spec) do |pkg|
140
+ pkg.need_zip = false
141
+ pkg.need_tar = false
142
+ # Do not copy any files per PackageTask, because
143
+ # we need the files from the platform specific directory
144
+ pkg.package_files.clear
145
+ end
146
+
147
+ # copy files of the gem to pkg directory
148
+ file pkg.package_dir_path => spec.files do
149
+ spec.files.each do |fn|
150
+ next if fn == "lib/#{File.basename(libusb_dll)}"
151
+ f = File.join(pkg.package_dir_path, fn)
152
+ fdir = File.dirname(f)
153
+ mkdir_p(fdir) if !File.exist?(fdir)
154
+ rm_f f
155
+ safe_ln(fn, f)
156
+ end
157
+ end
158
+ # copy libusb.dll to pkg directory
159
+ file pkg.package_dir_path => [libusb_dll] do
160
+ f = "#{pkg.package_dir_path}/lib/#{File.basename(libusb_dll)}"
161
+ rm_f f
162
+ safe_ln libusb_dll, f
163
+ end
164
+ end
142
165
  end
143
166
  end
144
167
 
145
- task :mingw32 do
146
- # Use Rake::ExtensionCompiler helpers to find the proper host
147
- unless Rake::ExtensionCompiler.mingw_host then
148
- warn "You need to install mingw32 cross compile functionality to be able to continue."
149
- warn "Please refer to your distribution/package manager documentation about installation."
150
- fail
151
- end
168
+ CrossLibraries = [
169
+ ['i386-mingw32', 'i686-w64-mingw32'],
170
+ ['x64-mingw32', 'x86_64-w64-mingw32'],
171
+ ].map do |ruby_platform, host_platform|
172
+ CrossLibrary.new ruby_platform, host_platform
152
173
  end
153
174
 
154
175
  desc "Download and update bundled libusb(x)"
data/ext/extconf.rb CHANGED
@@ -24,7 +24,7 @@ rescue LoadError
24
24
 
25
25
  old_dir = Dir.pwd
26
26
  Dir.chdir libusb_dir
27
- cmd = "./configure --prefix=#{root_dir} && make && make install"
27
+ cmd = "sh configure --prefix=#{root_dir} && make && make install"
28
28
  puts cmd
29
29
  system cmd
30
30
  raise "libusb build exited with #{$?.exitstatus}" if $?.exitstatus!=0
@@ -15,5 +15,5 @@
15
15
 
16
16
  module LIBUSB
17
17
  # Library version of libusb for Ruby
18
- VERSION = "0.3.2"
18
+ VERSION = "0.3.3"
19
19
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libusb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
5
- prerelease:
4
+ version: 0.3.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Lars Kanis
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-16 00:00:00.000000000 Z
11
+ date: 2013-04-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ffi
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake-compiler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0.6'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0.6'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: LIBUSB is a Ruby binding that gives Ruby programmers access to arbitrary
@@ -171,6 +164,7 @@ files:
171
164
  - test/test_libusb_version.rb
172
165
  homepage: http://github.com/larskanis/libusb
173
166
  licenses: []
167
+ metadata: {}
174
168
  post_install_message:
175
169
  rdoc_options:
176
170
  - --main
@@ -179,21 +173,19 @@ rdoc_options:
179
173
  require_paths:
180
174
  - lib
181
175
  required_ruby_version: !ruby/object:Gem::Requirement
182
- none: false
183
176
  requirements:
184
- - - ! '>='
177
+ - - '>='
185
178
  - !ruby/object:Gem::Version
186
179
  version: '0'
187
180
  required_rubygems_version: !ruby/object:Gem::Requirement
188
- none: false
189
181
  requirements:
190
- - - ! '>='
182
+ - - '>='
191
183
  - !ruby/object:Gem::Version
192
184
  version: '0'
193
185
  requirements: []
194
186
  rubyforge_project: libusb
195
- rubygems_version: 1.8.24
187
+ rubygems_version: 2.0.0.rc.2
196
188
  signing_key:
197
- specification_version: 3
189
+ specification_version: 4
198
190
  summary: Access USB devices from Ruby via libusb-1.0
199
191
  test_files: []