rake-compiler 0.7.1 → 0.7.5
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.
- data/History.txt +21 -0
- data/Isolate +9 -0
- data/README.rdoc +320 -301
- data/Rakefile +3 -5
- data/features/step_definitions/gem.rb +5 -1
- data/features/support/file_template_helpers.rb +1 -1
- data/lib/rake/extensiontask.rb +18 -5
- data/spec/lib/rake/extensiontask_spec.rb +2 -0
- data/tasks/bin/cross-ruby.rake +10 -17
- data/tasks/bootstrap.rake +11 -0
- data/tasks/common.rake +0 -3
- data/tasks/gem.rake +4 -3
- data/tasks/news.rake +38 -78
- data/tasks/release.rake +19 -64
- metadata +8 -17
- data/tasks/rdoc.rake +0 -15
- data/tasks/rdoc_publish.rake +0 -41
data/History.txt
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
=== 0.7.5 / 2010-11-25
|
2
|
+
|
3
|
+
* Enhancements:
|
4
|
+
* Promoted stable version for cross-compilation to 1.8.6-p398. Closes GH-19
|
5
|
+
|
6
|
+
* Bugfixes:
|
7
|
+
* Generate a fake.rb compatible with Ruby 1.9.2. Closes GH-25
|
8
|
+
* fake.rb will not try to mimic Ruby's own fake to the letter. Closes GH-28
|
9
|
+
* Expand symlinks for tmp_dir. Closes GH-24
|
10
|
+
* Silence make output during rake-compiler invocation.
|
11
|
+
* Usage of Gem.ruby instead of RbConfig ruby_install_name
|
12
|
+
This solve issues with ruby vs. ruby.exe and jruby.exe
|
13
|
+
|
14
|
+
* Experimental:
|
15
|
+
* Allow setting of HOST during cross-compilation. This enable usage
|
16
|
+
of mingw-w64 compiler and not the first one found in the PATH.
|
17
|
+
|
18
|
+
rake-compiler cross-ruby VERSION=1.9.2-p0 HOST=i686-w64-mingw32
|
19
|
+
rake-compiler cross-ruby HOST=i386-mingw32 (OSX mingw32 port)
|
20
|
+
rake-compiler cross-ruby HOST=i586-pc-mingw32 (Debian/Ubuntu mingw32)
|
21
|
+
|
1
22
|
=== 0.7.1 / 2010-08-07
|
2
23
|
|
3
24
|
* Bugfixes:
|
data/Isolate
ADDED
data/README.rdoc
CHANGED
@@ -1,301 +1,320 @@
|
|
1
|
-
= rake-compiler
|
2
|
-
|
3
|
-
rake-compiler aims to help Gem developers deal with Ruby extensions, simplifying
|
4
|
-
code and reducing duplication.
|
5
|
-
|
6
|
-
It followss *convention over configuration* and sets a standardized structure to
|
7
|
-
build and package both C and Java extensions in your gems.
|
8
|
-
|
9
|
-
This is the result of experiences dealing with several Gems that required native
|
10
|
-
extensions across platforms and different user configurations where details like
|
11
|
-
portability and clarity of code were lacking.
|
12
|
-
|
13
|
-
== An Overview
|
14
|
-
|
15
|
-
Let's summarize what rake-compiler provides:
|
16
|
-
|
17
|
-
* No custom rake tasks required. Less code duplication and errors.
|
18
|
-
|
19
|
-
* Painlessly build extensions on different platforms (Linux, OSX and Windows).
|
20
|
-
|
21
|
-
* Painlessly build extensions for different Ruby implementations (JRuby,
|
22
|
-
Rubinius and MRI).
|
23
|
-
|
24
|
-
* Allow multiple extensions be compiled inside the same gem.
|
25
|
-
|
26
|
-
* Mimics RubyGems installation process, so helps as a test environment.
|
27
|
-
|
28
|
-
* Simplify cross platform compilation of extensions (target Windows from Linux).
|
29
|
-
|
30
|
-
== I'm sold! show me how to use it! (Installation)
|
31
|
-
|
32
|
-
Usage of rake-compiler is pretty much straight forward.
|
33
|
-
|
34
|
-
First, you need to install the gem:
|
35
|
-
|
36
|
-
$ gem install rake-compiler
|
37
|
-
|
38
|
-
== Now what? (Usage)
|
39
|
-
|
40
|
-
Now that you have the gem installed, let's give your project some structure.
|
41
|
-
|
42
|
-
=== Structure
|
43
|
-
|
44
|
-
Let's say we want to compile an extension called 'hello_world', so we should
|
45
|
-
organize the code and folders that will help rake-compiler do its job:
|
46
|
-
|
47
|
-
|-- ext
|
48
|
-
| `-- hello_world
|
49
|
-
| |-- extconf.rb
|
50
|
-
| |-- HelloWorldService.java
|
51
|
-
| `-- hello_world.c
|
52
|
-
|-- lib
|
53
|
-
`-- Rakefile
|
54
|
-
|
55
|
-
TIP: Having a consistent folder structure will help developers and newcomers
|
56
|
-
to find code and also contribute back to your project more easily.
|
57
|
-
|
58
|
-
=== Adding the code
|
59
|
-
|
60
|
-
So now it's time to introduce the code to compile our extension:
|
61
|
-
|
62
|
-
# File: Rakefile
|
63
|
-
|
64
|
-
require 'rake/extensiontask'
|
65
|
-
|
66
|
-
Rake::ExtensionTask.new('hello_world')
|
67
|
-
|
68
|
-
Ok, that's it. No other line of code.
|
69
|
-
|
70
|
-
If we wanted to do the same for a JRuby extension (written in Java):
|
71
|
-
|
72
|
-
# File: Rakefile
|
73
|
-
|
74
|
-
require 'rake/javaextensiontask'
|
75
|
-
|
76
|
-
Rake::JavaExtensionTask.new('hello_world')
|
77
|
-
|
78
|
-
=== Compile process
|
79
|
-
|
80
|
-
Those *two* lines of code automatically added the needed rake tasks to build
|
81
|
-
the hello_world extension. Running Rake on 1.8.x/1.9 (MRI):
|
82
|
-
|
83
|
-
$ rake -T
|
84
|
-
(in /home/user/my_extension)
|
85
|
-
rake compile # Compile the extension(s)
|
86
|
-
rake compile:hello_world # Compile just the hello_world extension
|
87
|
-
|
88
|
-
Simply calling <tt>compile</tt>:
|
89
|
-
|
90
|
-
$ rake compile
|
91
|
-
|
92
|
-
Will do all the compile process for us, putting the result extension inside
|
93
|
-
<tt>lib</tt> directory.
|
94
|
-
|
95
|
-
NOTE: Please be aware that building C extensions requires the proper
|
96
|
-
development environment for your Platform, which includes libraries, headers
|
97
|
-
and build tools. Check your distro / vendor documentation on how to install it.
|
98
|
-
|
99
|
-
NOTE: Building Java extensions requires the <tt>javac</tt>, part of the Java
|
100
|
-
Development Kit (JDK). This should be included by default on Mac OS X, and
|
101
|
-
downloadable from http://java.sun.com for other operating systems.
|
102
|
-
|
103
|
-
=== Generate native gems
|
104
|
-
|
105
|
-
A common usage scenario of rake-compiler is generate native gems that bundles
|
106
|
-
your extensions.
|
107
|
-
|
108
|
-
This got over-simplified with <tt>Rake::ExtensionTask</tt>:
|
109
|
-
|
110
|
-
# somewhere in your Rakefile, define your gem spec
|
111
|
-
spec = Gem::Specification.new do |s|
|
112
|
-
s.name = "my_gem"
|
113
|
-
s.platform = Gem::Platform::RUBY
|
114
|
-
s.extensions = FileList["ext/**/extconf.rb"]
|
115
|
-
end
|
116
|
-
|
117
|
-
# add your default gem packing task
|
118
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
119
|
-
end
|
120
|
-
|
121
|
-
# feed your ExtensionTask with your spec
|
122
|
-
Rake::ExtensionTask.new('hello_world', spec)
|
123
|
-
|
124
|
-
Now, as usual, you can build your pure-ruby gem (standard output):
|
125
|
-
|
126
|
-
$ rake gem
|
127
|
-
(in /projects/oss/my_gem.git)
|
128
|
-
mkdir -p pkg
|
129
|
-
Successfully built RubyGem
|
130
|
-
Name: my_gem
|
131
|
-
Version: 0.1.0
|
132
|
-
File: my_gem-0.1.0.gem
|
133
|
-
mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
|
134
|
-
|
135
|
-
Plus, you have the functionality to build native versions of the gem:
|
136
|
-
|
137
|
-
# rake native gem
|
138
|
-
(... compilation output ...)
|
139
|
-
mkdir -p pkg
|
140
|
-
Successfully built RubyGem
|
141
|
-
Name: my_gem
|
142
|
-
Version: 0.1.0
|
143
|
-
File: my_gem-0.1.0.gem
|
144
|
-
mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
|
145
|
-
Successfully built RubyGem
|
146
|
-
Name: my_gem
|
147
|
-
Version: 0.1.0
|
148
|
-
File: my_gem-0.1.0-x86-mingw32.gem
|
149
|
-
mv my_gem-0.1.0-x86-mingw32.gem pkg/my_gem-0.1.0-x86-mingw32.gem
|
150
|
-
|
151
|
-
You get two gems for the price of one.
|
152
|
-
|
153
|
-
And the same for JRuby extensions:
|
154
|
-
|
155
|
-
# rake java gem
|
156
|
-
(... compilation output ...)
|
157
|
-
mkdir -p pkg
|
158
|
-
Successfully built RubyGem
|
159
|
-
Name: my_gem
|
160
|
-
Version: 0.1.0
|
161
|
-
File: my_gem-0.1.0.gem
|
162
|
-
mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
|
163
|
-
Successfully built RubyGem
|
164
|
-
Name: my_gem
|
165
|
-
Version: 0.1.0
|
166
|
-
File: my_gem-0.1.0-java.gem
|
167
|
-
mv my_gem-0.1.0-java.gem pkg/my_gem-0.1.0-java.gem
|
168
|
-
|
169
|
-
|
170
|
-
=== What about breaking the standards? (Customization)
|
171
|
-
|
172
|
-
In case you want to bend the convention established, rake-compiler let you
|
173
|
-
personalize several settings for <tt>Rake::ExtensionTask</tt>:
|
174
|
-
|
175
|
-
Rake::ExtensionTask.new do |ext|
|
176
|
-
ext.name = 'hello_world' # indicate the name of the extension.
|
177
|
-
ext.ext_dir = 'ext/weird_world' # search for 'hello_world' inside it.
|
178
|
-
ext.lib_dir = 'lib/my_lib' # put binaries into this folder.
|
179
|
-
ext.config_script = 'custom_extconf.rb' # use instead of 'extconf.rb' default
|
180
|
-
ext.tmp_dir = 'tmp' # temporary folder used during compilation.
|
181
|
-
ext.source_pattern = "*.{c,cpp}" # monitor file changes to allow simple rebuild.
|
182
|
-
ext.config_options << '--with-foo' # supply additional configure options to config script.
|
183
|
-
ext.gem_spec = spec # optional indicate which gem specification
|
184
|
-
# will be used to based on.
|
185
|
-
end
|
186
|
-
|
187
|
-
== Future is now: Cross compilation
|
188
|
-
|
189
|
-
rake-compiler provides now an standardized way to generate, from Linux or OSX
|
190
|
-
both extensions and gem binaries for Windows!
|
191
|
-
|
192
|
-
It takes advantages from GCC host/target to build binaries (for target) on
|
193
|
-
different OS (hosts).
|
194
|
-
|
195
|
-
=== How I enjoy this?
|
196
|
-
|
197
|
-
Besides having the development tool chain installed (GCC), you should install
|
198
|
-
also <tt>mingw32</tt> cross compilation package.
|
199
|
-
|
200
|
-
Installation depends will depend on your operating system/distribution. On
|
201
|
-
Ubuntu and Debian machines, a simple <tt>apt-get install mingw32</tt> will be
|
202
|
-
enough.
|
203
|
-
|
204
|
-
On OSX, mingw32 is available via MacPorts: <tt>port install i386-mingw32-gcc</tt>
|
205
|
-
(ensure you update your ports tree before hand as <tt>mingw32</tt> has been
|
206
|
-
been broken).
|
207
|
-
|
208
|
-
=== I have my tool-chain, now what?
|
209
|
-
|
210
|
-
You need to build Ruby for Windows.
|
211
|
-
|
212
|
-
Relax, no need to freak out! Let rake-compiler do it for you:
|
213
|
-
|
214
|
-
rake-compiler cross-ruby
|
215
|
-
|
216
|
-
And you're done. It will automatically download, configure and compile latest
|
217
|
-
stable version of Ruby for Windows, and place it into <tt>~/.rake-compiler</tt>
|
218
|
-
|
219
|
-
If, instead, you want to build another version than the default one, please
|
220
|
-
supply a <tt>VERSION</tt>:
|
221
|
-
|
222
|
-
rake-compiler cross-ruby VERSION=1.8.6-p114
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
1
|
+
= rake-compiler
|
2
|
+
|
3
|
+
rake-compiler aims to help Gem developers deal with Ruby extensions, simplifying
|
4
|
+
code and reducing duplication.
|
5
|
+
|
6
|
+
It followss *convention over configuration* and sets a standardized structure to
|
7
|
+
build and package both C and Java extensions in your gems.
|
8
|
+
|
9
|
+
This is the result of experiences dealing with several Gems that required native
|
10
|
+
extensions across platforms and different user configurations where details like
|
11
|
+
portability and clarity of code were lacking.
|
12
|
+
|
13
|
+
== An Overview
|
14
|
+
|
15
|
+
Let's summarize what rake-compiler provides:
|
16
|
+
|
17
|
+
* No custom rake tasks required. Less code duplication and errors.
|
18
|
+
|
19
|
+
* Painlessly build extensions on different platforms (Linux, OSX and Windows).
|
20
|
+
|
21
|
+
* Painlessly build extensions for different Ruby implementations (JRuby,
|
22
|
+
Rubinius and MRI).
|
23
|
+
|
24
|
+
* Allow multiple extensions be compiled inside the same gem.
|
25
|
+
|
26
|
+
* Mimics RubyGems installation process, so helps as a test environment.
|
27
|
+
|
28
|
+
* Simplify cross platform compilation of extensions (target Windows from Linux).
|
29
|
+
|
30
|
+
== I'm sold! show me how to use it! (Installation)
|
31
|
+
|
32
|
+
Usage of rake-compiler is pretty much straight forward.
|
33
|
+
|
34
|
+
First, you need to install the gem:
|
35
|
+
|
36
|
+
$ gem install rake-compiler
|
37
|
+
|
38
|
+
== Now what? (Usage)
|
39
|
+
|
40
|
+
Now that you have the gem installed, let's give your project some structure.
|
41
|
+
|
42
|
+
=== Structure
|
43
|
+
|
44
|
+
Let's say we want to compile an extension called 'hello_world', so we should
|
45
|
+
organize the code and folders that will help rake-compiler do its job:
|
46
|
+
|
47
|
+
|-- ext
|
48
|
+
| `-- hello_world
|
49
|
+
| |-- extconf.rb
|
50
|
+
| |-- HelloWorldService.java
|
51
|
+
| `-- hello_world.c
|
52
|
+
|-- lib
|
53
|
+
`-- Rakefile
|
54
|
+
|
55
|
+
TIP: Having a consistent folder structure will help developers and newcomers
|
56
|
+
to find code and also contribute back to your project more easily.
|
57
|
+
|
58
|
+
=== Adding the code
|
59
|
+
|
60
|
+
So now it's time to introduce the code to compile our extension:
|
61
|
+
|
62
|
+
# File: Rakefile
|
63
|
+
|
64
|
+
require 'rake/extensiontask'
|
65
|
+
|
66
|
+
Rake::ExtensionTask.new('hello_world')
|
67
|
+
|
68
|
+
Ok, that's it. No other line of code.
|
69
|
+
|
70
|
+
If we wanted to do the same for a JRuby extension (written in Java):
|
71
|
+
|
72
|
+
# File: Rakefile
|
73
|
+
|
74
|
+
require 'rake/javaextensiontask'
|
75
|
+
|
76
|
+
Rake::JavaExtensionTask.new('hello_world')
|
77
|
+
|
78
|
+
=== Compile process
|
79
|
+
|
80
|
+
Those *two* lines of code automatically added the needed rake tasks to build
|
81
|
+
the hello_world extension. Running Rake on 1.8.x/1.9 (MRI):
|
82
|
+
|
83
|
+
$ rake -T
|
84
|
+
(in /home/user/my_extension)
|
85
|
+
rake compile # Compile the extension(s)
|
86
|
+
rake compile:hello_world # Compile just the hello_world extension
|
87
|
+
|
88
|
+
Simply calling <tt>compile</tt>:
|
89
|
+
|
90
|
+
$ rake compile
|
91
|
+
|
92
|
+
Will do all the compile process for us, putting the result extension inside
|
93
|
+
<tt>lib</tt> directory.
|
94
|
+
|
95
|
+
NOTE: Please be aware that building C extensions requires the proper
|
96
|
+
development environment for your Platform, which includes libraries, headers
|
97
|
+
and build tools. Check your distro / vendor documentation on how to install it.
|
98
|
+
|
99
|
+
NOTE: Building Java extensions requires the <tt>javac</tt>, part of the Java
|
100
|
+
Development Kit (JDK). This should be included by default on Mac OS X, and
|
101
|
+
downloadable from http://java.sun.com for other operating systems.
|
102
|
+
|
103
|
+
=== Generate native gems
|
104
|
+
|
105
|
+
A common usage scenario of rake-compiler is generate native gems that bundles
|
106
|
+
your extensions.
|
107
|
+
|
108
|
+
This got over-simplified with <tt>Rake::ExtensionTask</tt>:
|
109
|
+
|
110
|
+
# somewhere in your Rakefile, define your gem spec
|
111
|
+
spec = Gem::Specification.new do |s|
|
112
|
+
s.name = "my_gem"
|
113
|
+
s.platform = Gem::Platform::RUBY
|
114
|
+
s.extensions = FileList["ext/**/extconf.rb"]
|
115
|
+
end
|
116
|
+
|
117
|
+
# add your default gem packing task
|
118
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
119
|
+
end
|
120
|
+
|
121
|
+
# feed your ExtensionTask with your spec
|
122
|
+
Rake::ExtensionTask.new('hello_world', spec)
|
123
|
+
|
124
|
+
Now, as usual, you can build your pure-ruby gem (standard output):
|
125
|
+
|
126
|
+
$ rake gem
|
127
|
+
(in /projects/oss/my_gem.git)
|
128
|
+
mkdir -p pkg
|
129
|
+
Successfully built RubyGem
|
130
|
+
Name: my_gem
|
131
|
+
Version: 0.1.0
|
132
|
+
File: my_gem-0.1.0.gem
|
133
|
+
mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
|
134
|
+
|
135
|
+
Plus, you have the functionality to build native versions of the gem:
|
136
|
+
|
137
|
+
# rake native gem
|
138
|
+
(... compilation output ...)
|
139
|
+
mkdir -p pkg
|
140
|
+
Successfully built RubyGem
|
141
|
+
Name: my_gem
|
142
|
+
Version: 0.1.0
|
143
|
+
File: my_gem-0.1.0.gem
|
144
|
+
mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
|
145
|
+
Successfully built RubyGem
|
146
|
+
Name: my_gem
|
147
|
+
Version: 0.1.0
|
148
|
+
File: my_gem-0.1.0-x86-mingw32.gem
|
149
|
+
mv my_gem-0.1.0-x86-mingw32.gem pkg/my_gem-0.1.0-x86-mingw32.gem
|
150
|
+
|
151
|
+
You get two gems for the price of one.
|
152
|
+
|
153
|
+
And the same for JRuby extensions:
|
154
|
+
|
155
|
+
# rake java gem
|
156
|
+
(... compilation output ...)
|
157
|
+
mkdir -p pkg
|
158
|
+
Successfully built RubyGem
|
159
|
+
Name: my_gem
|
160
|
+
Version: 0.1.0
|
161
|
+
File: my_gem-0.1.0.gem
|
162
|
+
mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
|
163
|
+
Successfully built RubyGem
|
164
|
+
Name: my_gem
|
165
|
+
Version: 0.1.0
|
166
|
+
File: my_gem-0.1.0-java.gem
|
167
|
+
mv my_gem-0.1.0-java.gem pkg/my_gem-0.1.0-java.gem
|
168
|
+
|
169
|
+
|
170
|
+
=== What about breaking the standards? (Customization)
|
171
|
+
|
172
|
+
In case you want to bend the convention established, rake-compiler let you
|
173
|
+
personalize several settings for <tt>Rake::ExtensionTask</tt>:
|
174
|
+
|
175
|
+
Rake::ExtensionTask.new do |ext|
|
176
|
+
ext.name = 'hello_world' # indicate the name of the extension.
|
177
|
+
ext.ext_dir = 'ext/weird_world' # search for 'hello_world' inside it.
|
178
|
+
ext.lib_dir = 'lib/my_lib' # put binaries into this folder.
|
179
|
+
ext.config_script = 'custom_extconf.rb' # use instead of 'extconf.rb' default
|
180
|
+
ext.tmp_dir = 'tmp' # temporary folder used during compilation.
|
181
|
+
ext.source_pattern = "*.{c,cpp}" # monitor file changes to allow simple rebuild.
|
182
|
+
ext.config_options << '--with-foo' # supply additional configure options to config script.
|
183
|
+
ext.gem_spec = spec # optional indicate which gem specification
|
184
|
+
# will be used to based on.
|
185
|
+
end
|
186
|
+
|
187
|
+
== Future is now: Cross compilation
|
188
|
+
|
189
|
+
rake-compiler provides now an standardized way to generate, from Linux or OSX
|
190
|
+
both extensions and gem binaries for Windows!
|
191
|
+
|
192
|
+
It takes advantages from GCC host/target to build binaries (for target) on
|
193
|
+
different OS (hosts).
|
194
|
+
|
195
|
+
=== How I enjoy this?
|
196
|
+
|
197
|
+
Besides having the development tool chain installed (GCC), you should install
|
198
|
+
also <tt>mingw32</tt> cross compilation package.
|
199
|
+
|
200
|
+
Installation depends will depend on your operating system/distribution. On
|
201
|
+
Ubuntu and Debian machines, a simple <tt>apt-get install mingw32</tt> will be
|
202
|
+
enough.
|
203
|
+
|
204
|
+
On OSX, mingw32 is available via MacPorts: <tt>port install i386-mingw32-gcc</tt>
|
205
|
+
(ensure you update your ports tree before hand as <tt>mingw32</tt> has been
|
206
|
+
been broken).
|
207
|
+
|
208
|
+
=== I have my tool-chain, now what?
|
209
|
+
|
210
|
+
You need to build Ruby for Windows.
|
211
|
+
|
212
|
+
Relax, no need to freak out! Let rake-compiler do it for you:
|
213
|
+
|
214
|
+
rake-compiler cross-ruby
|
215
|
+
|
216
|
+
And you're done. It will automatically download, configure and compile latest
|
217
|
+
stable version of Ruby for Windows, and place it into <tt>~/.rake-compiler</tt>
|
218
|
+
|
219
|
+
If, instead, you want to build another version than the default one, please
|
220
|
+
supply a <tt>VERSION</tt>:
|
221
|
+
|
222
|
+
rake-compiler cross-ruby VERSION=1.8.6-p114
|
223
|
+
|
224
|
+
If you, like me, have multiple versions of MinGW packages, you can specify the
|
225
|
+
HOST that will be used to cross compile ruby:
|
226
|
+
|
227
|
+
rake-compiler cross-ruby HOST=i386-mingw32 # (OSX mingw32 port)
|
228
|
+
|
229
|
+
The host will vary depending on provider (mingw32 versus mingw-w64 projects).
|
230
|
+
Consult the documentation and website of the MinGW package provider before
|
231
|
+
reporting any issue.
|
232
|
+
|
233
|
+
=== Let's build some gems!
|
234
|
+
|
235
|
+
Now, you only need to use additional options in your extension definition:
|
236
|
+
|
237
|
+
Rake::ExtensionTask.new('my_extension', gem_spec) do |ext|
|
238
|
+
ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
|
239
|
+
ext.cross_platform = 'i386-mswin32' # forces the Windows platform instead of the default one
|
240
|
+
# configure options only for cross compile
|
241
|
+
ext.cross_config_options << '--with-something'
|
242
|
+
|
243
|
+
# perform alterations on the gemspec when cross compiling
|
244
|
+
ext.cross_compiling do |gem_spec|
|
245
|
+
gem_spec.post_install_message = "You installed the binary version of this gem!"
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
By default, cross compilation targets 'i386-mingw32' which is default GCC platform
|
250
|
+
for Ruby.
|
251
|
+
|
252
|
+
To target gems for current Ruby official distribution, please force the platform
|
253
|
+
to the one shown before.
|
254
|
+
|
255
|
+
=== Magician doing some tricks, don't blink!
|
256
|
+
|
257
|
+
Compiles keeps being simple:
|
258
|
+
|
259
|
+
rake cross compile
|
260
|
+
|
261
|
+
And now, build your gems for Windows is just 5 more letters:
|
262
|
+
|
263
|
+
rake cross native gem
|
264
|
+
|
265
|
+
And you're done, yeah.
|
266
|
+
|
267
|
+
=== Take it even further
|
268
|
+
|
269
|
+
You can specify against with version of Ruby you want to build the extension:
|
270
|
+
|
271
|
+
rake cross compile RUBY_CC_VERSION=1.8.6
|
272
|
+
|
273
|
+
If you installed <tt>1.9.1</tt>, you can do:
|
274
|
+
|
275
|
+
rake cross compile RUBY_CC_VERSION=1.9.1
|
276
|
+
|
277
|
+
Even more, you can target multiple versions (ie. 1.8.6 and 1.9.1):
|
278
|
+
|
279
|
+
rake cross compile RUBY_CC_VERSION=1.8.6:1.9.1
|
280
|
+
|
281
|
+
And more exiting, bundle both binaries in one "fat" Gem:
|
282
|
+
|
283
|
+
rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.1
|
284
|
+
|
285
|
+
That will place binaries for 1.8 and 1.9 versions of ruby inside <tt>lib_dir</tt>
|
286
|
+
|
287
|
+
lib/1.8/my_extension.so
|
288
|
+
lib/1.9/my_extension.so
|
289
|
+
|
290
|
+
Now is up to you to make your gem load the proper one ;-)
|
291
|
+
|
292
|
+
=== What are you talking about? (Give me examples)
|
293
|
+
|
294
|
+
I know all the above sounds like a complete foreign language (it does even for me!). So, what if I show you some examples?
|
295
|
+
|
296
|
+
Check our wiki with links to the proper rake files used by many developers and projects and how they use rake-compiler.
|
297
|
+
|
298
|
+
http://github.com/luislavena/rake-compiler/wiki/projects-using-rake-compiler
|
299
|
+
|
300
|
+
== Future
|
301
|
+
|
302
|
+
rake-compiler is a work in progress and we will appreciate feedback during the
|
303
|
+
development of it! (and contributions too!)
|
304
|
+
|
305
|
+
You can find more information about rake-compiler:
|
306
|
+
|
307
|
+
* GitHub: https://github.com/luislavena/rake-compiler
|
308
|
+
* Issues: https://github.com/luislavena/rake-compiler/issues
|
309
|
+
* Blog: http://blog.mmediasys.com
|
310
|
+
* Docs: http://rubydoc.info/gems/rake-compiler
|
311
|
+
* Wiki: https://github.com/luislavena/rake-compiler/wiki
|
312
|
+
|
313
|
+
== Disclaimer
|
314
|
+
|
315
|
+
If you have any trouble, don't hesitate to contact the author. As always,
|
316
|
+
I'm not going to say "Use at your own risk" because I don't want this library
|
317
|
+
to be risky.
|
318
|
+
|
319
|
+
If you trip on something, I'll share the liability by repairing things
|
320
|
+
as quickly as I can. Your responsibility is to report the inadequacies.
|
data/Rakefile
CHANGED
@@ -12,11 +12,9 @@
|
|
12
12
|
#
|
13
13
|
|
14
14
|
begin
|
15
|
-
require '
|
16
|
-
rescue LoadError
|
17
|
-
|
18
|
-
gem 'rake', '~> 0.8.3.1'
|
19
|
-
require 'rake'
|
15
|
+
require 'isolate/now'
|
16
|
+
rescue LoadError => e
|
17
|
+
fail "This project uses Isolate to manage development dependencies. Please `gem install isolate` first and try again."
|
20
18
|
end
|
21
19
|
|
22
20
|
# load rakefile extensions (tasks)
|
@@ -17,7 +17,11 @@ Then /^a gem for '(.*)' version '(.*)' platform '(.*)' do exist in '(.*)'$/ do |
|
|
17
17
|
`gem unpack #{gem_file_platform(folder, name, version, platform)} --target tmp`
|
18
18
|
unpacked_gem_dir = unpacked_gem_dir_platform('tmp', name, version, platform)
|
19
19
|
File.exist?(unpacked_gem_dir).should be_true
|
20
|
-
|
20
|
+
|
21
|
+
files = Dir.glob("#{unpacked_gem_dir}/lib/*.#{binary_extension(platform)}")
|
22
|
+
files << Dir.glob("#{unpacked_gem_dir}/lib/*/*.#{binary_extension(platform)}")
|
23
|
+
|
24
|
+
files.flatten.uniq.should_not be_empty
|
21
25
|
end
|
22
26
|
|
23
27
|
Then /^gem for platform '(.*)' get generated$/ do |platform|
|
data/lib/rake/extensiontask.rb
CHANGED
@@ -109,7 +109,7 @@ Rerun `rake` under MRI Ruby 1.8.x/1.9.x to cross/native compile.
|
|
109
109
|
options = @config_options.dup
|
110
110
|
|
111
111
|
# include current directory
|
112
|
-
cmd = ['-I.']
|
112
|
+
cmd = [Gem.ruby, '-I.']
|
113
113
|
|
114
114
|
# if fake.rb is present, add to the command line
|
115
115
|
if t.prerequisites.include?("#{tmp_path}/fake.rb") then
|
@@ -117,8 +117,8 @@ Rerun `rake` under MRI Ruby 1.8.x/1.9.x to cross/native compile.
|
|
117
117
|
end
|
118
118
|
|
119
119
|
# build a relative path to extconf script
|
120
|
-
abs_tmp_path = Pathname.new(Dir.pwd) + tmp_path
|
121
|
-
abs_extconf = Pathname.new(Dir.pwd) + extconf
|
120
|
+
abs_tmp_path = (Pathname.new(Dir.pwd) + tmp_path).realpath
|
121
|
+
abs_extconf = (Pathname.new(Dir.pwd) + extconf).realpath
|
122
122
|
|
123
123
|
# now add the extconf script
|
124
124
|
cmd << abs_extconf.relative_path_from(abs_tmp_path)
|
@@ -135,7 +135,7 @@ Rerun `rake` under MRI Ruby 1.8.x/1.9.x to cross/native compile.
|
|
135
135
|
# FIXME: Rake is broken for multiple arguments system() calls.
|
136
136
|
# Add current directory to the search path of Ruby
|
137
137
|
# Also, include additional parameters supplied.
|
138
|
-
|
138
|
+
sh cmd.join(' ')
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -378,11 +378,24 @@ Rerun `rake` under MRI Ruby 1.8.x/1.9.x to cross/native compile.
|
|
378
378
|
class Object
|
379
379
|
remove_const :RUBY_PLATFORM
|
380
380
|
remove_const :RUBY_VERSION
|
381
|
+
remove_const :RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
|
381
382
|
RUBY_PLATFORM = "i386-mingw32"
|
382
383
|
RUBY_VERSION = "#{version}"
|
384
|
+
RUBY_DESCRIPTION = "ruby \#{RUBY_VERSION} (\#{RUBY_RELEASE_DATE}) [\#{RUBY_PLATFORM}]"
|
383
385
|
end
|
386
|
+
if RUBY_PLATFORM =~ /mswin|bccwin|mingw/
|
387
|
+
class File
|
388
|
+
remove_const :ALT_SEPARATOR
|
389
|
+
ALT_SEPARATOR = "\\\\"
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
posthook = proc do
|
394
|
+
$ruby = "#{Gem.ruby}"
|
395
|
+
untrace_var(:$ruby, posthook)
|
396
|
+
end
|
397
|
+
trace_var(:$ruby, posthook)
|
384
398
|
FAKE_RB
|
385
399
|
end
|
386
|
-
|
387
400
|
end
|
388
401
|
end
|
@@ -441,6 +441,8 @@ describe Rake::ExtensionTask do
|
|
441
441
|
'rbconfig-1.8.6' => '/some/path/version/1.8/to/rbconfig.rb',
|
442
442
|
'rbconfig-1.8.7' => '/some/path/version/1.8/to/rbconfig.rb',
|
443
443
|
'rbconfig-1.9.1' => '/some/path/version/1.9.1/to/rbconfig.rb',
|
444
|
+
'rbconfig-1.9.2' => '/some/path/version/1.9.1/to/rbconfig.rb',
|
445
|
+
'rbconfig-1.9.3' => '/some/path/version/1.9.1/to/rbconfig.rb',
|
444
446
|
'rbconfig-3.0.0' => '/some/fake/version/3.0.0/to/rbconfig.rb'
|
445
447
|
}
|
446
448
|
end
|
data/tasks/bin/cross-ruby.rake
CHANGED
@@ -33,16 +33,17 @@ end
|
|
33
33
|
|
34
34
|
require 'rake/extensioncompiler'
|
35
35
|
|
36
|
-
MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c
|
36
|
+
MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system("#{c} -v > /dev/null 2>&1") }
|
37
37
|
USER_HOME = File.expand_path("~/.rake-compiler")
|
38
|
-
RUBY_CC_VERSION = "ruby-#{ENV['VERSION'] || '1.8.6-
|
38
|
+
RUBY_CC_VERSION = "ruby-#{ENV['VERSION'] || '1.8.6-p398'}"
|
39
39
|
RUBY_SOURCE = ENV['SOURCE']
|
40
40
|
|
41
41
|
# grab the major "1.8" or "1.9" part of the version number
|
42
42
|
MAJOR = RUBY_CC_VERSION.match(/.*-(\d.\d).\d/)[1]
|
43
43
|
|
44
44
|
# Use Rake::ExtensionCompiler helpers to find the proper host
|
45
|
-
MINGW_HOST = Rake::ExtensionCompiler.mingw_host
|
45
|
+
MINGW_HOST = ENV['HOST'] || Rake::ExtensionCompiler.mingw_host
|
46
|
+
MINGW_TARGET = MINGW_HOST.gsub('msvc', '')
|
46
47
|
|
47
48
|
# define a location where sources will be stored
|
48
49
|
directory "#{USER_HOME}/sources/#{RUBY_CC_VERSION}"
|
@@ -59,7 +60,7 @@ CLOBBER.include("#{USER_HOME}/ruby/#{RUBY_CC_VERSION}")
|
|
59
60
|
CLOBBER.include("#{USER_HOME}/config.yml")
|
60
61
|
|
61
62
|
# ruby source file should be stored there
|
62
|
-
file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}.tar.
|
63
|
+
file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}.tar.bz2" => ["#{USER_HOME}/sources"] do |t|
|
63
64
|
# download the source file using wget or curl
|
64
65
|
chdir File.dirname(t.name) do
|
65
66
|
if RUBY_SOURCE
|
@@ -72,10 +73,10 @@ file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}.tar.gz" => ["#{USER_HOME}/sources"
|
|
72
73
|
end
|
73
74
|
|
74
75
|
# Extract the sources
|
75
|
-
source_file = RUBY_SOURCE ? RUBY_SOURCE.split('/').last : "#{RUBY_CC_VERSION}.tar.
|
76
|
+
source_file = RUBY_SOURCE ? RUBY_SOURCE.split('/').last : "#{RUBY_CC_VERSION}.tar.bz2"
|
76
77
|
file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}" => ["#{USER_HOME}/sources/#{source_file}"] do |t|
|
77
78
|
chdir File.dirname(t.name) do
|
78
|
-
t.prerequisites.each { |f| sh "tar
|
79
|
+
t.prerequisites.each { |f| sh "tar xf #{File.basename(f)}" }
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
@@ -111,22 +112,13 @@ task :mingw32 do
|
|
111
112
|
end
|
112
113
|
end
|
113
114
|
|
114
|
-
task :environment do
|
115
|
-
ENV['ac_cv_func_getpgrp_void'] = 'no'
|
116
|
-
ENV['ac_cv_func_setpgrp_void'] = 'yes'
|
117
|
-
ENV['rb_cv_negative_time_t'] = 'no'
|
118
|
-
ENV['ac_cv_func_memcmp_working'] = 'yes'
|
119
|
-
ENV['rb_cv_binary_elf' ] = 'no'
|
120
|
-
end
|
121
|
-
|
122
115
|
# generate the makefile in a clean build location
|
123
116
|
file "#{USER_HOME}/builds/#{RUBY_CC_VERSION}/Makefile" => ["#{USER_HOME}/builds/#{RUBY_CC_VERSION}",
|
124
117
|
"#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in"] do |t|
|
125
118
|
|
126
119
|
options = [
|
127
|
-
'--target=i386-mingw32',
|
128
120
|
"--host=#{MINGW_HOST}",
|
129
|
-
|
121
|
+
"--target=#{MINGW_TARGET}",
|
130
122
|
'--enable-shared',
|
131
123
|
'--disable-install-doc',
|
132
124
|
'--without-tk',
|
@@ -188,4 +180,5 @@ task :default do
|
|
188
180
|
end
|
189
181
|
|
190
182
|
desc "Build #{RUBY_CC_VERSION} suitable for cross-platform development."
|
191
|
-
task 'cross-ruby' => [:mingw32, :
|
183
|
+
task 'cross-ruby' => [:mingw32, :install, 'update-config']
|
184
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
desc 'Ensure all the cross compiled versions are installed'
|
2
|
+
task :bootstrap do
|
3
|
+
fail "Sorry, this only works on OSX and Linux" if RUBY_PLATFORM =~ /mswin|mingw/
|
4
|
+
|
5
|
+
versions = %w(1.8.6-p398 1.9.1-p243 1.9.2-p0)
|
6
|
+
|
7
|
+
versions.each do |version|
|
8
|
+
puts "[INFO] Attempt to cross-compile Ruby #{version}"
|
9
|
+
ruby "-Ilib bin/rake-compiler cross-ruby VERSION=#{version}"
|
10
|
+
end
|
11
|
+
end
|
data/tasks/common.rake
CHANGED
data/tasks/gem.rake
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems/package_task'
|
|
3
3
|
GEM_SPEC = Gem::Specification.new do |s|
|
4
4
|
# basic information
|
5
5
|
s.name = "rake-compiler"
|
6
|
-
s.version = "0.7.
|
6
|
+
s.version = "0.7.5"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
|
9
9
|
# description and details
|
@@ -15,7 +15,7 @@ GEM_SPEC = Gem::Specification.new do |s|
|
|
15
15
|
s.required_rubygems_version = ">= 1.3.5"
|
16
16
|
|
17
17
|
# dependencies
|
18
|
-
s.add_dependency 'rake'
|
18
|
+
s.add_dependency 'rake'
|
19
19
|
|
20
20
|
# development dependencies
|
21
21
|
s.add_development_dependency 'rspec', '~> 1.2.9'
|
@@ -25,7 +25,8 @@ GEM_SPEC = Gem::Specification.new do |s|
|
|
25
25
|
# components, files and paths
|
26
26
|
s.files = FileList["features/**/*.{feature,rb}", "bin/rake-compiler",
|
27
27
|
"lib/**/*.rb", "spec/spec.opts", "spec/**/*.rb",
|
28
|
-
"tasks/**/*.rake", "Rakefile", "
|
28
|
+
"tasks/**/*.rake", "Rakefile", "Isolate",
|
29
|
+
"*.{rdoc,txt,yml}"]
|
29
30
|
|
30
31
|
s.bindir = 'bin'
|
31
32
|
s.executables = ['rake-compiler']
|
data/tasks/news.rake
CHANGED
@@ -1,79 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
''
|
40
|
-
end
|
41
|
-
|
42
|
-
# read changes
|
43
|
-
changes = begin
|
44
|
-
h = File.read("History.txt")
|
45
|
-
h.split(/^(===+ .*)/)[1..2].join.strip
|
46
|
-
rescue
|
47
|
-
warn "Missing History.txt"
|
48
|
-
''
|
49
|
-
end
|
50
|
-
|
51
|
-
# standard fields
|
52
|
-
subject = "#{GEM_SPEC.name} #{GEM_SPEC.version} Released"
|
53
|
-
title = "#{GEM_SPEC.name} version #{GEM_SPEC.version} has been released!"
|
54
|
-
body = "#{notes}\n\nChanges:\n\n#{changes}"
|
55
|
-
urls = [GEM_SPEC.homepage, "http://rubyforge.org/projects/#{GEM_SPEC.rubyforge_project}"].map { |u| "* <#{u.strip}>" }.join("\n")
|
56
|
-
|
57
|
-
puts "Logging in RubyForge..."
|
58
|
-
rf.login
|
59
|
-
|
60
|
-
puts "Generating email.txt..."
|
61
|
-
File.open("email.txt", "w") do |mail|
|
62
|
-
mail.puts "Subject: [ANN] #{subject}"
|
63
|
-
mail.puts
|
64
|
-
mail.puts title
|
65
|
-
mail.puts
|
66
|
-
mail.puts urls
|
67
|
-
mail.puts
|
68
|
-
mail.puts body
|
69
|
-
end
|
70
|
-
puts "Created email.txt"
|
71
|
-
|
72
|
-
puts "Posting news for #{GEM_SPEC.name} version #{GEM_SPEC.version}..."
|
73
|
-
rf.post_news GEM_SPEC.rubyforge_project, subject, "#{title}\n\n#{body}"
|
74
|
-
puts "Done."
|
75
|
-
end
|
76
|
-
else
|
77
|
-
warn "no GEM_SPEC is found or defined. 'announce' task cannot work without it."
|
78
|
-
end
|
1
|
+
desc 'Generate email template to standard output'
|
2
|
+
task :announce do
|
3
|
+
fail "no GEM_SPEC is found or defined. 'announce' task cannot work without it." unless defined?(GEM_SPEC)
|
4
|
+
|
5
|
+
# read project info and overview
|
6
|
+
notes = begin
|
7
|
+
r = File.read("README.rdoc")
|
8
|
+
r.split(/^(=+ .*)/)[1..4].join.strip
|
9
|
+
rescue
|
10
|
+
warn "Missing README.rdoc"
|
11
|
+
''
|
12
|
+
end
|
13
|
+
|
14
|
+
# read changes
|
15
|
+
changes = begin
|
16
|
+
h = File.read("History.txt")
|
17
|
+
h.split(/^(===+ .*)/)[1..2].join.strip
|
18
|
+
rescue
|
19
|
+
warn "Missing History.txt"
|
20
|
+
''
|
21
|
+
end
|
22
|
+
|
23
|
+
# standard fields
|
24
|
+
subject = "#{GEM_SPEC.name} #{GEM_SPEC.version} Released"
|
25
|
+
title = "#{GEM_SPEC.name} version #{GEM_SPEC.version} has been released!"
|
26
|
+
body = "#{notes}\n\nChanges:\n\n#{changes}"
|
27
|
+
urls = [GEM_SPEC.homepage].map { |u| "* <#{u.strip}>" }.join("\n")
|
28
|
+
|
29
|
+
puts "=" * 80, ""
|
30
|
+
puts "Subject: [ANN] #{subject}"
|
31
|
+
puts
|
32
|
+
puts title
|
33
|
+
puts
|
34
|
+
puts urls
|
35
|
+
puts
|
36
|
+
puts body
|
37
|
+
puts
|
38
|
+
puts "=" * 80, ""
|
79
39
|
end
|
data/tasks/release.rake
CHANGED
@@ -1,71 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
if defined?(RubyForge) then
|
8
|
-
if defined?(GEM_SPEC) then
|
9
|
-
desc 'Package and upload to RubyForge'
|
10
|
-
task :release => [:clobber, :package] do |t|
|
11
|
-
ver = ENV['VERSION'] or fail "Must supply VERSION (rake release VERSION=x.y.z)."
|
12
|
-
|
13
|
-
# compare versions to avoid mistakes
|
14
|
-
unless ver == GEM_SPEC.version.to_s then
|
15
|
-
fail "Version mismatch (supplied and specification versions differ)."
|
16
|
-
end
|
17
|
-
|
18
|
-
# no rubyforge project? no release for you!
|
19
|
-
if GEM_SPEC.rubyforge_project == 'TODO' or GEM_SPEC.rubyforge_project.nil? then
|
20
|
-
fail "Must define rubyforge_project in your gem specification."
|
21
|
-
end
|
22
|
-
|
23
|
-
# instantiate a RubyForge object
|
24
|
-
rf = RubyForge.new
|
1
|
+
desc 'Package gems and upload to RubyGems'
|
2
|
+
task :release, :version, :needs => [:package] do |t, args|
|
3
|
+
args.with_defaults(:version => "")
|
4
|
+
ver = args.version
|
25
5
|
|
26
|
-
|
27
|
-
notes = begin
|
28
|
-
r = File.read("README.rdoc")
|
29
|
-
r.split(/^(=+ .*)/)[1..4].join.strip
|
30
|
-
rescue
|
31
|
-
warn "Missing README.rdoc"
|
32
|
-
''
|
33
|
-
end
|
6
|
+
fail "no GEM_SPEC is found or defined. 'release' task cannot work without it." unless defined?(GEM_SPEC)
|
34
7
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
rescue
|
40
|
-
warn "Missing History.txt"
|
41
|
-
''
|
42
|
-
end
|
43
|
-
|
44
|
-
# build the configuration for the release
|
45
|
-
config = Hash.new
|
46
|
-
config["release_notes"] = notes
|
47
|
-
config["release_changes"] = changes
|
48
|
-
config["preformatted"] = true
|
49
|
-
|
50
|
-
# prepare configuration
|
51
|
-
rf.configure config
|
52
|
-
|
53
|
-
files = FileList["pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version}*.*"].to_a
|
54
|
-
fail "No files found for the release." if files.empty?
|
8
|
+
# compare versions to avoid mistakes
|
9
|
+
unless ver == GEM_SPEC.version.to_s then
|
10
|
+
fail "Version mismatch (supplied and specification versions differ)."
|
11
|
+
end
|
55
12
|
|
56
|
-
|
57
|
-
|
13
|
+
files = FileList["pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version}*.*"].to_a
|
14
|
+
fail "No files found for the release." if files.empty?
|
58
15
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
16
|
+
puts "Files to release:"
|
17
|
+
files.each do |f|
|
18
|
+
puts " * #{f}"
|
19
|
+
end
|
63
20
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
68
|
-
else
|
69
|
-
warn "no GEM_SPEC is found or defined. 'release' task cannot work without it."
|
21
|
+
puts "Releasing #{GEM_SPEC.name} version #{GEM_SPEC.version}..."
|
22
|
+
files.each do |f|
|
23
|
+
system "gem push #{f}"
|
70
24
|
end
|
25
|
+
puts "Done."
|
71
26
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake-compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 5
|
10
|
+
version: 0.7.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Luis Lavena
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-25 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,19 +26,10 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 3
|
30
30
|
segments:
|
31
31
|
- 0
|
32
|
-
|
33
|
-
- 3
|
34
|
-
version: 0.8.3
|
35
|
-
- - <
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
hash: 25
|
38
|
-
segments:
|
39
|
-
- 0
|
40
|
-
- 9
|
41
|
-
version: "0.9"
|
32
|
+
version: "0"
|
42
33
|
type: :runtime
|
43
34
|
version_requirements: *id001
|
44
35
|
- !ruby/object:Gem::Dependency
|
@@ -115,15 +106,15 @@ files:
|
|
115
106
|
- spec/spec_helper.rb
|
116
107
|
- spec/support/capture_output_helper.rb
|
117
108
|
- tasks/bin/cross-ruby.rake
|
109
|
+
- tasks/bootstrap.rake
|
118
110
|
- tasks/common.rake
|
119
111
|
- tasks/cucumber.rake
|
120
112
|
- tasks/gem.rake
|
121
113
|
- tasks/news.rake
|
122
|
-
- tasks/rdoc.rake
|
123
|
-
- tasks/rdoc_publish.rake
|
124
114
|
- tasks/release.rake
|
125
115
|
- tasks/rspec.rake
|
126
116
|
- Rakefile
|
117
|
+
- Isolate
|
127
118
|
- README.rdoc
|
128
119
|
- History.txt
|
129
120
|
- LICENSE.txt
|
data/tasks/rdoc.rake
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'rdoc/task'
|
3
|
-
rescue LoadError
|
4
|
-
warn "RDoc 2.4.3+ gem is required, please install it (gem install rdoc)."
|
5
|
-
end
|
6
|
-
|
7
|
-
if defined?(RDoc) then
|
8
|
-
DOC = RDoc::Task.new(:rdoc) do |rd|
|
9
|
-
rd.title = 'rake-compiler -- Documentation'
|
10
|
-
rd.main = 'README.rdoc'
|
11
|
-
rd.rdoc_dir = 'doc/api'
|
12
|
-
rd.options << '--line-numbers' << '--main' << 'README.rdoc' << '--title' << 'rake-compiler -- Documentation'
|
13
|
-
rd.rdoc_files.include %w(README.rdoc LICENSE.txt History.txt lib/**/*.rb)
|
14
|
-
end
|
15
|
-
end
|
data/tasks/rdoc_publish.rake
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'rubyforge'
|
3
|
-
rescue LoadError
|
4
|
-
warn "rubyforge gem is required to generate releases, please install it (gem install rubyforge)."
|
5
|
-
end
|
6
|
-
|
7
|
-
if defined?(RubyForge) then
|
8
|
-
if defined?(DOC) && defined?(GEM_SPEC) then
|
9
|
-
desc "Publish RDoc to RubyForge"
|
10
|
-
task :publish => [:clobber_rdoc, :rdoc] do
|
11
|
-
config_file = File.expand_path('~/.rubyforge/user-config.yml')
|
12
|
-
fail "You need rubyforge properly configured." unless File.exist?(config_file)
|
13
|
-
|
14
|
-
# no rubyforge project? no release for you!
|
15
|
-
if GEM_SPEC.rubyforge_project == 'TODO' or GEM_SPEC.rubyforge_project.nil? then
|
16
|
-
fail "Must define rubyforge_project in your gem specification."
|
17
|
-
end
|
18
|
-
|
19
|
-
# use YAML to load configuration file
|
20
|
-
config = YAML.load_file(config_file)
|
21
|
-
|
22
|
-
host = "#{config['username']}@rubyforge.org"
|
23
|
-
remote_dir = "/var/www/gforge-projects/#{GEM_SPEC.rubyforge_project}/"
|
24
|
-
local_dir = DOC.rdoc_dir
|
25
|
-
|
26
|
-
# use PuTTY pscp or scp on other platforms
|
27
|
-
ssh_exe = RUBY_PLATFORM =~ /mswin|mingw/ ? 'pscp' : 'scp'
|
28
|
-
|
29
|
-
# construct the command
|
30
|
-
cmd = [ssh_exe]
|
31
|
-
cmd << '-r' << '-q' # recursive and quiet options
|
32
|
-
cmd << "#{local_dir}/*"
|
33
|
-
cmd << "#{host}:#{remote_dir}"
|
34
|
-
|
35
|
-
puts "Publishing RDocs to RubyForge..."
|
36
|
-
sh cmd.join(' ')
|
37
|
-
end
|
38
|
-
else
|
39
|
-
warn "You need a GEM_SPEC and DOC rdoc definitions present. task publish not defined."
|
40
|
-
end
|
41
|
-
end
|