rake-compiler 0.3.0 → 0.5.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.
@@ -21,12 +21,22 @@ require 'rake'
21
21
  require 'rake/clean'
22
22
  require 'yaml'
23
23
 
24
+ # load compiler helpers
25
+ # add lib directory to the search path
26
+ libdir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
27
+ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
28
+
29
+ require 'rake/extensioncompiler'
30
+
24
31
  USER_HOME = File.expand_path("~/.rake-compiler")
25
32
  RUBY_CC_VERSION = "ruby-#{ENV['VERSION'] || '1.8.6-p287'}"
26
33
 
27
34
  # grab the major "1.8" or "1.9" part of the version number
28
35
  MAJOR = RUBY_CC_VERSION.match(/.*-(\d.\d).\d/)[1]
29
36
 
37
+ # Use Rake::ExtensionCompiler helpers to find the proper host
38
+ MINGW_HOST = Rake::ExtensionCompiler.mingw_host
39
+
30
40
  # define a location where sources will be stored
31
41
  directory "#{USER_HOME}/sources/#{RUBY_CC_VERSION}"
32
42
  directory "#{USER_HOME}/builds/#{RUBY_CC_VERSION}"
@@ -45,7 +55,7 @@ CLOBBER.include("#{USER_HOME}/config.yml")
45
55
  file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}.tar.gz" => ["#{USER_HOME}/sources"] do |t|
46
56
  # download the source file using wget or curl
47
57
  chdir File.dirname(t.name) do
48
- url = "ftp://ftp.ruby-lang.org/pub/ruby/#{MAJOR}/#{File.basename(t.name)}"
58
+ url = "http://ftp.ruby-lang.org/pub/ruby/#{MAJOR}/#{File.basename(t.name)}"
49
59
  sh "wget #{url} || curl -O #{url}"
50
60
  end
51
61
  end
@@ -82,9 +92,9 @@ file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in" => ["#{USER_HOME}/sou
82
92
  end
83
93
 
84
94
  task :mingw32 do
85
- unless File.exist?('/usr/bin/i586-mingw32msvc-gcc') then
95
+ unless MINGW_HOST then
86
96
  warn "You need to install mingw32 cross compile functionality to be able to continue."
87
- warn "Please refer to your distro documentation about installation."
97
+ warn "Please refer to your distribution/package manager documentation about installation."
88
98
  fail
89
99
  end
90
100
  end
@@ -101,12 +111,14 @@ end
101
111
  file "#{USER_HOME}/builds/#{RUBY_CC_VERSION}/Makefile" => ["#{USER_HOME}/builds/#{RUBY_CC_VERSION}",
102
112
  "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in"] do |t|
103
113
 
104
- # set the configure options
105
114
  options = [
106
- '--host=i586-mingw32msvc',
107
115
  '--target=i386-mingw32',
116
+ "--host=#{MINGW_HOST}",
108
117
  '--build=i686-linux',
109
- '--enable-shared'
118
+ '--enable-shared',
119
+ '--disable-install-doc',
120
+ '--without-tk',
121
+ '--without-tcl'
110
122
  ]
111
123
 
112
124
  chdir File.dirname(t.name) do
