@@ -17,49 +17,61 @@ def linklist(crossruby)
17
17
File . join ( product_build_dir ( crossruby ) , "link.filelist" )
18
18
end
19
19
20
- def define_task ( crossruby )
21
- task "#{ crossruby . name } -ext-#{ @name } " => [ crossruby . configure ] do
22
- make_args = [ ]
23
- make_args << "CC=#{ @toolchain . cc } "
24
- make_args << "LD=#{ @toolchain . ld } "
25
- make_args << "AR=#{ @toolchain . ar } "
26
- make_args << "RANLIB=#{ @toolchain . ranlib } "
20
+ def make_args ( crossruby )
21
+ make_args = [ ]
22
+ make_args << "CC=#{ @toolchain . cc } "
23
+ make_args << "LD=#{ @toolchain . ld } "
24
+ make_args << "AR=#{ @toolchain . ar } "
25
+ make_args << "RANLIB=#{ @toolchain . ranlib } "
27
26
28
- make_args << "DESTDIR=#{ crossruby . dest_dir } "
27
+ make_args << "DESTDIR=#{ crossruby . dest_dir } "
28
+ make_args
29
+ end
29
30
31
+ def define_task ( crossruby )
32
+ task "#{ crossruby . name } -ext-#{ @name } " => [ crossruby . configure ] do
30
33
lib = @name
31
- source = crossruby . source
32
34
objdir = product_build_dir crossruby
33
35
FileUtils . mkdir_p objdir
34
- extconf_args = [
35
- "--disable=gems" ,
36
- # HACK: top_srcdir is required to find ruby headers
37
- "-e" ,
38
- %Q('$top_srcdir="#{ source . src_dir } "') ,
39
- # HACK: extout is required to find config.h
40
- "-e" ,
41
- %Q('$extout="#{ crossruby . build_dir } /.ext"') ,
42
- # HACK: force static ext build by imitating extmk
43
- "-e" ,
44
- "'$static = true; trace_var(:$static) {|v| $static = true }'" ,
45
- # HACK: $0 should be extconf.rb path due to mkmf source file detection
46
- # and we want to insert some hacks before it. But -e and $0 cannot be
47
- # used together, so we rewrite $0 in -e.
48
- "-e" ,
49
- %Q('$0="#{ @srcdir } /extconf.rb"') ,
50
- "-e" ,
51
- %Q('require_relative "#{ @srcdir } /extconf.rb"') ,
52
- "-I#{ crossruby . build_dir } "
53
- ]
54
- sh "#{ crossruby . baseruby_path } #{ extconf_args . join ( " " ) } " , chdir : objdir
55
- make_cmd = %Q(make -C "#{ objdir } " #{ make_args . join ( " " ) } static)
56
- sh make_cmd
36
+ do_extconf crossruby
37
+ sh %Q(make -C "#{ objdir } " #{ make_args ( crossruby ) . join ( " " ) } #{ lib } .a)
57
38
# A ext can provide link args by link.filelist. It contains only built archive file by default.
58
39
unless File . exist? ( linklist ( crossruby ) )
59
40
File . write ( linklist ( crossruby ) , Dir . glob ( "#{ objdir } /*.a" ) . join ( "\n " ) )
60
41
end
61
42
end
62
43
end
44
+
45
+ def do_extconf ( crossruby )
46
+ objdir = product_build_dir crossruby
47
+ source = crossruby . source
48
+ extconf_args = [
49
+ "--disable=gems" ,
50
+ # HACK: top_srcdir is required to find ruby headers
51
+ "-e" ,
52
+ %Q('$top_srcdir="#{ source . src_dir } "') ,
53
+ # HACK: extout is required to find config.h
54
+ "-e" ,
55
+ %Q('$extout="#{ crossruby . build_dir } /.ext"') ,
56
+ # HACK: force static ext build by imitating extmk
57
+ "-e" ,
58
+ "'$static = true; trace_var(:$static) {|v| $static = true }'" ,
59
+ # HACK: $0 should be extconf.rb path due to mkmf source file detection
60
+ # and we want to insert some hacks before it. But -e and $0 cannot be
61
+ # used together, so we rewrite $0 in -e.
62
+ "-e" ,
63
+ %Q('$0="#{ @srcdir } /extconf.rb"') ,
64
+ "-e" ,
65
+ %Q('require_relative "#{ @srcdir } /extconf.rb"') ,
66
+ "-I#{ crossruby . build_dir } "
67
+ ]
68
+ sh "#{ crossruby . baseruby_path } #{ extconf_args . join ( " " ) } " , chdir : objdir
69
+ end
70
+
71
+ def do_install_rb ( crossruby )
72
+ objdir = product_build_dir crossruby
73
+ sh %Q(make -C "#{ objdir } " #{ make_args ( crossruby ) . join ( " " ) } install-rb)
74
+ end
63
75
end
64
76
65
77
class CrossRubyProduct < BuildProduct
@@ -125,8 +137,7 @@ def define_task
125
137
next if File . exist? ( artifact )
126
138
rm_rf dest_dir
127
139
cp_r "#{ dest_dir } -install" , dest_dir
128
- ruby_api_version =
129
- `#{ baseruby_path } -e 'print RbConfig::CONFIG["ruby_version"]'`
140
+ @user_exts . each { |ext | ext . do_install_rb ( self ) }
130
141
sh "tar cfz #{ artifact } -C rubies #{ name } "
131
142
end
132
143
end
0 commit comments