rake-compiler 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,15 @@
1
+ === 0.5.0 / 2009-04-25
2
+
3
+ * Enhancements
4
+ * Allow generation of multiple gems for Windows (EXPERIMENTAL)
5
+ This allows build gems for both VC6 and MinGW builts of Ruby
6
+ (Thanks to Jonathan Stott for the suggestion)
7
+
8
+ Rake::ExtensionTask.new('my_extension', GEM_SPEC) do |ext|
9
+ ext.cross_compile = true
10
+ ext.cross_platform = ['i386-mswin32', 'i386-mingw32']
11
+ end
12
+
1
13
  === 0.4.1 / 2009-04-09
2
14
 
3
15
  * Enhancements
@@ -0,0 +1,15 @@
1
+ Feature: Generate multiple Windows gems from Linux
2
+
3
+ In order to keep compatibility with versions of Ruby on Windows
4
+ As a Gem developer on Linux
5
+ I want to build binary gems for One-Click Installer (old and new versions)
6
+
7
+ Scenario: package multiple gems for Windows
8
+ Given that my gem source is all in place to target two platforms
9
+ And I'm running a POSIX operating system
10
+ And I've installed cross compile toolchain
11
+ And I've already successfully executed rake task 'cross compile'
12
+ When rake task 'cross native gem' is invoked
13
+ Then rake task 'cross native gem' succeeded
14
+ And gem for platform 'x86-mswin32' get generated
15
+ And gem for platform 'x86-mingw32' get generated
@@ -8,6 +8,11 @@ Given /^a extension cross-compilable '(.*)'$/ do |extension_name|
8
8
  generate_source_code_for extension_name
9
9
  end
10
10
 
11
+ Given /^a extension '(.*)' multi cross\-compilable$/ do |extension_name|
12
+ generate_multi_cross_compile_extension_task_for extension_name
13
+ generate_source_code_for extension_name
14
+ end
15
+
11
16
  Given /^a extension '(.*)' with forced platform '(.*)'$/ do |extension_name, forced_platform|
12
17
  generate_extension_task_for extension_name, forced_platform
13
18
  generate_source_code_for extension_name
@@ -24,6 +29,12 @@ Given /^that my gem source is all in place$/ do
24
29
  Given "a extension cross-compilable 'extension_one'"
25
30
  end
26
31
 
32
+ Given /^that my gem source is all in place to target two platforms$/ do
33
+ Given "a safe project directory"
34
+ Given "a gem named 'gem_abc'"
35
+ Given "a extension 'extension_one' multi cross-compilable"
36
+ end
37
+
27
38
  Given /^not changed any file since$/ do
28
39
  # don't do anything, that's the purpose of this step!
29
40
  end
@@ -17,6 +17,15 @@ Given %r{^I've installed cross compile toolchain$} do
17
17
  end
18
18
 
19
19
  Then /^binaries for platform '(.*)' get generated$/ do |platform|
20
- ext_for_platform = Dir.glob("tmp/#{platform}/**/*.#{RbConfig::CONFIG['DLEXT']}")
20
+ ext = case platform
21
+ when /darwin/
22
+ 'bundle'
23
+ when /mingw|mswin|linux/
24
+ 'so'
25
+ else
26
+ RbConfig::CONFIG['DLEXT']
27
+ end
28
+
29
+ ext_for_platform = Dir.glob("tmp/#{platform}/**/*.#{ext}")
21
30
  ext_for_platform.should_not be_empty
22
31
  end
@@ -1,5 +1,6 @@
1
- def template_rakefile
2
- <<-EOF
1
+ module FileTemplateHelpers
2
+ def template_rakefile
3
+ <<-EOF
3
4
  # add rake-compiler lib dir to the LOAD_PATH
4
5
  $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '../..', 'lib'))
5
6
 
@@ -9,10 +10,10 @@ require 'rake'
9
10
  # load rakefile extensions (tasks)
10
11
  Dir['tasks/*.rake'].each { |f| import f }
11
12
  EOF
12
- end
13
+ end
13
14
 
14
- def template_rake_gemspec(gem_name)
15
- <<-EOF
15
+ def template_rake_gemspec(gem_name)
16
+ <<-EOF
16
17
  require 'rake/gempackagetask'
