@@ -58,13 +58,16 @@ MINGW_TARGET = MINGW_HOST.gsub('msvc', '')
5858 ENV . delete ( var )
5959end
6060
61+ source_dir = "#{ USER_HOME } /sources/#{ RUBY_CC_VERSION } "
62+ build_dir = "#{ USER_HOME } /builds/#{ MINGW_HOST } /#{ RUBY_CC_VERSION } "
63+
6164# define a location where sources will be stored
62- directory " #{ USER_HOME } /sources/ #{ RUBY_CC_VERSION } "
63- directory " #{ USER_HOME } /builds/ #{ MINGW_HOST } / #{ RUBY_CC_VERSION } "
65+ directory source_dir
66+ directory build_dir
6467
6568# clean intermediate files and folders
66- CLEAN . include ( " #{ USER_HOME } /sources/ #{ RUBY_CC_VERSION } " )
67- CLEAN . include ( " #{ USER_HOME } /builds/ #{ MINGW_HOST } / #{ RUBY_CC_VERSION } " )
69+ CLEAN . include ( source_dir )
70+ CLEAN . include ( build_dir )
6871
6972# remove the final products and sources
7073CLOBBER . include ( "#{ USER_HOME } /sources" )
8790
8891# Extract the sources
8992source_file = RUBY_SOURCE ? RUBY_SOURCE . split ( '/' ) . last : "#{ RUBY_CC_VERSION } .tar.bz2"
90- file " #{ USER_HOME } /sources/ #{ RUBY_CC_VERSION } " => [ "#{ USER_HOME } /sources/#{ source_file } " ] do |t |
93+ file source_dir => [ "#{ USER_HOME } /sources/#{ source_file } " ] do |t |
9194 chdir File . dirname ( t . name ) do
9295 t . prerequisites . each { |f | sh "tar xf #{ File . basename ( f ) } " }
9396 end
9497end
9598
9699# backup makefile.in
97- file "#{ USER_HOME } /sources/#{ RUBY_CC_VERSION } /Makefile.in.bak" => [ "#{ USER_HOME } /sources/#{ RUBY_CC_VERSION } " ] do |t |
98- cp "#{ USER_HOME } /sources/#{ RUBY_CC_VERSION } /Makefile.in" , t . name
100+ if RUBY_CC_VERSION >= "ruby-2.7.0"
101+ makefile_in = "#{ source_dir } /template/Makefile.in"
102+ else
103+ makefile_in = "#{ source_dir } /Makefile.in"
104+ end
105+ makefile_in_bak = "#{ makefile_in } .bak"
106+ file makefile_in_bak => [ source_dir ] do |t |
107+ cp makefile_in , makefile_in_bak
99108end
100109
101110# correct the makefiles
102- file " #{ USER_HOME } /sources/ #{ RUBY_CC_VERSION } /Makefile.in" => [ " #{ USER_HOME } /sources/ #{ RUBY_CC_VERSION } /Makefile.in.bak" ] do |t |
103- content = File . open ( t . name , 'rb' ) { |f | f . read }
111+ file makefile_in => [ makefile_in_bak ] do |t |
112+ content = File . open ( makefile_in_bak , 'rb' ) { |f | f . read }
104113
105114 out = ""
106115
@@ -113,7 +122,7 @@ file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in" => ["#{USER_HOME}/sou
113122 end
114123
115124 when_writing ( "Patching Makefile.in" ) {
116- File . open ( t . name , 'wb' ) { |f | f . write ( out ) }
125+ File . open ( makefile_in , 'wb' ) { |f | f . write ( out ) }
117126 }
118127end
119128
@@ -126,8 +135,7 @@ task :mingw32 do
126135end
127136
128137# generate the makefile in a clean build location
129- file "#{ USER_HOME } /builds/#{ MINGW_HOST } /#{ RUBY_CC_VERSION } /Makefile" => [ "#{ USER_HOME } /builds/#{ MINGW_HOST } /#{ RUBY_CC_VERSION } " ,
130- "#{ USER_HOME } /sources/#{ RUBY_CC_VERSION } /Makefile.in" ] do |t |
138+ file "#{ build_dir } /Makefile" => [ build_dir , makefile_in ] do |t |
131139
132140 options = [
133141 "--host=#{ MINGW_HOST } " ,
@@ -149,14 +157,14 @@ file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile" => ["#{USER
149157end
150158
151159# make
152- file "#{ USER_HOME } /builds/ #{ MINGW_HOST } / #{ RUBY_CC_VERSION } / ruby.exe" => [ "#{ USER_HOME } /builds/ #{ MINGW_HOST } / #{ RUBY_CC_VERSION } /Makefile" ] do |t |
160+ file "#{ build_dir } / ruby.exe" => [ "#{ build_dir } /Makefile" ] do |t |
153161 chdir File . dirname ( t . prerequisites . first ) do
154162 sh MAKE
155163 end
156164end
157165
158166# make install
159- file "#{ USER_HOME } /ruby/#{ MINGW_HOST } /#{ RUBY_CC_VERSION } /bin/ruby.exe" => [ "#{ USER_HOME } /builds/ #{ MINGW_HOST } / #{ RUBY_CC_VERSION } /ruby.exe" ] do |t |
167+ file "#{ USER_HOME } /ruby/#{ MINGW_HOST } /#{ RUBY_CC_VERSION } /bin/ruby.exe" => [ "#{ build_dir } /ruby.exe" ] do |t |
160168 chdir File . dirname ( t . prerequisites . first ) do
161169 sh "#{ MAKE } install"
162170 end
210218
211219desc "Build #{ RUBY_CC_VERSION } suitable for cross-platform development."
212220task 'cross-ruby' => [ :mingw32 , :install , 'update-config' ]
213-
0 commit comments