luislavena-rake-compiler 0.2.1 → 0.3.0

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 CHANGED
@@ -1,3 +1,21 @@
1
+ === 0.3.0 / 2008-12-07
2
+
3
+ * 1 Major Enhancement:
4
+
5
+ * Let you specify the Ruby version used for cross compilation instead
6
+ of default one.
7
+
8
+ rake cross compile RUBY_CC_VERSION=1.8
9
+
10
+ * 2 Minor Enhancements:
11
+
12
+ * Properly update rake-compiler configuration when new version is installed.
13
+ * Automated release process to RubyForge, yay!
14
+
15
+ * 1 Bug fix:
16
+
17
+ * Corrected documentation to reflect the available options
18
+
1
19
  === 0.2.1 / 2008-11-30
2
20
 
3
21
  * 2 Major Enhancements:
data/README.rdoc CHANGED
@@ -10,7 +10,6 @@ This is the result of expriences dealing with several Gems that required
10
10
  native extensions across platforms and different user configurations
11
11
  where details like portability and clarity of code were lacking.
12
12
 
13
-
14
13
  == An Overview
15
14
 
16
15
  Let's summarize what rake-compiler provides:
@@ -23,6 +22,7 @@ Let's summarize what rake-compiler provides:
23
22
 
24
23
  * Mimics RubyGems installation process, so helps as test environment.
25
24
 
25
+ * Simplify cross platform compilation of extensions (target Windows from Linux).
26
26
 
27
27
  == I'm sold! show me how to use it! (Installation)
28
28
 
@@ -39,12 +39,10 @@ from GitHub:
39
39
 
40
40
  The development gem is usually in pretty good shape actually.
41
41
 
42
-
43
42
  == Now what? (Usage)
44
43
 
45
44
  Now that you have the gem installed, let's give your project some structure.
46
45
 
47
-
48
46
  === Structure
49
47
 
50
48
  Let's say we want to compile an extension called 'hello_world', so we should
@@ -60,7 +58,6 @@ organize the code and folders that will help rake-compiler do it's job:
60
58
  TIP: Having a consistent folder structure will help developers and newcomers
61
59
  to find code and also contribute back to your project more easily.
62
60
 
63
-
64
61
  === Adding the code
65
62
 
66
63
  So now it's time to introduce the code to compile our extension:
@@ -73,7 +70,6 @@ So now it's time to introduce the code to compile our extension:
73
70
 
74
71
  Ok, that's it. No other line of code.
75
72
 
76
-
77
73
  === Compile process
78
74
 
79
75
  Those *two* lines of code automatically added the needed rake tasks to build
@@ -162,7 +158,6 @@ personalize several settings for <tt>Rake::ExtensionTask</tt>:
162
158
  # will be used to based on.
163
159
  end
164
160
 
165
-
166
161
  == Future is now: Cross compilation
167
162
 
168
163
  rake-compiler provides now an standarized way to generate, from Linux or OSX
@@ -171,7 +166,6 @@ both extensions and gem binaries for Windows!
171
166
  It takes advantages from GCC host/target to build binaries (for target) on
172
167
  different OS (hosts).
173
168
 
174
-
175
169
  === How I enjoy this?
176
170
 
177
171
  Besides having the development tool chain installed (GCC), you should install
@@ -182,7 +176,6 @@ will be enough.
182
176
 
183
177
  Please check OSX documentation about installing mingw32 from macports.
184
178
 
185
-
186
179
  === I have my toolchain, now what?
187
180
 
188
181
  You need to build Ruby for Windows.
@@ -222,12 +215,21 @@ Compiles keeps being simple:
222
215
 
223
216
  rake cross compile
224
217
 
225
- And now, build your gems for Windows is just 4 more letters:
218
+ And now, build your gems for Windows is just 5 more letters:
226
219
 
227
220
  rake cross native gem
228
221
 
229
222
  And you're done, yeah.
230
223
 
224
+ === Take it even further
225
+
226
+ You can specify against with version of Ruby you want to build the extension:
227
+
228
+ rake cross compile RUBY_CC_VERSION=1.8
229
+
230
+ If you installed <tt>1.9.1</tt>, you can do:
231
+
232
+ rake cross compile RUBY_CC_VERSION=1.9
231
233
 
232
234
  == Future
233
235
 
@@ -237,16 +239,15 @@ development of it! (and contributions too!)
237
239
  You can find more information about rake-compiler:
238
240
 
239
241
  Blog: http://blog.mmediasys.com
242
+ RubyForge: http://rubyforge.org/projects/rake-compiler
240
243
  GitHub: http://github.com/luislavena/rake-compiler
241
244
 
242
-
243
- === Some of the features already underworks
245
+ === Some of the desired features
244
246
 
