Skip to content

Commit

Permalink
Add support for Ruby 2.7
Browse files Browse the repository at this point in the history
GitHub: fix #161

Reported by Masaki Hara. Thanks!!!
  • Loading branch information
kou committed Dec 10, 2019
1 parent f808dd7 commit 6822686
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions tasks/bin/cross-ruby.rake
Expand Up @@ -58,13 +58,16 @@ MINGW_TARGET = MINGW_HOST.gsub('msvc', '')
ENV.delete(var)
end

source_dir = "#{USER_HOME}/sources/#{RUBY_CC_VERSION}"
build_dir = "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}"

# define a location where sources will be stored
directory "#{USER_HOME}/sources/#{RUBY_CC_VERSION}"
directory "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}"
directory source_dir
directory build_dir

# clean intermediate files and folders
CLEAN.include("#{USER_HOME}/sources/#{RUBY_CC_VERSION}")
CLEAN.include("#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}")
CLEAN.include(source_dir)
CLEAN.include(build_dir)

# remove the final products and sources
CLOBBER.include("#{USER_HOME}/sources")
Expand All @@ -87,20 +90,26 @@ end

# Extract the sources
source_file = RUBY_SOURCE ? RUBY_SOURCE.split('/').last : "#{RUBY_CC_VERSION}.tar.bz2"
file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}" => ["#{USER_HOME}/sources/#{source_file}"] do |t|
file source_dir => ["#{USER_HOME}/sources/#{source_file}"] do |t|
chdir File.dirname(t.name) do
t.prerequisites.each { |f| sh "tar xf #{File.basename(f)}" }
end
end

# backup makefile.in
file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in.bak" => ["#{USER_HOME}/sources/#{RUBY_CC_VERSION}"] do |t|
cp "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in", t.name
if RUBY_CC_VERSION >= "ruby-2.7.0"

This comment has been minimized.

Copy link
@methodmissing

methodmissing Dec 26, 2019

@kou just wondering if this could perhaps check on 2.7.0 as well? Documentation prefers the numeric only version as per https://github.com/rake-compiler/rake-compiler#but-wait-theres-more and noticed in our build pipeline a failure pointing towards this and it's kinda drifting off convention for RUBY_CC_VERSION

However ruby-2.7.0 may still need to be maintained here as a check for backwards compatibility since the latest release. Thoughts?

This comment has been minimized.

Copy link
@kou

kou Dec 27, 2019

Author Member

This is not used for rake cross compile. This is used for rake-compiler cross-ruby. https://github.com/rake-compiler/rake-compiler#ive-got-my-tool-chain-installed-now-what

Anyway, we don't have this code on master. :-)
d76da27#diff-ed359e58e2bdd92d722d40b16c3f24ef

makefile_in = "#{source_dir}/template/Makefile.in"
else
makefile_in = "#{source_dir}/Makefile.in"
end
makefile_in_bak = "#{makefile_in}.bak"
file makefile_in_bak => [source_dir] do |t|
cp makefile_in, makefile_in_bak
end

# correct the makefiles
file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in" => ["#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in.bak"] do |t|
content = File.open(t.name, 'rb') { |f| f.read }
file makefile_in => [makefile_in_bak] do |t|
content = File.open(makefile_in_bak, 'rb') { |f| f.read }

out = ""

Expand All @@ -113,7 +122,7 @@ file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in" => ["#{USER_HOME}/sou
end

when_writing("Patching Makefile.in") {
File.open(t.name, 'wb') { |f| f.write(out) }
File.open(makefile_in, 'wb') { |f| f.write(out) }
}
end

Expand All @@ -126,8 +135,7 @@ task :mingw32 do
end

# generate the makefile in a clean build location
file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}",
"#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in"] do |t|
file "#{build_dir}/Makefile" => [build_dir, makefile_in] do |t|

options = [
"--host=#{MINGW_HOST}",
Expand All @@ -149,14 +157,14 @@ file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile" => ["#{USER
end

# make
file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/ruby.exe" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile"] do |t|
file "#{build_dir}/ruby.exe" => ["#{build_dir}/Makefile"] do |t|
chdir File.dirname(t.prerequisites.first) do
sh MAKE
end
end

# make install
file "#{USER_HOME}/ruby/#{MINGW_HOST}/#{RUBY_CC_VERSION}/bin/ruby.exe" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/ruby.exe"] do |t|
file "#{USER_HOME}/ruby/#{MINGW_HOST}/#{RUBY_CC_VERSION}/bin/ruby.exe" => ["#{build_dir}/ruby.exe"] do |t|
chdir File.dirname(t.prerequisites.first) do
sh "#{MAKE} install"
end
Expand Down Expand Up @@ -210,4 +218,3 @@ end

desc "Build #{RUBY_CC_VERSION} suitable for cross-platform development."
task 'cross-ruby' => [:mingw32, :install, 'update-config']

0 comments on commit 6822686

Please sign in to comment.