17
18
  SPEC = Gem::Specification.new do |s|
18
19
  s.name = "#{gem_name}"
@@ -37,52 +38,65 @@ gem_package = Rake::GemPackageTask.new(SPEC) do |pkg|
37
38
  pkg.need_tar = false
38
39
  end
39
40
  EOF
40
- end
41
+ end
41
42
 
42
- def template_rake_extension(extension_name, gem_spec = nil)
43
- <<-EOF
43
+ def template_rake_extension(extension_name, gem_spec = nil)
44
+ <<-EOF
44
45
  require 'rake/extensiontask'
45
46
  Rake::ExtensionTask.new("#{extension_name}"#{', SPEC' if gem_spec})
46
47
  EOF
47
- end
48
+ end
48
49
 
49
- def template_rake_extension_with_platform(extension_name, platform)
50
- <<-EOF
50
+ def template_rake_extension_with_platform(extension_name, platform)
51
+ <<-EOF
51
52
  require 'rake/extensiontask'
52
53
  Rake::ExtensionTask.new("#{extension_name}", SPEC) do |ext|
53
54
  ext.platform = "#{platform}"
54
55
  end
55
56
  EOF
56
- end
57
+ end
57
58
 
58
- def template_rake_extension_cross_compile(extension_name, gem_spec = nil)
59
- <<-EOF
59
+ def template_rake_extension_cross_compile(extension_name, gem_spec = nil)
60
+ <<-EOF
60
61
  require 'rake/extensiontask'
61
62
  Rake::ExtensionTask.new("#{extension_name}"#{', SPEC' if gem_spec}) do |ext|
62
63
  ext.cross_compile = true
63
64
  end
64
65
  EOF
66
+ end
67
+
68
+ def template_rake_extension_multi_cross_compile(extension_name)
69
+ <<-EOF
70
+ require 'rake/extensiontask'
71
+ Rake::ExtensionTask.new("#{extension_name}", SPEC) do |ext|
72
+ ext.cross_compile = true
73
+ ext.cross_platform = ['i386-mswin32', 'i386-mingw32']
65
74
  end
75
+ EOF
76
+ end
66
77
 
67
- def template_extconf(extension_name)
68
- <<-EOF
78
+ def template_extconf(extension_name)
79
+ <<-EOF
69
80
  require 'mkmf'
70
81
  create_makefile("#{extension_name}")
71
82
  EOF
72
- end
83
+ end
73
84
 
74
- def template_source_c(extension_name)
75
- <<-EOF
85
+ def template_source_c(extension_name)
86
+ <<-EOF
76
87
  #include "source.h"
77
88
  void Init_#{extension_name}()
78
89
  {
79
90
  printf("source.c of extension #{extension_name}\\n");
80
91
  }
81
92
  EOF
82
- end
93
+ end
83
94
 
84
- def template_source_h
85
- <<-EOF
95
+ def template_source_h
96
+ <<-EOF
86
97
  #include "ruby.h"
87
98
  EOF
99
+ end
88
100
  end
101
+
102
+ World(FileTemplateHelpers)
@@ -0,0 +1,96 @@
1
+ module GeneratorHelpers
2
+ def generate_scaffold_structure
3
+ # create folder structure
4
+ FileUtils.mkdir_p "lib"
5
+ FileUtils.mkdir_p "tasks"
6
+ FileUtils.mkdir_p "tmp"
7
+
8
+ # create Rakefile loader
9
+ File.open("Rakefile", 'w') do |rakefile|
10
+ rakefile.puts template_rakefile.strip
11
+ end
12
+ end
13
+
14
+ def generate_gem_task(gem_name)
15
+ # create generic gem task
16
+ File.open("tasks/gem.rake", 'w') do |gem_rake|
17
+ gem_rake.puts template_rake_gemspec(gem_name)
18
+ end
19
+ end
20
+
21
+ def generate_extension_task_for(extension_name, platform = nil)
22
+ # create folder structure
23
+ FileUtils.mkdir_p "ext/#{extension_name}"
24
+
25
+ return if File.exist?("tasks/#{extension_name}.rake")
26
+
27
+ # Building a gem?
28
+ if File.exist?("tasks/gem.rake") then
29
+ File.open("tasks/gem.rake", 'a+') do |ext_in_gem|
30
+ if platform
31
+ ext_in_gem.puts template_rake_extension_with_platform(extension_name, platform)
32
+ else
33
+ ext_in_gem.puts template_rake_extension(extension_name, true)
34
+ end
35
+ end
36
+ else
37
+ # create specific extension rakefile
38
+ File.open("tasks/#{extension_name}.rake", 'w') do |ext_rake|
39
+ ext_rake.puts template_rake_extension(extension_name)
40
+ end
41
+ end
42
+ end
43
+
44
+ def generate_cross_compile_extension_task_for(extension_name)
45
+ # create folder structure
46
+ FileUtils.mkdir_p "ext/#{extension_name}"
47
+
48
+ return if File.exist?("tasks/#{extension_name}.rake")
49
+
50
+ # create specific extension rakefile
51
+ # Building a gem?
52
+ if File.exist?("tasks/gem.rake") then
53
+ File.open("tasks/gem.rake", 'a+') do |ext_in_gem|
54
+ ext_in_gem.puts template_rake_extension_cross_compile(extension_name, true)
55
+ end
56
+ else
57
+ File.open("tasks/#{extension_name}.rake", 'w') do |ext_rake|
58
+ ext_rake.puts template_rake_extension_cross_compile(extension_name)
59
+ end
60
+ end
61
+ end
62
+
63
+ def generate_multi_cross_compile_extension_task_for(extension_name)
64
+ # create folder structure
65
+ FileUtils.mkdir_p "ext/#{extension_name}"
66
+
67
+ return if File.exist?("tasks/#{extension_name}.rake")
68
+
69
+ # create specific extension rakefile
70
+ # Building a gem?
71
+ if File.exist?("tasks/gem.rake") then
72
+ File.open("tasks/gem.rake", 'a+') do |ext_in_gem|
73
+ ext_in_gem.puts template_rake_extension_multi_cross_compile(extension_name)
74
+ end
75
+ end
76
+ end
77
+
78
+ def generate_source_code_for(extension_name)
79
+ # source C file
80
+ File.open("ext/#{extension_name}/source.c", 'w') do |c|
81
+ c.puts template_source_c(extension_name)
82
+ end
83
+
84
+ # header H file
85
+ File.open("ext/#{extension_name}/source.h", 'w') do |h|
86
+ h.puts template_source_h
87
+ end
88
+
89
+ # extconf.rb file
90
+ File.open("ext/#{extension_name}/extconf.rb", 'w') do |ext|
91
+ ext.puts template_extconf(extension_name)
92
+ end
93
+ end
94
+ end
95
+
96
+ World(GeneratorHelpers)
@@ -62,8 +62,13 @@ module Rake
62
62
  define_native_tasks if @gem_spec && @gem_spec.platform == 'ruby'
63
63
 
64
64
  # only define cross platform functionality when enabled
65
- # FIXME: there is no value for having this on Windows or JRuby
66
- define_cross_platform_tasks if @cross_compile
65
+ return unless @cross_compile
66
+
67
+ if cross_platform.is_a?(Array) then
68
+ cross_platform.each { |platf| define_cross_platform_tasks(platf) }
69
+ else
70
+ define_cross_platform_tasks(cross_platform)
71
+ end
67
72
  end
68
73
 
69
74
  private
@@ -218,7 +223,7 @@ module Rake
218
223
  end
219
224
  end
220
225
 
221
- def define_cross_platform_tasks
226
+ def define_cross_platform_tasks(for_platform)
222
227
  config_path = File.expand_path("~/.rake-compiler/config.yml")
223
228
  ruby_ver = ENV['RUBY_CC_VERSION'] || RUBY_VERSION
224
229
 
@@ -231,7 +236,7 @@ module Rake
231
236
  config_file = YAML.load_file(config_path)
232
237
 
233
238
  # tmp_path
234
- tmp_path = "#{@tmp_dir}/#{cross_platform}/#{@name}"
239
+ tmp_path = "#{@tmp_dir}/#{for_platform}/#{@name}"
235
240
 
236
241
  unless rbconfig_file = config_file["rbconfig-#{ruby_ver}"] then
237
242
  warn "no configuration section for specified version of Ruby (rbconfig-#{ruby_ver})"
@@ -239,7 +244,7 @@ module Rake
239
244
  end
240
245
 
241
246
  # define compilation tasks for cross platfrom!
242
- define_compile_tasks(cross_platform)
247
+ define_compile_tasks(for_platform)
243
248
 
244
249
  # chain fake.rb and rbconfig.rb to Makefile generation
245
250
  file "#{tmp_path}/Makefile" => ["#{tmp_path}/fake.rb", "#{tmp_path}/rbconfig.rb"]
@@ -257,27 +262,31 @@ module Rake
257
262
  end
258
263
 
259
264
  # now define native tasks for cross compiled files
260
- define_native_tasks(cross_platform) if @gem_spec && @gem_spec.platform == 'ruby'
265
+ define_native_tasks(for_platform) if @gem_spec && @gem_spec.platform == 'ruby'
261
266
 
262
267
  # create cross task
263
268
  task 'cross' do
264
269
  # clear compile dependencies
265
- Rake::Task['compile'].prerequisites.clear
270
+ Rake::Task['compile'].prerequisites.reject! { |t| !compiles_cross_platform.include?(t) }
266
271
 
267
272
  # chain the cross platform ones
268
- task 'compile' => ["compile:#{cross_platform}"]
273
+ task 'compile' => ["compile:#{for_platform}"]
269
274
 
270
275
  # clear lib/binary dependencies and trigger cross platform ones
271
276
  # check if lib/binary is defined (damn bundle versus so versus dll)
272
- if Rake::Task.task_defined?("#{@lib_dir}/#{binary(cross_platform)}") then
273
- Rake::Task["#{@lib_dir}/#{binary(cross_platform)}"].prerequisites.clear
277
+ if Rake::Task.task_defined?("#{@lib_dir}/#{binary(for_platform)}") then
278
+ Rake::Task["#{@lib_dir}/#{binary(for_platform)}"].prerequisites.clear
274
279
  end
275
- file "#{@lib_dir}/#{binary(cross_platform)}" => ["copy:#{@name}:#{cross_platform}"]
280
+
281
+ # FIXME: targeting multiple platforms copies the file twice
282
+ file "#{@lib_dir}/#{binary(for_platform)}" => ["copy:#{@name}:#{for_platform}"]
276
283
 
277
284
  # if everything for native task is in place
278
285
  if @gem_spec && @gem_spec.platform == 'ruby' then
279
- Rake::Task['native'].prerequisites.clear
280
- task 'native' => ["native:#{cross_platform}"]
286
+ # double check: only cross platform native tasks should be here
287
+ # FIXME: Sooo brittle
288
+ Rake::Task['native'].prerequisites.reject! { |t| !natives_cross_platform.include?(t) }
289
+ task 'native' => ["native:#{for_platform}"]
281
290
  end
282
291
  end
283
292
  end
@@ -306,6 +315,14 @@ module Rake
306
315
  @source_files ||= FileList["#{@ext_dir}/#{@source_pattern}"]
307
316
  end
308
317
 
318
+ def compiles_cross_platform
319
+ [*@cross_platform].map { |p| "compile:#{p}" }
320
+ end
321
+
322
+ def natives_cross_platform
323
+ [*@cross_platform].map { |p| "native:#{p}" }
324
+ end
325
+
309
326
  def fake_rb(version)
310
327
  <<-FAKE_RB
311
328
  class Object
@@ -4,8 +4,8 @@ require 'rake/extensiontask'
4
4
  require 'rbconfig'
5
5
 
6
6
  describe Rake::ExtensionTask do
7
- describe '#new' do
8
- describe '(basic)' do
7
+ context '#new' do
8
+ context '(basic)' do
9
9
  it 'should raise an error if no name is provided' do
10
10
  lambda {
11
11
  Rake::ExtensionTask.new
@@ -55,7 +55,7 @@ describe Rake::ExtensionTask do
55
55
  end
56
56
  end
57
57
 
58
- describe '(defaults)' do
58
+ context '(defaults)' do
59
59
  before :each do
60
60
  @ext = Rake::ExtensionTask.new('extension_one')
61
61
  end
@@ -97,14 +97,14 @@ describe Rake::ExtensionTask do
97
97
  end
98
98
  end
99
99
 
100
- describe '(tasks)' do
100
+ context '(tasks)' do
101
101
  before :each do
102
102
  Rake.application.clear
103
103
  CLEAN.clear
104
104
  CLOBBER.clear
105
105
  end
106
106
 
107
- describe '(one extension)' do
107
+ context '(one extension)' do
108
108
  before :each do
109
109
  Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"])
110
110
  @ext = Rake::ExtensionTask.new('extension_one')
@@ -112,7 +112,7 @@ describe Rake::ExtensionTask do
112
112
  @platform = RUBY_PLATFORM
113
113
  end
114
114
 
115
- describe 'compile' do
115
+ context 'compile' do
116
116
  it 'should define as task' do
117
117
  Rake::Task.task_defined?('compile').should be_true
118
118
  end
@@ -122,7 +122,7 @@ describe Rake::ExtensionTask do
122
122
  end
123
123
  end
124
124
 
125
- describe 'compile:extension_one' do
125
+ context 'compile:extension_one' do
126
126
  it 'should define as task' do
127
127
  Rake::Task.task_defined?('compile:extension_one').should be_true
128
128
  end
@@ -132,7 +132,7 @@ describe Rake::ExtensionTask do
132
132
  end
133
133
  end
134
134
 
135
- describe 'lib/extension_one.{so,bundle}' do
135
+ context 'lib/extension_one.{so,bundle}' do
136
136
  it 'should define as task' do
137
137
  Rake::Task.task_defined?("lib/#{@ext_bin}").should be_true
138
138
  end
@@ -142,7 +142,7 @@ describe Rake::ExtensionTask do
142
142
  end
143
143
  end
144
144
 
145
- describe 'tmp/{platform}/extension_one/extension_one.{so,bundle}' do
145
+ context 'tmp/{platform}/extension_one/extension_one.{so,bundle}' do
146
146
  it 'should define as task' do
147
147
  Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ext_bin}").should be_true
148
148
  end
@@ -160,7 +160,7 @@ describe Rake::ExtensionTask do
160
160
  end
161
161
  end
162
162
 
163
- describe 'tmp/{platform}/extension_one/Makefile' do
163
+ context 'tmp/{platform}/extension_one/Makefile' do
164
164
  it 'should define as task' do
165
165
  Rake::Task.task_defined?("tmp/#{@platform}/extension_one/Makefile").should be_true
166
166
  end
@@ -174,13 +174,13 @@ describe Rake::ExtensionTask do
174
174
  end
175
175
  end
176
176
 
177
- describe 'clean' do
177
+ context 'clean' do
178
178
  it "should include 'tmp/{platform}/extension_one' in the pattern" do
179
179
  CLEAN.should include("tmp/#{@platform}/extension_one")
180
180
  end
181
181
  end
182
182
 
183
- describe 'clobber' do
183
+ context 'clobber' do
184
184
  it "should include 'lib/extension_one.{so,bundle}'" do
185
185
  CLOBBER.should include("lib/#{@ext_bin}")
186
186
  end
@@ -191,7 +191,7 @@ describe Rake::ExtensionTask do
191
191
  end
192
192
  end
193
193
 
194
- describe '(extension in custom location)' do
194
+ context '(extension in custom location)' do
195
195
  before :each do
196
196
  Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"])
197
197
  @ext = Rake::ExtensionTask.new('extension_one') do |ext|
@@ -201,14 +201,14 @@ describe Rake::ExtensionTask do
201
201
  @platform = RUBY_PLATFORM
202
202
  end
203
203
 
204
- describe 'tmp/{platform}/extension_one/Makefile' do
204
+ context 'tmp/{platform}/extension_one/Makefile' do
205
205
  it "should depend on 'custom/ext/foo/extconf.rb'" do
206
206
  Rake::Task["tmp/#{@platform}/extension_one/Makefile"].prerequisites.should include("custom/ext/foo/extconf.rb")
207
207
  end
208
208
  end
209
209
  end
210
210
 
211
- describe '(native tasks)' do
211
+ context '(native tasks)' do
212
212
  before :each do
213
213
  Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"])
214
214
  @spec = mock_gem_spec
@@ -216,7 +216,7 @@ describe Rake::ExtensionTask do
216
216
  @platform = RUBY_PLATFORM
217
217
  end
218
218
 
219
- describe 'native' do
219
+ context 'native' do
220
220
  before :each do
221
221
  @spec.stub!(:platform=).and_return('ruby')
222
222
  end
@@ -243,7 +243,7 @@ describe Rake::ExtensionTask do
243
243
  Rake::Task["native"].prerequisites.should include("native:#{@platform}")
244
244
  end
245
245
 
246
- describe 'native:my_gem:{platform}' do
246
+ context 'native:my_gem:{platform}' do
247
247
  it 'should depend on binary extension' do
248
248
  Rake::ExtensionTask.new('extension_one', @spec)
249
249
  Rake::Task["native:my_gem:#{@platform}"].prerequisites.should include("tmp/#{@platform}/extension_one/#{@ext_bin}")
@@ -252,7 +252,7 @@ describe Rake::ExtensionTask do
252
252
  end
253
253
  end
254
254
 
255
- describe '(cross platform tasks)' do
255
+ context '(cross platform tasks)' do
256
256
  before :each do
257
257
  File.stub!(:exist?).and_return(true)
258
258
  YAML.stub!(:load_file).and_return(mock_config_yml)
@@ -311,7 +311,7 @@ describe Rake::ExtensionTask do
311
311
  ENV.delete('RUBY_CC_VERSION')
312
312
  end
313
313
 
314
- describe "(cross for 'universal-unknown' platform)" do
314
+ context "(cross for 'universal-unknown' platform)" do
315
315
  before :each do
316
316
  @ext = Rake::ExtensionTask.new('extension_one', @spec) do |ext|
317
317
  ext.cross_compile = true
@@ -319,13 +319,13 @@ describe Rake::ExtensionTask do
319
319
  end
320
320
  end
321
321
 
322
- describe 'fake' do
322
+ context 'fake' do
323
323
  it 'should chain fake task to Makefile generation' do
324
324
  Rake::Task['tmp/universal-unknown/extension_one/Makefile'].prerequisites.should include('tmp/universal-unknown/extension_one/fake.rb')
325
325
  end
326
326
  end
327
327
 
328
- describe 'rbconfig' do
328
+ context 'rbconfig' do
329
329
  it 'should chain rbconfig tasks to Makefile generation' do
330
330
  Rake::Task['tmp/universal-unknown/extension_one/Makefile'].prerequisites.should include('tmp/universal-unknown/extension_one/rbconfig.rb')
331
331
  end
@@ -335,7 +335,7 @@ describe Rake::ExtensionTask do
335
335
  end
336
336
  end
337
337
 
338
- describe 'compile:universal-unknown' do
338
+ context 'compile:universal-unknown' do
339
339
  it "should be defined" do
340
340
  Rake::Task.task_defined?('compile:universal-unknown').should be_true
341
341
  end
@@ -345,7 +345,7 @@ describe Rake::ExtensionTask do
345
345
  end
346
346
  end
347
347
 
348
- describe 'native:universal-unknown' do
348
+ context 'native:universal-unknown' do
349
349
  it "should be defined" do
350
350
  Rake::Task.task_defined?('native:universal-unknown').should be_true
351
351
  end
@@ -355,6 +355,18 @@ describe Rake::ExtensionTask do
355
355
  end
356
356
  end
357
357
  end
358
+
359
+ context '(cross for multiple platforms)' do
360
+ it 'should define task for each supplied platform' do
361
+ @ext = Rake::ExtensionTask.new('extension_one', @spec) do |ext|
362
+ ext.cross_compile = true
363
+ ext.cross_platform = ['universal-known', 'universal-unknown']
364
+ end
365
+
366
+ Rake::Task.should have_defined('compile:universal-known')
367
+ Rake::Task.should have_defined('compile:universal-unknown')
368
+ end
369
+ end
358
370
  end
359
371
  end
360
372
 
data/spec/spec_helper.rb CHANGED
@@ -9,5 +9,7 @@ require 'spec'
9
9
  require File.expand_path(File.join(File.dirname(__FILE__), 'support/capture_output_helper'))
10
10
 
11
11
  Spec::Runner.configure do |config|
12
+ config.predicate_matchers[:have_defined] = :task_defined?
13
+
12
14
  include CaptureOutputHelper
13
15
  end
data/tasks/gem.rake CHANGED
@@ -1,17 +1,14 @@
1
- require 'rake/gempackagetask'
1
+ require 'rubygems/package_task'
2
2
 
3
3
  GEM_SPEC = Gem::Specification.new do |s|
4
4
  # basic information
5
5
  s.name = "rake-compiler"
6
- s.version = "0.4.1"
6
+ s.version = "0.5.0"
7
7
  s.platform = Gem::Platform::RUBY
8
8
 
9
9
  # description and details
10
10
  s.summary = 'Rake-based Ruby C Extension task generator.'
11
- s.description = <<-EOF
12
- Provide a standard and simplified way to build and package
13
- Ruby C extensions using Rake as glue.
14
- EOF
11
+ s.description = "Provide a standard and simplified way to build and package\nRuby C extensions using Rake as glue."
15
12
 
16
13
  # dependencies
17
14
  s.add_dependency 'rake', '>= 0.8.3', '< 0.9'
@@ -39,21 +36,22 @@ GEM_SPEC = Gem::Specification.new do |s|
39
36
  # project information
40
37
  s.homepage = 'http://github.com/luislavena/rake-compiler'
41
38
  s.rubyforge_project = 'rake-compiler'
39
+ s.licenses = ['MIT']
42
40
 
43
41
  # author and contributors
44
42
  s.author = 'Luis Lavena'
45
43
  s.email = 'luislavena@gmail.com'
46
44
  end
47
45
 
48
- gem_package = Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
46
+ gem_package = Gem::PackageTask.new(GEM_SPEC) do |pkg|
49
47
  pkg.need_tar = false
50
48
  pkg.need_zip = false
51
49
  end
52
50
 
53
- file 'rake-compiler.gemspec' => ['Rakefile', 'tasks/gem.rake'] do |t|
51
+ file "#{GEM_SPEC.name}.gemspec" => ['Rakefile', 'tasks/gem.rake'] do |t|
54
52
  puts "Generating #{t.name}"
55
53
  File.open(t.name, 'w') { |f| f.puts GEM_SPEC.to_yaml }
56
54
  end
57
55
 
58
56
  desc "Generate or update the standalone gemspec file for the project"
59
- task :gemspec => ['rake-compiler.gemspec']
57
+ task :gemspec => ["#{GEM_SPEC.name}.gemspec"]
data/tasks/news.rake CHANGED
@@ -5,6 +5,8 @@ rescue Exception
5
5
  nil
6
6
  end
7
7
 
8
+ CLEAN.include('email.txt')
9
+
8
10
  if defined?(RubyForge) then
9
11
  if defined?(GEM_SPEC) then
10
12
  desc 'Create news email file and post to RubyForge.'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Lavena
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-09 00:00:00 -03:00
12
+ date: 2009-04-25 00:00:00 -03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -25,7 +25,9 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: "0.9"
27
27
  version:
28
- description: Provide a standard and simplified way to build and package Ruby C extensions using Rake as glue.
28
+ description: |-
29
+ Provide a standard and simplified way to build and package
30
+ Ruby C extensions using Rake as glue.
29
31
  email: luislavena@gmail.com
30
32
  executables:
31
33
  - rake-compiler
@@ -38,6 +40,7 @@ extra_rdoc_files:
38
40
  files:
39
41
  - features/compile.feature
40
42
  - features/cross-compile.feature
43
+ - features/cross-package-multi.feature
41
44
  - features/cross-package.feature
42
45
  - features/package.feature
43
46
  - features/step_definitions/compilation.rb
@@ -46,8 +49,8 @@ files:
46
49
  - features/step_definitions/folders.rb
47
50
  - features/step_definitions/gem.rb
48
51
  - features/support/env.rb
49
- - features/support/file_templates.rb
50
- - features/support/generators.rb
52
+ - features/support/file_template_helpers.rb
53
+ - features/support/generator_helpers.rb
51
54
  - bin/rake-compiler
52
55
  - lib/rake/extensioncompiler.rb
53
56
  - lib/rake/extensiontask.rb
@@ -70,6 +73,8 @@ files:
70
73
  - cucumber.yml
71
74
  has_rdoc: true
72
75
  homepage: http://github.com/luislavena/rake-compiler
76
+ licenses:
77
+ - MIT
73
78
  post_install_message:
74
79
  rdoc_options:
75
80
  - --main
@@ -93,9 +98,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
98
  requirements: []
94
99
 
95
100
  rubyforge_project: rake-compiler
96
- rubygems_version: 1.3.1
101
+ rubygems_version: 1.3.2
97
102
  signing_key:
98
- specification_version: 2
103
+ specification_version: 3
99
104
  summary: Rake-based Ruby C Extension task generator.
100
105
  test_files: []
101
106
 
@@ -1,77 +0,0 @@
1
- def generate_scaffold_structure
2
- # create folder structure
3
- FileUtils.mkdir_p "lib"
4
- FileUtils.mkdir_p "tasks"
5
- FileUtils.mkdir_p "tmp"
6
-
7
- # create Rakefile loader
8
- File.open("Rakefile", 'w') do |rakefile|
9
- rakefile.puts template_rakefile.strip
10
- end
11
- end
12
-
13
- def generate_gem_task(gem_name)
14
- # create generic gem task
15
- File.open("tasks/gem.rake", 'w') do |gem_rake|
16
- gem_rake.puts template_rake_gemspec(gem_name)
17
- end
18
- end
19
-
20
- def generate_extension_task_for(extension_name, platform = nil)
21
- # create folder structure
22
- FileUtils.mkdir_p "ext/#{extension_name}"
23
-
24
- return if File.exist?("tasks/#{extension_name}.rake")
25
-
26
- # Building a gem?
27
- if File.exist?("tasks/gem.rake") then
28
- File.open("tasks/gem.rake", 'a+') do |ext_in_gem|
29
- if platform
30
- ext_in_gem.puts template_rake_extension_with_platform(extension_name, platform)
31
- else
32
- ext_in_gem.puts template_rake_extension(extension_name, true)
33
- end
34
- end
35
- else
36
- # create specific extension rakefile
37
- File.open("tasks/#{extension_name}.rake", 'w') do |ext_rake|
38
- ext_rake.puts template_rake_extension(extension_name)
39
- end
40
- end
41
- end
42
-
43
- def generate_cross_compile_extension_task_for(extension_name)
44
- # create folder structure
45
- FileUtils.mkdir_p "ext/#{extension_name}"
46
-
47
- return if File.exist?("tasks/#{extension_name}.rake")
48
-
49
- # create specific extension rakefile
50
- # Building a gem?
51
- if File.exist?("tasks/gem.rake") then
52
- File.open("tasks/gem.rake", 'a+') do |ext_in_gem|
53
- ext_in_gem.puts template_rake_extension_cross_compile(extension_name, true)
54
- end
55
- else
56
- File.open("tasks/#{extension_name}.rake", 'w') do |ext_rake|
57
- ext_rake.puts template_rake_extension_cross_compile(extension_name)
58
- end
59
- end
60
- end
61
-
62
- def generate_source_code_for(extension_name)
63
- # source C file
64
- File.open("ext/#{extension_name}/source.c", 'w') do |c|
65
- c.puts template_source_c(extension_name)
66
- end
67
-
68
- # header H file
69
- File.open("ext/#{extension_name}/source.h", 'w') do |h|
70
- h.puts template_source_h
71
- end
72
-
73
- # extconf.rb file
74
- File.open("ext/#{extension_name}/extconf.rb", 'w') do |ext|
75
- ext.puts template_extconf(extension_name)
76
- end
77
- end