@@ -129,21 +141,26 @@ file "#{USER_HOME}/ruby/#{RUBY_CC_VERSION}/bin/ruby.exe" => ["#{USER_HOME}/build
129
141
  sh "make install"
130
142
  end
131
143
  end
144
+ task :install => ["#{USER_HOME}/ruby/#{RUBY_CC_VERSION}/bin/ruby.exe"]
132
145
 
133
- # rbconfig.rb location
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
-
136
- file :update_config => ["#{USER_HOME}/ruby/#{RUBY_CC_VERSION}/lib/ruby/#{MAJOR}/i386-mingw32/rbconfig.rb"] do |t|
146
+ desc "Update rake-compiler list of installed Ruby versions"
147
+ task 'update-config' do
137
148
  config_file = "#{USER_HOME}/config.yml"
138
149
  if File.exist?(config_file) then
139
- puts "Updating #{t.name}"
150
+ puts "Updating #{config_file}"
140
151
  config = YAML.load_file(config_file)
141
152
  else
142
- puts "Generating #{t.name}"
153
+ puts "Generating #{config_file}"
143
154
  config = {}
144
155
  end
145
156
 
146
- config["rbconfig-#{MAJOR}"] = File.expand_path(t.prerequisites.first)
157
+ files = Dir.glob("#{USER_HOME}/ruby/**/rbconfig.rb").sort
158
+
159
+ files.each do |rbconfig|
160
+ version = rbconfig.match(/.*-(\d.\d.\d)/)[1]
161
+ config["rbconfig-#{version}"] = rbconfig
162
+ puts "Found Ruby version #{version} (#{rbconfig})"
163
+ end
147
164
 
148
165
  when_writing("Saving changes into #{config_file}") {
149
166
  File.open(config_file, 'w') do |f|
@@ -153,7 +170,10 @@ file :update_config => ["#{USER_HOME}/ruby/#{RUBY_CC_VERSION}/lib/ruby/#{MAJOR}/
153
170
  end
154
171
 
155
172
  task :default do
173
+ # Force the display of the available tasks when no option is given
174
+ Rake.application.options.show_task_pattern = //
175
+ Rake.application.display_tasks_and_comments
156
176
  end
157
177
 
158
178
  desc "Build #{RUBY_CC_VERSION} suitable for cross-platform development."
159
- task 'cross-ruby' => [:mingw32, :environment, :update_config]
179
+ task 'cross-ruby' => [:mingw32, :environment, :install, 'update-config']
data/tasks/common.rake CHANGED
@@ -11,3 +11,6 @@ task :package => [:spec, :features]
11
11
 
12
12
  # make the release re-generate the gemspec if required
13
13
  task :release => [:gemspec]
14
+
15
+ # publish documentation when doing a release
16
+ task :release => [:publish]
data/tasks/cucumber.rake CHANGED
@@ -1,5 +1,5 @@
1
1
  begin
2
- gem 'cucumber', '~> 0.1.8'
2
+ gem 'cucumber'
3
3
  require 'cucumber/rake/task'
4
4
  rescue Exception
5
5
  nil
@@ -12,3 +12,4 @@ if defined?(Cucumber)
12
12
  else
13
13
  warn "Cucumber gem is required, please install it. (gem install cucumber)"
14
14
  end
15
+
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.3.0"
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 ADDED
@@ -0,0 +1,82 @@
1
+ begin
2
+ gem 'rubyforge', '~> 1.0.1'
3
+ require 'rubyforge'
4
+ rescue Exception
5
+ nil
6
+ end
7
+
8
+ CLEAN.include('email.txt')
9
+
10
+ if defined?(RubyForge) then
11
+ if defined?(GEM_SPEC) then
12
+ desc 'Create news email file and post to RubyForge.'
13
+ task :announce do |t|
14
+ ver = ENV['VERSION'] or fail "Must supply VERSION (rake announce VERSION=x.y.z)."
15
+
16
+ # compare versions to avoid mistakes
17
+ unless ver == GEM_SPEC.version.to_s then
18
+ fail "Version mismatch (supplied and specification versions differ)."
19
+ end
20
+
21
+ # no homepage? why announce it then?!
22
+ if GEM_SPEC.homepage == 'TODO' or GEM_SPEC.homepage.nil? then
23
+ fail "Must define homepage in your gem specification."
24
+ end
25
+
26
+ # no rubyforge project? no release for you!
27
+ if GEM_SPEC.rubyforge_project == 'TODO' or GEM_SPEC.rubyforge_project.nil? then
28
+ fail "Must define rubyforge_project in your gem specification."
29
+ end
30
+
31
+ # instantiate a RubyForge object
32
+ rf = RubyForge.new.configure
33
+
34
+ # read project info and overview
35
+ notes = begin
36
+ r = File.read("README.rdoc")
37
+ r.split(/^(=+ .*)/)[1..4].join.strip
38
+ rescue
39
+ warn "Missing README.rdoc"
40
+ ''
41
+ end
42
+
43
+ # read changes
44
+ changes = begin
45
+ h = File.read("History.txt")
46
+ h.split(/^(===+ .*)/)[1..2].join.strip
47
+ rescue
48
+ warn "Missing History.txt"
49
+ ''
50
+ end
51
+
52
+ # standard fields
53
+ subject = "#{GEM_SPEC.name} #{GEM_SPEC.version} Released"
54
+ title = "#{GEM_SPEC.name} version #{GEM_SPEC.version} has been released!"
55
+ body = "#{notes}\n\nChanges:\n\n#{changes}"
56
+ urls = [GEM_SPEC.homepage, "http://rubyforge.org/projects/#{GEM_SPEC.rubyforge_project}"].map { |u| "* <#{u.strip}>" }.join("\n")
57
+
58
+ puts "Logging in RubyForge..."
59
+ rf.login
60
+
61
+ puts "Generating email.txt..."
62
+ File.open("email.txt", "w") do |mail|
63
+ mail.puts "Subject: [ANN] #{subject}"
64
+ mail.puts
65
+ mail.puts title
66
+ mail.puts
67
+ mail.puts urls
68
+ mail.puts
69
+ mail.puts body
70
+ end
71
+ puts "Created email.txt"
72
+
73
+ puts "Posting news for #{GEM_SPEC.name} version #{GEM_SPEC.version}..."
74
+ rf.post_news GEM_SPEC.rubyforge_project, subject, "#{title}\n\n#{body}"
75
+ puts "Done."
76
+ end
77
+ else
78
+ warn "no GEM_SPEC is found or defined. 'announce' task cannot work without it."
79
+ end
80
+ else
81
+ warn "rubyforge gem is required to generate announces, please install it (gem install rubyforge)."
82
+ end
data/tasks/rdoc.rake CHANGED
@@ -1,9 +1,15 @@
1
- require 'rake/rdoctask'
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
2
6
 
3
- Rake::RDocTask.new(:rdoc) do |rd|
4
- rd.title = 'rake-compiler -- Documentation'
5
- rd.main = 'README.rdoc'
6
- rd.rdoc_dir = 'doc/api'
7
- rd.options << '--main' << 'README.rdoc' << '--title' << 'rake-compiler -- Documentation'
8
- rd.rdoc_files.include %w(README.rdoc LICENSE.txt History.txt lib/**/*.rb)
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
9
15
  end
@@ -0,0 +1,44 @@
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?(DOC) && defined?(GEM_SPEC) then
10
+ desc "Publish RDoc to RubyForge"
11
+ task :publish => [:clobber_rdoc, :rdoc] do
12
+ config_file = File.expand_path('~/.rubyforge/user-config.yml')
13
+ fail "You need rubyforge properly configured." unless File.exist?(config_file)
14
+
15
+ # no rubyforge project? no release for you!
16
+ if GEM_SPEC.rubyforge_project == 'TODO' or GEM_SPEC.rubyforge_project.nil? then
17
+ fail "Must define rubyforge_project in your gem specification."
18
+ end
19
+
20
+ # use YAML to load configuration file
21
+ config = YAML.load_file(config_file)
22
+
23
+ host = "#{config['username']}@rubyforge.org"
24
+ remote_dir = "/var/www/gforge-projects/#{GEM_SPEC.rubyforge_project}/"
25
+ local_dir = DOC.rdoc_dir
26
+
27
+ # use PuTTY pscp or scp on other platforms
28
+ ssh_exe = RUBY_PLATFORM =~ /mswin|mingw/ ? 'pscp' : 'scp'
29
+
30
+ # construct the command
31
+ cmd = [ssh_exe]
32
+ cmd << '-r' << '-q' # recursive and quiet options
33
+ cmd << "#{local_dir}/*"
34
+ cmd << "#{host}:#{remote_dir}"
35
+
36
+ puts "Publishing RDocs to RubyForge..."
37
+ sh cmd.join(' ')
38
+ end
39
+ else
40
+ warn "You need a GEM_SPEC and DOC rdoc definitions present. task publish not defined."
41
+ end
42
+ else
43
+ warn "rubyforge gem is required to generate releases, please install it (gem install rubyforge)."
44
+ end
data/tasks/release.rake CHANGED
@@ -7,6 +7,7 @@ end
7
7
 
8
8
  if defined?(RubyForge) then
9
9
  if defined?(GEM_SPEC) then
10
+ desc 'Package and upload to RubyForge'
10
11
  task :release => [:clobber, :package] do |t|
11
12
  ver = ENV['VERSION'] or fail "Must supply VERSION (rake release VERSION=x.y.z)."
12
13
 
@@ -35,7 +36,7 @@ if defined?(RubyForge) then
35
36
  # read changes
36
37
  changes = begin
37
38
  h = File.read("History.txt")
38
- h.split(/^(==.*)/)[1..2].join.strip
39
+ h.split(/^(===+ .*)/)[1..2].join.strip
39
40
  rescue
40
41
  warn "Missing History.txt"
41
42
  ''
@@ -50,12 +51,6 @@ if defined?(RubyForge) then
50
51
  # prepare configuration
51
52
  rf.configure config
52
53
 
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
54
  files = FileList["pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version}*.*"].to_a
60
55
  fail "No files found for the release." if files.empty?
61
56
 
data/tasks/rspec.rake CHANGED
@@ -1,10 +1,14 @@
1
1
  begin
2
- gem 'rspec', '~> 1.1.9'
3
- gem 'rcov', '~> 0.8.1'
4
2
  require 'spec/rake/spectask'
5
- require 'rcov'
6
- rescue Exception
7
- nil
3
+
4
+ begin
5
+ require 'rcov'
6
+ rescue LoadError
7
+ warn "RCov gem is required, please install it (gem install rcov)."
8
+ end
9
+
10
+ rescue LoadError
11
+ warn "RSpec gem is required, please install it (gem install rspec)."
8
12
  end
9
13
 
10
14
  if defined?(Spec)
@@ -25,9 +29,6 @@ if defined?(Spec)
25
29
  t.rcov_opts = ["--exclude", "spec/*,features/*,gems/*"]
26
30
  end
27
31
  end
28
- else
29
- warn "RCov gem is required, please install it (gem install rcov)."
30
32
  end
31
- else
32
- warn "RSpec gem is required, please install it (gem install rspec)."
33
33
  end
34
+
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.3.0
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: 2008-12-07 00:00:00 -05: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,17 +49,21 @@ 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
55
+ - lib/rake/extensioncompiler.rb
52
56
  - lib/rake/extensiontask.rb
53
57
  - spec/lib/rake/extensiontask_spec.rb
54
58
  - spec/spec_helper.rb
59
+ - spec/support/capture_output_helper.rb
55
60
  - tasks/bin/cross-ruby.rake
56
61
  - tasks/common.rake
57
62
  - tasks/cucumber.rake
58
63
  - tasks/gem.rake
64
+ - tasks/news.rake
59
65
  - tasks/rdoc.rake
66
+ - tasks/rdoc_publish.rake
60
67
  - tasks/release.rake
61
68
  - tasks/rspec.rake
62
69
  - Rakefile
@@ -66,6 +73,8 @@ files:
66
73
  - cucumber.yml
67
74
  has_rdoc: true
68
75
  homepage: http://github.com/luislavena/rake-compiler
76
+ licenses:
77
+ - MIT
69
78
  post_install_message:
70
79
  rdoc_options:
71
80
  - --main
@@ -89,9 +98,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
98
  requirements: []
90
99
 
91
100
  rubyforge_project: rake-compiler
92
- rubygems_version: 1.3.0
101
+ rubygems_version: 1.3.2
93
102
  signing_key:
94
- specification_version: 2
103
+ specification_version: 3
95
104
  summary: Rake-based Ruby C Extension task generator.
96
105
  test_files: []
97
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