@@ -32,7 +32,11 @@ def build(executor, crossruby)
32
32
objdir = product_build_dir crossruby
33
33
executor . mkdir_p objdir
34
34
do_extconf executor , crossruby
35
- executor . system %Q(make -C "#{ objdir } " #{ make_args ( crossruby ) . join ( " " ) } #{ lib } .a)
35
+ executor . system "make" ,
36
+ "-C" ,
37
+ "#{ objdir } " ,
38
+ *make_args ( crossruby ) ,
39
+ "#{ lib } .a"
36
40
# A ext can provide link args by link.filelist. It contains only built archive file by default.
37
41
unless File . exist? ( linklist ( crossruby ) )
38
42
executor . write (
@@ -49,31 +53,34 @@ def do_extconf(executor, crossruby)
49
53
"--disable=gems" ,
50
54
# HACK: top_srcdir is required to find ruby headers
51
55
"-e" ,
52
- %Q(' $top_srcdir="#{ source . src_dir } "' ) ,
56
+ %Q($top_srcdir="#{ source . src_dir } ") ,
53
57
# HACK: extout is required to find config.h
54
58
"-e" ,
55
- %Q(' $extout="#{ crossruby . build_dir } /.ext"' ) ,
59
+ %Q($extout="#{ crossruby . build_dir } /.ext") ,
56
60
# HACK: force static ext build by imitating extmk
57
61
"-e" ,
58
- "' $static = true; trace_var(:$static) {|v| $static = true }' " ,
62
+ "$static = true; trace_var(:$static) {|v| $static = true }" ,
59
63
# HACK: $0 should be extconf.rb path due to mkmf source file detection
60
64
# and we want to insert some hacks before it. But -e and $0 cannot be
61
65
# used together, so we rewrite $0 in -e.
62
66
"-e" ,
63
- %Q(' $0="#{ @srcdir } /extconf.rb"' ) ,
67
+ %Q($0="#{ @srcdir } /extconf.rb") ,
64
68
"-e" ,
65
- %Q(' require_relative "#{ @srcdir } /extconf.rb"' ) ,
69
+ %Q(require_relative "#{ @srcdir } /extconf.rb") ,
66
70
"-I#{ crossruby . build_dir } "
67
71
]
68
72
# Clear RUBYOPT to avoid loading unrelated bundle setup
69
- executor . system ( { "RUBYOPT" => "" } ) ,
70
- "#{ crossruby . baseruby_path } #{ extconf_args . join ( " " ) } " ,
71
- chdir : objdir
73
+ executor . system crossruby . baseruby_path ,
74
+ *extconf_args ,
75
+ chdir : objdir ,
76
+ env : {
77
+ "RUBYOPT" => ""
78
+ }
72
79
end
73
80
74
81
def do_install_rb ( executor , crossruby )
75
82
objdir = product_build_dir crossruby
76
- executor . system %Q( make -C " #{ objdir } " #{ make_args ( crossruby ) . join ( " " ) } install-rb)
83
+ executor . system " make" , "-C" , objdir , * make_args ( crossruby ) , " install-rb"
77
84
end
78
85
79
86
def cache_key ( digest )
@@ -129,38 +136,58 @@ def initialize(
129
136
def configure ( executor , reconfigure : false )
130
137
if !File . exist? ( "#{ build_dir } /Makefile" ) || reconfigure
131
138
args = configure_args ( RbConfig ::CONFIG [ "host" ] , toolchain )
132
- executor . system "#{ source . configure_file } #{ args . join ( " " ) } " ,
133
- chdir : build_dir
139
+ executor . system source . configure_file , *args , chdir : build_dir
134
140
end
135
141
# NOTE: we need rbconfig.rb at configuration time to build user given extensions with mkmf
136
- executor . system "make rbconfig.rb" , chdir : build_dir
142
+ executor . system "make" , " rbconfig.rb", chdir : build_dir
137
143
end
138
144
139
145
def build_exts ( executor )
140
- @user_exts . each { |prod | prod . build ( executor , self ) }
141
- executor . mkdir_p File . dirname ( extinit_obj )
142
- executor . system %Q(ruby #{ extinit_c_erb } #{ @user_exts . map ( &:name ) . join ( " " ) } | #{ toolchain . cc } -c -x c - -o #{ extinit_obj } )
146
+ @user_exts . each do |prod |
147
+ executor . begin_section prod . class , prod . name , "Building"
148
+ prod . build ( executor , self )
149
+ executor . end_section prod . class , prod . name
150
+ end
143
151
end
144
152
145
153
def build ( executor , remake : false , reconfigure : false )
146
154
executor . mkdir_p dest_dir
147
155
executor . mkdir_p build_dir
148
156
@toolchain . install
149
157
[ @source , @baseruby , @libyaml , @zlib , @openssl , @wasi_vfs ] . each do |prod |
158
+ executor . begin_section prod . class , prod . name , "Building"
150
159
prod . build ( executor )
160
+ executor . end_section prod . class , prod . name
151
161
end
162
+ executor . begin_section self . class , name , "Configuring"
152
163
configure ( executor , reconfigure : reconfigure )
164
+ executor . end_section self . class , name
165
+
153
166
build_exts ( executor )
154
167
168
+ executor . begin_section self . class , name , "Building"
169
+ executor . mkdir_p File . dirname ( extinit_obj )
170
+ executor . system "ruby" ,
171
+ extinit_c_erb ,
172
+ *@user_exts . map ( &:name ) ,
173
+ "--cc" ,
174
+ toolchain . cc ,
175
+ "--output" ,
176
+ extinit_obj
155
177
install_dir = File . join ( build_dir , "install" )
156
178
if !File . exist? ( install_dir ) || remake || reconfigure
157
- executor . system "make install DESTDIR=#{ install_dir } " , chdir : build_dir
179
+ executor . system "make" ,
180
+ "install" ,
181
+ "DESTDIR=#{ install_dir } " ,
182
+ chdir : build_dir
158
183
end
159
184
160
185
executor . rm_rf dest_dir
161
186
executor . cp_r install_dir , dest_dir
162
187
@user_exts . each { |ext | ext . do_install_rb ( executor , self ) }
163
- executor . system "tar cfz #{ artifact } -C rubies #{ name } "
188
+ executor . system "tar" , "cfz" , artifact , "-C" , "rubies" , name
189
+
190
+ executor . end_section self . class , name
164
191
end
165
192
166
193
def clean ( executor )
@@ -241,11 +268,11 @@ def configure_args(build_triple, toolchain)
241
268
242
269
args = self . system_triplet_args + [ "--build" , build_triple ]
243
270
args << "--with-static-linked-ext"
244
- args << %Q(--with-ext=" #{ default_exts } " )
245
- args << %Q(--with-libyaml-dir=" #{ @libyaml . install_root } " )
246
- args << %Q(--with-zlib-dir=" #{ @zlib . install_root } " )
247
- args << %Q(--with-openssl-dir=" #{ @openssl . install_root } " ) if @openssl
248
- args << %Q(--with-baseruby=" #{ baseruby_path } " )
271
+ args << %Q(--with-ext=#{ default_exts } )
272
+ args << %Q(--with-libyaml-dir=#{ @libyaml . install_root } )
273
+ args << %Q(--with-zlib-dir=#{ @zlib . install_root } )
274
+ args << %Q(--with-openssl-dir=#{ @openssl . install_root } ) if @openssl
275
+ args << %Q(--with-baseruby=#{ baseruby_path } )
249
276
250
277
case target
251
278
when "wasm32-unknown-wasi"
@@ -270,13 +297,13 @@ def configure_args(build_triple, toolchain)
270
297
xcflags << "-DWASM_FIBER_STACK_BUFFER_SIZE=24576"
271
298
xcflags << "-DWASM_SCAN_STACK_BUFFER_SIZE=24576"
272
299
273
- args << %Q(LDFLAGS=" #{ ldflags . join ( " " ) } " )
274
- args << %Q(XLDFLAGS=" #{ xldflags . join ( " " ) } " )
275
- args << %Q(XCFLAGS=" #{ xcflags . join ( " " ) } " )
276
- args << %Q(debugflags=" #{ @debugflags . join ( " " ) } " )
277
- args << %Q(cppflags=" #{ @cppflags . join ( " " ) } " )
300
+ args << %Q(LDFLAGS=#{ ldflags . join ( " " ) } )
301
+ args << %Q(XLDFLAGS=#{ xldflags . join ( " " ) } )
302
+ args << %Q(XCFLAGS=#{ xcflags . join ( " " ) } )
303
+ args << %Q(debugflags=#{ @debugflags . join ( " " ) } )
304
+ args << %Q(cppflags=#{ @cppflags . join ( " " ) } )
278
305
unless wasmoptflags . empty?
279
- args << %Q(wasmoptflags=" #{ @wasmoptflags . join ( " " ) } " )
306
+ args << %Q(wasmoptflags=#{ @wasmoptflags . join ( " " ) } )
280
307
end
281
308
args << "--disable-install-doc"
282
309
args
0 commit comments