245
247
  * <tt>Rake::JavaJarTask</tt> to generate <tt>jar</tt> packages and gems for JRuby.
246
248
 
247
249
  $ rake java gem
248
250
 
249
-
250
251
  == Disclaimer
251
252
 
252
253
  If you have any trouble, don't hesitate to contact the author. As always,
@@ -1,6 +1,7 @@
1
1
  # Naive way of looking into platforms, please include others like FreeBSD?
2
- if RUBY_PLATFORM =~ /linux|darwin/
3
- Given %r{^I'm running a POSIX operating system$} do
2
+ Given %r{^I'm running a POSIX operating system$} do
3
+ unless RUBY_PLATFORM =~ /linux|darwin/ then
4
+ raise Cucumber::Pending.new("You need a POSIX operating system, no cheating ;-)")
4
5
  end
5
6
  end
6
7
 
@@ -200,7 +200,7 @@ module Rake
200
200
 
201
201
  def define_cross_platform_tasks
202
202
  config_path = File.expand_path("~/.rake-compiler/config.yml")
203
- major_ver = RUBY_VERSION.match(/(\d+.\d+)/)[1]
203
+ major_ver = (ENV['RUBY_CC_VERSION'] || RUBY_VERSION).match(/(\d+.\d+)/)[1]
204
204
 
205
205
  # warn the user about the need of configuration to use cross compilation.
206
206
  unless File.exist?(config_path)
@@ -277,6 +277,20 @@ describe Rake::ExtensionTask do
277
277
  }.should raise_error(RuntimeError, /no configuration section for this version of Ruby/)
278
278
  end
279
279
 
280
+ it 'should allow usage of RUBY_CC_VERSION to indicate a different version of ruby' do
281
+ config = mock(Hash)
282
+ config.should_receive(:[]).with("rbconfig-2.0").and_return('/path/to/ruby/2.0/rbconfig.rb')
283
+ YAML.stub!(:load_file).and_return(config)
284
+ begin
285
+ ENV['RUBY_CC_VERSION'] = '2.0'
286
+ Rake::ExtensionTask.new('extension_one') do |ext|
287
+ ext.cross_compile = true
288
+ end
289
+ ensure
290
+ ENV.delete('RUBY_CC_VERSION')
291
+ end
292
+ end
293
+
280
294
  describe "(cross for 'universal-unknown' platform)" do
281
295
  before :each do
282
296
  @ext = Rake::ExtensionTask.new('extension_one', @spec) do |ext|
@@ -133,10 +133,11 @@ end
133
133
  # rbconfig.rb location
134
134
  file "#{USER_HOME}/ruby/#{RUBY_CC_VERSION}/lib/ruby/#{MAJOR}/i386-mingw32/rbconfig.rb" => ["#{USER_HOME}/ruby/#{RUBY_CC_VERSION}/bin/ruby.exe"]
135
135
 
136
- file "#{USER_HOME}/config.yml" => ["#{USER_HOME}/ruby/#{RUBY_CC_VERSION}/lib/ruby/#{MAJOR}/i386-mingw32/rbconfig.rb"] do |t|
137
- if File.exist?(t.name) then
136
+ file :update_config => ["#{USER_HOME}/ruby/#{RUBY_CC_VERSION}/lib/ruby/#{MAJOR}/i386-mingw32/rbconfig.rb"] do |t|
137
+ config_file = "#{USER_HOME}/config.yml"
138
+ if File.exist?(config_file) then
138
139
  puts "Updating #{t.name}"
139
- config = YAML.load_file(t.name)
140
+ config = YAML.load_file(config_file)
140
141
  else
141
142
  puts "Generating #{t.name}"
142
143
  config = {}
@@ -144,8 +145,8 @@ file "#{USER_HOME}/config.yml" => ["#{USER_HOME}/ruby/#{RUBY_CC_VERSION}/lib/rub
144
145
 
145
146
  config["rbconfig-#{MAJOR}"] = File.expand_path(t.prerequisites.first)
146
147
 
147
- when_writing("Saving changes into #{t.name}") {
148
- File.open(t.name, 'w') do |f|
148
+ when_writing("Saving changes into #{config_file}") {
149
+ File.open(config_file, 'w') do |f|
149
150
  f.puts config.to_yaml
150
151
  end
151
152
  }
@@ -155,4 +156,4 @@ task :default do
155
156
  end
156
157
 
157
158
  desc "Build #{RUBY_CC_VERSION} suitable for cross-platform development."
158
- task 'cross-ruby' => [:mingw32, :environment, "#{USER_HOME}/config.yml"]
159
+ task 'cross-ruby' => [:mingw32, :environment, :update_config]
data/tasks/common.rake CHANGED
@@ -5,3 +5,9 @@ CLEAN.include('tmp')
5
5
 
6
6
  # set default task
7
7
  task :default => [:spec, :features]
8
+
9
+ # make packing depend on success of running specs and features
10
+ task :package => [:spec, :features]
11
+
12
+ # make the release re-generate the gemspec if required
13
+ task :release => [:gemspec]
@@ -1,9 +1,9 @@
1
1
  require 'rake/gempackagetask'
2
2
 
3
- spec = Gem::Specification.new do |s|
3
+ GEM_SPEC = Gem::Specification.new do |s|
4
4
  # basic information
5
5
  s.name = "rake-compiler"
6
- s.version = "0.2.1"
6
+ s.version = "0.3.0"
7
7
  s.platform = Gem::Platform::RUBY
8
8
 
9
9
  # description and details
@@ -37,22 +37,22 @@ spec = Gem::Specification.new do |s|
37
37
  s.extra_rdoc_files = %w(README.rdoc LICENSE.txt History.txt)
38
38
 
39
39
  # project information
40
- s.homepage = 'http://github.com/luislavena/rake-compiler'
41
- s.rubyforge_project = 'TODO'
40
+ s.homepage = 'http://github.com/luislavena/rake-compiler'
41
+ s.rubyforge_project = 'rake-compiler'
42
42
 
43
43
  # author and contributors
44
44
  s.author = 'Luis Lavena'
45
45
  s.email = 'luislavena@gmail.com'
46
46
  end
47
47
 
48
- gem_package = Rake::GemPackageTask.new(spec) do |pkg|
48
+ gem_package = Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
49
49
  pkg.need_tar = false
50
50
  pkg.need_zip = false
51
51
  end
52
52
 
53
- file 'rake-compiler.gemspec' => ['Rakefile', 'tasks/rubygems.rake'] do |t|
53
+ file 'rake-compiler.gemspec' => ['Rakefile', 'tasks/gem.rake'] do |t|
54
54
  puts "Generating #{t.name}"
55
- File.open(t.name, 'w') { |f| f.puts spec.to_yaml }
55
+ File.open(t.name, 'w') { |f| f.puts GEM_SPEC.to_yaml }
56
56
  end
57
57
 
58
58
  desc "Generate or update the standalone gemspec file for the project"
@@ -0,0 +1,79 @@
1
+ begin
2
+ gem 'rubyforge', '~> 1.0.1'
3
+ require 'rubyforge'
4
+ rescue Exception
5
+ nil
6
+ end
7
+
8
+ if defined?(RubyForge) then
9
+ if defined?(GEM_SPEC) then
10
+ task :release => [:clean, :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
25
+
26
+ # read project info and overview
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
34
+
35
+ # read changes
36
+ changes = begin
37
+ h = File.read("History.txt")
38
+ h.split(/^(==.*)/)[1..2].join.strip
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
+ # ensure this was not released before
54
+ releases = rf.autoconfig['release_ids']
55
+ if releases.has_key?(GEM_SPEC.name) and releases[GEM_SPEC.name][GEM_SPEC.version] then
56
+ fail "Release #{GEM_SPEC.version} already exist. Unable to release."
57
+ end
58
+
59
+ files = FileList["pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version}*.*"].to_a
60
+ fail "No files found for the release." if files.empty?
61
+
62
+ puts "Logging in RubyForge..."
63
+ rf.login
64
+
65
+ puts "Files to upload:"
66
+ files.each do |f|
67
+ puts " * #{f}"
68
+ end
69
+
70
+ puts "Releasing #{GEM_SPEC.name} version #{GEM_SPEC.version}..."
71
+ #rf.add_release GEM_SPEC.rubyforge_project, GEM_SPEC.name, GEM_SPEC.version, *files
72
+ puts "Done."
73
+ end
74
+ else
75
+ warn "no GEM_SPEC is found or defined. 'release' task cannot work without it."
76
+ end
77
+ else
78
+ warn "rubyforge gem is required to generate releases, please install it (gem install rubyforge)."
79
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luislavena-rake-compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.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: 2008-11-29 21:00:00 -08:00
12
+ date: 2008-12-06 21:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -55,9 +55,10 @@ files:
55
55
  - tasks/bin/cross-ruby.rake
56
56
  - tasks/common.rake
57
57
  - tasks/cucumber.rake
58
+ - tasks/gem.rake
58
59
  - tasks/rdoc.rake
60
+ - tasks/release.rake
59
61
  - tasks/rspec.rake
60
- - tasks/rubygems.rake
61
62
  - Rakefile
62
63
  - README.rdoc
63
64
  - History.txt
@@ -87,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  version:
88
89
  requirements: []
89
90
 
90
- rubyforge_project: TODO
91
+ rubyforge_project: rake-compiler
91
92
  rubygems_version: 1.2.0
92
93
  signing_key:
93
94
  specification_version: 2