libusb 0.1.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +23 -0
- data/.gemtest +0 -0
- data/COPYING +165 -0
- data/History.txt +15 -0
- data/Manifest.txt +15 -0
- data/README.rdoc +110 -0
- data/Rakefile +144 -0
- data/lib/libusb/compat.rb +370 -0
- data/lib/libusb-1.0.dll +0 -0
- data/lib/libusb.rb +1523 -0
- data/test/test_libusb_compat.rb +78 -0
- data/test/test_libusb_compat_mass_storage.rb +81 -0
- data/test/test_libusb_descriptors.rb +122 -0
- data/test/test_libusb_gc.rb +37 -0
- data/test/test_libusb_iso_transfer.rb +45 -0
- data/test/test_libusb_mass_storage.rb +271 -0
- metadata +107 -0
data/.autotest
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'autotest/restart'
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.extra_files << "../some/external/dependency.rb"
|
7
|
+
#
|
8
|
+
# at.libs << ":../some/external"
|
9
|
+
#
|
10
|
+
# at.add_exception 'vendor'
|
11
|
+
#
|
12
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
13
|
+
# at.files_matching(/test_.*rb$/)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# %w(TestA TestB).each do |klass|
|
17
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# Autotest.add_hook :run_command do |at|
|
22
|
+
# system "rake build"
|
23
|
+
# end
|
data/.gemtest
ADDED
File without changes
|
data/COPYING
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/History.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
=== 0.1.0 / 2011-04-xx
|
2
|
+
|
3
|
+
* add test suite based on mass storage devices
|
4
|
+
* usable async transfers
|
5
|
+
* migration to rake-compiler and hoe
|
6
|
+
* cross compiled Windows gems
|
7
|
+
* distinct exception classes
|
8
|
+
* new compatibility layer for ruby-usb.gem
|
9
|
+
* many helper methods for different USB descriptors
|
10
|
+
* add LIBUSB constants
|
11
|
+
* downcase methods names
|
12
|
+
|
13
|
+
=== 0.0.1 / 2009-06-23
|
14
|
+
|
15
|
+
* first public release
|
data/Manifest.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
.autotest
|
2
|
+
.gemtest
|
3
|
+
COPYING
|
4
|
+
History.txt
|
5
|
+
Manifest.txt
|
6
|
+
README.rdoc
|
7
|
+
Rakefile
|
8
|
+
lib/libusb.rb
|
9
|
+
lib/libusb/compat.rb
|
10
|
+
test/test_libusb_compat.rb
|
11
|
+
test/test_libusb_compat_mass_storage.rb
|
12
|
+
test/test_libusb_descriptors.rb
|
13
|
+
test/test_libusb_gc.rb
|
14
|
+
test/test_libusb_iso_transfer.rb
|
15
|
+
test/test_libusb_mass_storage.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
= Access USB devices from Ruby via libusb-1.0.
|
4
|
+
|
5
|
+
* http://github.com/larskanis/libusb
|
6
|
+
* API documentation: http://libusb.rubyforge.org/libusb
|
7
|
+
|
8
|
+
== DESCRIPTION:
|
9
|
+
|
10
|
+
LIBUSB is a Ruby binding that gives a Ruby programmer access to all functionality of libusb[http://www.libusb.org], version 1.0.
|
11
|
+
|
12
|
+
* libusb is a library that gives full access to devices connected via the USB bus. No special kernel driver is thus necessary for accessing USB devices.
|
13
|
+
* This Ruby binding supports the API version 1.0 of libusb. Note that the old "legacy" version 0.1.x of libusb uses a completely different API that is covered by the ruby extension ruby-usb[http://www.a-k-r.org/ruby-usb/] . LIBUSB has a compatibility API to ruby-usb[http://www.a-k-r.org/ruby-usb/].
|
14
|
+
|
15
|
+
|
16
|
+
LIBUSB for Ruby is covered by the GNU Lesser General Public License version 3.
|
17
|
+
|
18
|
+
== FEATURES:
|
19
|
+
* Access to descriptors of devices, configurations, interfaces, settings and endpoints
|
20
|
+
* Synchronous and asynchronous communication for bulk, control and interrupt transfers
|
21
|
+
* Compatibility layer for ruby-usb[http://www.a-k-r.org/ruby-usb/] (API based on libusb-0.1). See {::USB} for description.
|
22
|
+
|
23
|
+
== SYNOPSIS:
|
24
|
+
|
25
|
+
require "libusb"
|
26
|
+
|
27
|
+
usb = LIBUSB::Context.new
|
28
|
+
device = usb.devices(:idVendor => 0x04b4, :idProduct => 0x8613).first
|
29
|
+
device.open do |handle|
|
30
|
+
handle.claim_interface(0)
|
31
|
+
handle.control_transfer(:bmRequestType => 0x40, :bRequest => 0xa0, :wValue => 0xe600, :wIndex => 0x0000, :dataOut => 1.chr)
|
32
|
+
handle.release_interface(0)
|
33
|
+
end
|
34
|
+
{LIBUSB::Context#devices} is used to get all or only particular devices.
|
35
|
+
After opening the {LIBUSB::Device} the resulting {LIBUSB::DevHandle} can be
|
36
|
+
used to communicate with the connected USB device
|
37
|
+
by {LIBUSB::DevHandle#control_transfer}, {LIBUSB::DevHandle#bulk_transfer},
|
38
|
+
{LIBUSB::DevHandle#interrupt_transfer} or by using the {LIBUSB::Transfer} classes.
|
39
|
+
|
40
|
+
A {LIBUSB::Device} can also be used to retrieve information about it,
|
41
|
+
by using the device descriptor attributes.
|
42
|
+
A {LIBUSB::Device} could have several configurations. You can then decide of which
|
43
|
+
configuration to enable. You can only enable one configuration at a time.
|
44
|
+
|
45
|
+
Each {LIBUSB::Configuration} has one or more interfaces. This can be seen as functional group
|
46
|
+
performing a single feature of the device.
|
47
|
+
|
48
|
+
Each {LIBUSB::Interface} has at least one {LIBUSB::Setting}. The first setting is always default.
|
49
|
+
An alternate setting can be used independent on each interface.
|
50
|
+
|
51
|
+
Each {LIBUSB::Setting} specifies it's own set of communication endpoints.
|
52
|
+
Each {LIBUSB::Endpoint} specifies the type of transfer, direction, polling interval and
|
53
|
+
maximum packet size.
|
54
|
+
|
55
|
+
|
56
|
+
== REQUIREMENTS:
|
57
|
+
|
58
|
+
* libusb version 1.0 or greater
|
59
|
+
* FFI-gem[http://github.com/ffi/ffi]
|
60
|
+
* Linux, MacOSX or Windows system
|
61
|
+
|
62
|
+
== INSTALL:
|
63
|
+
|
64
|
+
gem install libusb
|
65
|
+
|
66
|
+
In order to use LIBUSB, you need the libusb-1.0 library (but not its header files).
|
67
|
+
* On Debian and Ubuntu system, install the +libusb-1.0-0+ package.
|
68
|
+
* The gem for Windows comes with a precompiled +libusb.dll+ and can be used
|
69
|
+
together with a precompiled FFI-gem, so there is no need for a compiler.
|
70
|
+
|
71
|
+
Latest code can be used in this way:
|
72
|
+
|
73
|
+
git clone git://github.com/larskanis/libusb.git
|
74
|
+
rake install_gem
|
75
|
+
|
76
|
+
|
77
|
+
== Usage on Windows
|
78
|
+
|
79
|
+
In contrast to Linux, any access to an USB device by LIBUSB on Windows requires a proper driver
|
80
|
+
installed in the system. Fortunately creating such a driver is quite easy with
|
81
|
+
Zadig[http://sourceforge.net/apps/mediawiki/libwdi/index.php?title=Main_Page]. Select the interesting USB device
|
82
|
+
and press "Install Driver". That's it. You may take the generated output directory
|
83
|
+
with it's INI-file and use it for driver installation on other 32 or 64 bit Windows
|
84
|
+
systems.
|
85
|
+
|
86
|
+
|
87
|
+
== Cross compiling for mswin32
|
88
|
+
|
89
|
+
Libusb-gem can be build on a linux or darwin host for the win32 platform,
|
90
|
+
using the mingw cross compiler collection. Libusb is downloaded from source
|
91
|
+
git repo, cross compiled and included in the generated libusb.gem.
|
92
|
+
|
93
|
+
Install mingw32. On a debian based system this should work:
|
94
|
+
|
95
|
+
apt-get install mingw32
|
96
|
+
|
97
|
+
On MacOS X, if you have MacPorts installed:
|
98
|
+
|
99
|
+
port install i386-mingw32-gcc
|
100
|
+
|
101
|
+
Download and cross compile libusb for win32:
|
102
|
+
|
103
|
+
rake cross gem
|
104
|
+
|
105
|
+
If everything works, there should be libusb-VERSION-x86-mswin32.gem in the pkg
|
106
|
+
directory.
|
107
|
+
|
108
|
+
== Todo
|
109
|
+
|
110
|
+
* add proper handling for polling and timing: http://libusb.sourceforge.net/api-1.0/group__poll.html
|
data/Rakefile
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'hoe'
|
6
|
+
require 'pathname'
|
7
|
+
require 'uri'
|
8
|
+
require 'rake/extensiontask'
|
9
|
+
require 'rake/extensioncompiler'
|
10
|
+
|
11
|
+
|
12
|
+
# Cross-compilation constants
|
13
|
+
COMPILE_HOME = Pathname( "./tmp" ).expand_path
|
14
|
+
STATIC_SOURCESDIR = COMPILE_HOME + 'sources'
|
15
|
+
STATIC_BUILDDIR = COMPILE_HOME + 'builds'
|
16
|
+
|
17
|
+
# Fetch tarball from sourceforge
|
18
|
+
# LIBUSB_VERSION = ENV['LIBUSB_VERSION'] || '1.0.8'
|
19
|
+
# LIBUSB_SOURCE_URI = URI( "http://downloads.sourceforge.net/project/libusb/libusb-1.0/libusb-#{LIBUSB_VERSION}/libusb-#{LIBUSB_VERSION}.tar.bz2" )
|
20
|
+
# LIBUSB_TARBALL = STATIC_SOURCESDIR + File.basename( LIBUSB_SOURCE_URI.path )
|
21
|
+
|
22
|
+
# Fetch tarball from git repo
|
23
|
+
# LIBUSB_VERSION = ENV['LIBUSB_VERSION'] || '295c9d1'
|
24
|
+
# LIBUSB_SOURCE_URI = URI( "http://git.libusb.org/?p=libusb.git;a=snapshot;h=#{LIBUSB_VERSION};sf=tbz2" )
|
25
|
+
# LIBUSB_TARBALL = STATIC_SOURCESDIR + "libusb-#{LIBUSB_VERSION}.tar.bz2"
|
26
|
+
|
27
|
+
# Fetch tarball from Pete Batard's git repo
|
28
|
+
LIBUSB_VERSION = ENV['LIBUSB_VERSION'] || '52a0e18'
|
29
|
+
LIBUSB_SOURCE_URI = URI( "http://git.libusb.org/?p=libusb-pbatard.git;a=snapshot;h=#{LIBUSB_VERSION};sf=tbz2" )
|
30
|
+
LIBUSB_TARBALL = STATIC_SOURCESDIR + "libusb-pbatard-#{LIBUSB_VERSION}.tar.bz2"
|
31
|
+
|
32
|
+
# Static libusb build vars
|
33
|
+
STATIC_LIBUSB_BUILDDIR = STATIC_BUILDDIR + LIBUSB_TARBALL.basename(".tar.bz2")
|
34
|
+
LIBUSB_CONFIGURE = STATIC_LIBUSB_BUILDDIR + 'configure'
|
35
|
+
LIBUSB_MAKEFILE = STATIC_LIBUSB_BUILDDIR + 'Makefile'
|
36
|
+
LIBUSB_DLL = STATIC_LIBUSB_BUILDDIR + 'libusb/.libs/libusb-1.0.dll'
|
37
|
+
|
38
|
+
|
39
|
+
hoe = Hoe.spec 'libusb' do
|
40
|
+
developer('Lars Kanis', 'kanis@comcard.de')
|
41
|
+
|
42
|
+
extra_deps << ['ffi', '>= 1.0']
|
43
|
+
extra_dev_deps << ['rake-compiler', '>= 0.6']
|
44
|
+
|
45
|
+
self.url = 'http://github.com/larskanis/libusb'
|
46
|
+
self.summary = 'Access USB devices from Ruby via libusb-1.0'
|
47
|
+
self.description = 'LIBUSB is a Ruby binding that gives Ruby programmers access to all functionality of libusb, version 1.0'
|
48
|
+
|
49
|
+
self.readme_file = 'README.rdoc'
|
50
|
+
spec_extras[:rdoc_options] = ['--main', readme_file, "--charset=UTF-8"]
|
51
|
+
self.extra_rdoc_files << self.readme_file
|
52
|
+
|
53
|
+
# clean intermediate files and folders
|
54
|
+
self.clean_globs << STATIC_BUILDDIR.to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
#####################################################################
|
59
|
+
### C R O S S - C O M P I L A T I O N - T A S K S
|
60
|
+
#####################################################################
|
61
|
+
|
62
|
+
directory STATIC_SOURCESDIR.to_s
|
63
|
+
|
64
|
+
#
|
65
|
+
# Static libusb build tasks
|
66
|
+
#
|
67
|
+
directory STATIC_LIBUSB_BUILDDIR.to_s
|
68
|
+
|
69
|
+
# libusb source file should be stored there
|
70
|
+
file LIBUSB_TARBALL => STATIC_SOURCESDIR do |t|
|
71
|
+
# download the source file using wget or curl
|
72
|
+
chdir File.dirname(t.name) do
|
73
|
+
url = LIBUSB_SOURCE_URI
|
74
|
+
sh "wget '#{url}' -O #{LIBUSB_TARBALL}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Extract the libusb builds
|
79
|
+
file STATIC_LIBUSB_BUILDDIR => LIBUSB_TARBALL do |t|
|
80
|
+
sh 'tar', '-xjf', LIBUSB_TARBALL.to_s, '-C', STATIC_LIBUSB_BUILDDIR.parent.to_s
|
81
|
+
LIBUSB_MAKEFILE.unlink if LIBUSB_MAKEFILE.exist?
|
82
|
+
end
|
83
|
+
|
84
|
+
file LIBUSB_CONFIGURE => STATIC_LIBUSB_BUILDDIR do |t|
|
85
|
+
Dir.chdir( STATIC_LIBUSB_BUILDDIR ) do
|
86
|
+
sh "sh autogen.sh && make distclean"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# generate the makefile in a clean build location
|
91
|
+
file LIBUSB_MAKEFILE => LIBUSB_CONFIGURE do |t|
|
92
|
+
Dir.chdir( STATIC_LIBUSB_BUILDDIR ) do
|
93
|
+
options = [
|
94
|
+
'--target=i386-mingw32',
|
95
|
+
"--host=#{Rake::ExtensionCompiler.mingw_host}",
|
96
|
+
]
|
97
|
+
build_host = `sh config.guess`.chomp
|
98
|
+
options << "--build=#{build_host}" unless build_host.to_s.empty?
|
99
|
+
|
100
|
+
configure_path = STATIC_LIBUSB_BUILDDIR + 'configure'
|
101
|
+
cmd = [ configure_path.to_s, *options ]
|
102
|
+
sh *cmd
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# make libusb-1.0.a
|
107
|
+
task LIBUSB_DLL => [ LIBUSB_MAKEFILE ] do |t|
|
108
|
+
Dir.chdir( STATIC_LIBUSB_BUILDDIR ) do
|
109
|
+
sh 'make'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# copy binary from temporary location to final lib
|
114
|
+
task "copy:libusb_dll" => ['lib', LIBUSB_DLL] do
|
115
|
+
install LIBUSB_DLL, "lib/#{File.basename(LIBUSB_DLL)}"
|
116
|
+
end
|
117
|
+
|
118
|
+
desc "compile static libusb libraries"
|
119
|
+
task :libusb_dll => [ "copy:libusb_dll" ]
|
120
|
+
|
121
|
+
desc 'Cross compile libusb for win32'
|
122
|
+
task :cross => [ :mingw32, :libusb_dll ] do |t|
|
123
|
+
spec = hoe.spec.dup
|
124
|
+
spec.instance_variable_set(:"@cache_file", nil) if spec.respond_to?(:cache_file)
|
125
|
+
spec.platform = Gem::Platform.new('i386-mingw32')
|
126
|
+
spec.files << "lib/#{File.basename(LIBUSB_DLL)}"
|
127
|
+
|
128
|
+
# Generate a package for this gem
|
129
|
+
Gem::PackageTask.new(spec) do |pkg|
|
130
|
+
pkg.need_zip = false
|
131
|
+
pkg.need_tar = false
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
task :mingw32 do
|
136
|
+
# Use Rake::ExtensionCompiler helpers to find the proper host
|
137
|
+
unless Rake::ExtensionCompiler.mingw_host then
|
138
|
+
warn "You need to install mingw32 cross compile functionality to be able to continue."
|
139
|
+
warn "Please refer to your distribution/package manager documentation about installation."
|
140
|
+
fail
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# vim: syntax=ruby
|