luislavena-rake-compiler 0.1.1
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/LICENSE.txt +20 -0
- data/README.rdoc +191 -0
- data/Rakefile +23 -0
- data/bin/rake-compiler +24 -0
- data/cucumber.yml +1 -0
- data/features/compile.feature +71 -0
- data/features/package.feature +40 -0
- data/features/step_definitions/compilation.rb +27 -0
- data/features/step_definitions/execution.rb +30 -0
- data/features/step_definitions/folders.rb +32 -0
- data/features/step_definitions/gem.rb +25 -0
- data/features/support/env.rb +7 -0
- data/features/support/file_templates.rb +75 -0
- data/features/support/generators.rb +58 -0
- data/lib/rake/extensiontask.rb +182 -0
- data/spec/lib/rake/extensiontask_spec.rb +245 -0
- data/spec/spec_helper.rb +9 -0
- data/tasks/bin/cross-ruby.rake +158 -0
- data/tasks/common.rake +7 -0
- data/tasks/cucumber.rake +14 -0
- data/tasks/rdoc.rake +9 -0
- data/tasks/rspec.rake +33 -0
- data/tasks/rubygems.rake +59 -0
- metadata +91 -0
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Cross-compile ruby, using Rake
|
|
3
|
+
#
|
|
4
|
+
# This source code is released under the MIT License.
|
|
5
|
+
# See LICENSE file for details
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
#
|
|
9
|
+
# This code is inspired and based on notes from the following sites:
|
|
10
|
+
#
|
|
11
|
+
# http://tenderlovemaking.com/2008/11/21/cross-compiling-ruby-gems-for-win32/
|
|
12
|
+
# http://github.com/jbarnette/johnson/tree/master/cross-compile.txt
|
|
13
|
+
# http://eigenclass.org/hiki/cross+compiling+rcovrt
|
|
14
|
+
#
|
|
15
|
+
# This recipe only cleanup the dependency chain and automate it.
|
|
16
|
+
# Also opens the door to usage different ruby versions
|
|
17
|
+
# for cross-compilation.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
require 'rake'
|
|
21
|
+
require 'rake/clean'
|
|
22
|
+
require 'yaml'
|
|
23
|
+
|
|
24
|
+
USER_HOME = File.expand_path("~/.rake-compiler")
|
|
25
|
+
RUBY_CC_VERSION = "ruby-#{ENV['VERSION'] || '1.8.6-p287'}"
|
|
26
|
+
|
|
27
|
+
# grab the major "1.8" or "1.9" part of the version number
|
|
28
|
+
MAJOR = RUBY_CC_VERSION.match(/.*-(\d.\d).\d/)[1]
|
|
29
|
+
|
|
30
|
+
# define a location where sources will be stored
|
|
31
|
+
directory "#{USER_HOME}/sources/#{RUBY_CC_VERSION}"
|
|
32
|
+
directory "#{USER_HOME}/builds/#{RUBY_CC_VERSION}"
|
|
33
|
+
|
|
34
|
+
# clean intermediate files and folders
|
|
35
|
+
CLEAN.include("#{USER_HOME}/sources/#{RUBY_CC_VERSION}")
|
|
36
|
+
CLEAN.include("#{USER_HOME}/builds/#{RUBY_CC_VERSION}")
|
|
37
|
+
|
|
38
|
+
# remove the final products and sources
|
|
39
|
+
CLOBBER.include("#{USER_HOME}/sources")
|
|
40
|
+
CLOBBER.include("#{USER_HOME}/builds")
|
|
41
|
+
CLOBBER.include("#{USER_HOME}/ruby/#{RUBY_CC_VERSION}")
|
|
42
|
+
CLOBBER.include("#{USER_HOME}/config.yml")
|
|
43
|
+
|
|
44
|
+
# ruby source file should be stored there
|
|
45
|
+
file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}.tar.gz" => ["#{USER_HOME}/sources"] do |t|
|
|
46
|
+
# download the source file using wget or curl
|
|
47
|
+
chdir File.dirname(t.name) do
|
|
48
|
+
url = "ftp://ftp.ruby-lang.org/pub/ruby/#{MAJOR}/#{File.basename(t.name)}"
|
|
49
|
+
sh "wget #{url} || curl -O #{url}"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Extract the sources
|
|
54
|
+
file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}" => ["#{USER_HOME}/sources/#{RUBY_CC_VERSION}.tar.gz"] do |t|
|
|
55
|
+
chdir File.dirname(t.name) do
|
|
56
|
+
t.prerequisites.each { |f| sh "tar xfz #{File.basename(f)}" }
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# backup makefile.in
|
|
61
|
+
file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in.bak" => ["#{USER_HOME}/sources/#{RUBY_CC_VERSION}"] do |t|
|
|
62
|
+
cp "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in", t.name
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# correct the makefiles
|
|
66
|
+
file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in" => ["#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in.bak"] do |t|
|
|
67
|
+
content = File.open(t.name, 'rb') { |f| f.read }
|
|
68
|
+
|
|
69
|
+
out = ""
|
|
70
|
+
|
|
71
|
+
content.each_line do |line|
|
|
72
|
+
if line =~ /^\s*ALT_SEPARATOR =/
|
|
73
|
+
out << "\t\t ALT_SEPARATOR = \"\\\\\\\\\"; \\\n"
|
|
74
|
+
else
|
|
75
|
+
out << line
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
when_writing("Patching Makefile.in") {
|
|
80
|
+
File.open(t.name, 'wb') { |f| f.write(out) }
|
|
81
|
+
}
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
task :mingw32 do
|
|
85
|
+
unless File.exist?('/usr/bin/i586-mingw32msvc-gcc') then
|
|
86
|
+
warn "You need to install mingw32 cross compile functionality to be able to continue."
|
|
87
|
+
warn "Please refer to your distro documentation about installation."
|
|
88
|
+
fail
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
task :environment do
|
|
93
|
+
ENV['ac_cv_func_getpgrp_void'] = 'no'
|
|
94
|
+
ENV['ac_cv_func_setpgrp_void'] = 'yes'
|
|
95
|
+
ENV['rb_cv_negative_time_t'] = 'no'
|
|
96
|
+
ENV['ac_cv_func_memcmp_working'] = 'yes'
|
|
97
|
+
ENV['rb_cv_binary_elf' ] = 'no'
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# generate the makefile in a clean build location
|
|
101
|
+
file "#{USER_HOME}/builds/#{RUBY_CC_VERSION}/Makefile" => ["#{USER_HOME}/builds/#{RUBY_CC_VERSION}",
|
|
102
|
+
"#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in"] do |t|
|
|
103
|
+
|
|
104
|
+
# set the configure options
|
|
105
|
+
options = [
|
|
106
|
+
'--host=i586-mingw32msvc',
|
|
107
|
+
'--target=i386-mingw32',
|
|
108
|
+
'--build=i686-linux',
|
|
109
|
+
'--enable-shared'
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
chdir File.dirname(t.name) do
|
|
113
|
+
prefix = File.expand_path("../../ruby/#{RUBY_CC_VERSION}")
|
|
114
|
+
options << "--prefix=#{prefix}"
|
|
115
|
+
sh File.expand_path("../../sources/#{RUBY_CC_VERSION}/configure"), *options
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# make
|
|
120
|
+
file "#{USER_HOME}/builds/#{RUBY_CC_VERSION}/ruby.exe" => ["#{USER_HOME}/builds/#{RUBY_CC_VERSION}/Makefile"] do |t|
|
|
121
|
+
chdir File.dirname(t.prerequisites.first) do
|
|
122
|
+
sh "make"
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# make install
|
|
127
|
+
file "#{USER_HOME}/ruby/#{RUBY_CC_VERSION}/bin/ruby.exe" => ["#{USER_HOME}/builds/#{RUBY_CC_VERSION}/ruby.exe"] do |t|
|
|
128
|
+
chdir File.dirname(t.prerequisites.first) do
|
|
129
|
+
sh "make install"
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
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 "#{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
|
|
138
|
+
puts "Updating #{t.name}"
|
|
139
|
+
config = YAML.load_file(t.name)
|
|
140
|
+
else
|
|
141
|
+
puts "Generating #{t.name}"
|
|
142
|
+
config = {}
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
config["rbconfig-#{MAJOR}"] = File.expand_path(t.prerequisites.first)
|
|
146
|
+
|
|
147
|
+
when_writing("Saving changes into #{t.name}") {
|
|
148
|
+
File.open(t.name, 'w') do |f|
|
|
149
|
+
f.puts config.to_yaml
|
|
150
|
+
end
|
|
151
|
+
}
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
task :default do
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
desc "Build #{RUBY_CC_VERSION} suitable for cross-platform development."
|
|
158
|
+
task 'cross-ruby' => [:mingw32, :environment, "#{USER_HOME}/config.yml"]
|
data/tasks/common.rake
ADDED
data/tasks/cucumber.rake
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
begin
|
|
2
|
+
gem 'cucumber', '~> 0.1.8'
|
|
3
|
+
require 'cucumber/rake/task'
|
|
4
|
+
rescue Exception
|
|
5
|
+
nil
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
if defined?(Cucumber)
|
|
9
|
+
Cucumber::Rake::Task.new do |t|
|
|
10
|
+
t.cucumber_opts = "--format pretty --no-source"
|
|
11
|
+
end
|
|
12
|
+
else
|
|
13
|
+
warn "Cucumber gem is required, please install it. (gem install cucumber)"
|
|
14
|
+
end
|
data/tasks/rdoc.rake
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require 'rake/rdoctask'
|
|
2
|
+
|
|
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 lib/**/*.rb)
|
|
9
|
+
end
|
data/tasks/rspec.rake
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
begin
|
|
2
|
+
gem 'rspec', '~> 1.1.9'
|
|
3
|
+
gem 'rcov', '~> 0.8.1'
|
|
4
|
+
require 'spec/rake/spectask'
|
|
5
|
+
require 'rcov'
|
|
6
|
+
rescue Exception
|
|
7
|
+
nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
if defined?(Spec)
|
|
11
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
|
12
|
+
t.spec_opts = ["--options", "spec/spec.opts"]
|
|
13
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
if defined?(Rcov)
|
|
17
|
+
CLOBBER.include('coverage')
|
|
18
|
+
|
|
19
|
+
namespace :spec do
|
|
20
|
+
desc "Run all specs in spec directory with RCov"
|
|
21
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
|
22
|
+
t.spec_opts = ["--options", "spec/spec.opts"]
|
|
23
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
|
24
|
+
t.rcov = true
|
|
25
|
+
t.rcov_opts = ["--exclude", "spec/*,features/*,gems/*"]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
else
|
|
29
|
+
warn "RCov gem is required, please install it (gem install rcov)."
|
|
30
|
+
end
|
|
31
|
+
else
|
|
32
|
+
warn "RSpec gem is required, please install it (gem install rspec)."
|
|
33
|
+
end
|
data/tasks/rubygems.rake
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require 'rake/gempackagetask'
|
|
2
|
+
|
|
3
|
+
spec = Gem::Specification.new do |s|
|
|
4
|
+
# basic information
|
|
5
|
+
s.name = "rake-compiler"
|
|
6
|
+
s.version = "0.1.1"
|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
|
8
|
+
|
|
9
|
+
# description and details
|
|
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
|
|
15
|
+
|
|
16
|
+
# dependencies
|
|
17
|
+
s.add_dependency 'rake', '>= 0.8.3', '< 0.9'
|
|
18
|
+
|
|
19
|
+
# development dependencies
|
|
20
|
+
#s.add_development_dependency 'rspec', '~> 1.1.9'
|
|
21
|
+
#s.add_development_dependency 'rcov', '~> 0.8.1'
|
|
22
|
+
#s.add_development_dependency 'cucumber', '~> 0.1.8'
|
|
23
|
+
|
|
24
|
+
# components, files and paths
|
|
25
|
+
s.files = FileList["features/**/*.{feature,rb}", "bin/rake-compiler",
|
|
26
|
+
"lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake",
|
|
27
|
+
"Rakefile", "*.{rdoc,txt,yml}"]
|
|
28
|
+
|
|
29
|
+
s.executables = ['rake-compiler']
|
|
30
|
+
|
|
31
|
+
s.require_path = 'lib'
|
|
32
|
+
|
|
33
|
+
# documentation
|
|
34
|
+
s.has_rdoc = true
|
|
35
|
+
s.rdoc_options << '--main' << 'README.rdoc' << '--title' << 'rake-compiler -- Documentation'
|
|
36
|
+
|
|
37
|
+
s.extra_rdoc_files = %w(README.rdoc LICENSE.txt)
|
|
38
|
+
|
|
39
|
+
# project information
|
|
40
|
+
s.homepage = 'http://github.com/luislavena/rake-compiler'
|
|
41
|
+
s.rubyforge_project = 'TODO'
|
|
42
|
+
|
|
43
|
+
# author and contributors
|
|
44
|
+
s.author = 'Luis Lavena'
|
|
45
|
+
s.email = 'luislavena@gmail.com'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
gem_package = Rake::GemPackageTask.new(spec) do |pkg|
|
|
49
|
+
pkg.need_tar = false
|
|
50
|
+
pkg.need_zip = false
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
file 'rake-compiler.gemspec' => ['Rakefile', 'tasks/rubygems.rake'] do |t|
|
|
54
|
+
puts "Generating #{t.name}"
|
|
55
|
+
File.open(t.name, 'w') { |f| f.puts spec.to_yaml }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
desc "Generate or update the standalone gemspec file for the project"
|
|
59
|
+
task :gemspec => ['rake-compiler.gemspec']
|
metadata
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: luislavena-rake-compiler
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Luis Lavena
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2008-11-27 18:00:00 -08:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: rake
|
|
17
|
+
type: :runtime
|
|
18
|
+
version_requirement:
|
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 0.8.3
|
|
24
|
+
- - <
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: "0.9"
|
|
27
|
+
version:
|
|
28
|
+
description: Provide a standard and simplified way to build and package Ruby C extensions using Rake as glue.
|
|
29
|
+
email: luislavena@gmail.com
|
|
30
|
+
executables:
|
|
31
|
+
- rake-compiler
|
|
32
|
+
extensions: []
|
|
33
|
+
|
|
34
|
+
extra_rdoc_files:
|
|
35
|
+
- README.rdoc
|
|
36
|
+
- LICENSE.txt
|
|
37
|
+
files:
|
|
38
|
+
- features/compile.feature
|
|
39
|
+
- features/package.feature
|
|
40
|
+
- features/step_definitions/compilation.rb
|
|
41
|
+
- features/step_definitions/execution.rb
|
|
42
|
+
- features/step_definitions/folders.rb
|
|
43
|
+
- features/step_definitions/gem.rb
|
|
44
|
+
- features/support/env.rb
|
|
45
|
+
- features/support/file_templates.rb
|
|
46
|
+
- features/support/generators.rb
|
|
47
|
+
- bin/rake-compiler
|
|
48
|
+
- lib/rake/extensiontask.rb
|
|
49
|
+
- spec/lib/rake/extensiontask_spec.rb
|
|
50
|
+
- spec/spec_helper.rb
|
|
51
|
+
- tasks/bin/cross-ruby.rake
|
|
52
|
+
- tasks/common.rake
|
|
53
|
+
- tasks/cucumber.rake
|
|
54
|
+
- tasks/rdoc.rake
|
|
55
|
+
- tasks/rspec.rake
|
|
56
|
+
- tasks/rubygems.rake
|
|
57
|
+
- Rakefile
|
|
58
|
+
- README.rdoc
|
|
59
|
+
- LICENSE.txt
|
|
60
|
+
- cucumber.yml
|
|
61
|
+
has_rdoc: true
|
|
62
|
+
homepage: http://github.com/luislavena/rake-compiler
|
|
63
|
+
post_install_message:
|
|
64
|
+
rdoc_options:
|
|
65
|
+
- --main
|
|
66
|
+
- README.rdoc
|
|
67
|
+
- --title
|
|
68
|
+
- rake-compiler -- Documentation
|
|
69
|
+
require_paths:
|
|
70
|
+
- lib
|
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: "0"
|
|
76
|
+
version:
|
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: "0"
|
|
82
|
+
version:
|
|
83
|
+
requirements: []
|
|
84
|
+
|
|
85
|
+
rubyforge_project: TODO
|
|
86
|
+
rubygems_version: 1.2.0
|
|
87
|
+
signing_key:
|
|
88
|
+
specification_version: 2
|
|
89
|
+
summary: Rake-based Ruby C Extension task generator.
|
|
90
|
+
test_files: []
|
|
91
|
+
|