@@ -63,50 +63,56 @@ def build(executor, crossruby)
6363 end
6464
6565 def do_extconf ( executor , crossruby )
66+ unless crossruby . target . pic?
67+ self . do_legacy_extconf ( executor , crossruby )
68+ return
69+ end
6670 objdir = product_build_dir crossruby
6771 source = crossruby . source
68- extconf_args = [ "-C" , objdir ]
69- # @type var extconf_env: Hash[String, String]
70- extconf_env = { }
71-
72- if crossruby . target . pic?
73- extconf_args . concat [
74- " #{ @srcdir } /extconf.rb" ,
75- ]
76- rbconfig_rb = Dir . glob ( File . join ( crossruby . dest_dir , "usr/local/lib/ruby/*/wasm32-wasi/rbconfig.rb" ) ) . first
77- raise "rbconfig.rb not found" unless rbconfig_rb
78- extconf_args << "--target-rbconfig= #{ rbconfig_rb } "
79- else
80- extconf_args . concat [
81- "--disable=gems" ,
82- # HACK: top_srcdir is required to find ruby headers
83- "-e ",
84- %Q($ top_srcdir=" #{ source . src_dir } ") ,
85- # HACK: extout is required to find config.h
86- "-e" ,
87- %Q($ extout=" #{ crossruby . build_dir } /.ext") ,
88- # HACK: force static ext build by imitating extmk
89- "-e" ,
90- "$static = true; trace_var(:$ static) {|v| $static = true }" ,
91- # HACK: $0 should be extconf.rb path due to mkmf source file detection
92- # and we want to insert some hacks before it. But -e and $0 cannot be
93- # used together, so we rewrite $0 in -e.
94- "-e" ,
95- %Q($0=" #{ @srcdir } /extconf.rb") ,
96- "-e" ,
97- %Q(require_relative "#{ @srcdir } /extconf.rb") ,
98- # HACK: extract "$target" from extconf.rb to get a full target name
99- # like "cgi/escape" instead of "escape"
100- "-e" ,
101- %Q(require "json"; File.write(" #{ metadata_json ( crossruby ) } ", JSON.dump({target: $target}))) ,
102- "-I #{ crossruby . build_dir } "
103- ]
104- # Clear RUBYOPT to avoid loading unrelated bundle setup
105- extconf_env [ "RUBYOPT" ] = ""
106- end
107- executor . system Gem . ruby ,
72+ rbconfig_rb = Dir . glob ( File . join ( crossruby . dest_dir , "usr/local/lib/ruby/*/wasm32-wasi/rbconfig.rb" ) ) . first
73+ raise "rbconfig.rb not found" unless rbconfig_rb
74+ extconf_args = [
75+ "-C" , objdir ,
76+ " #{ @srcdir } /extconf.rb" ,
77+ "--target-rbconfig= #{ rbconfig_rb } " ,
78+ ]
79+ executor . system Gem . ruby , * extconf_args
80+ end
81+
82+ def do_legacy_extconf ( executor , crossruby )
83+ objdir = product_build_dir crossruby
84+ source = crossruby . source
85+ extconf_args = [
86+ "-C" , objdir ,
87+ "--disable=gems ",
88+ # HACK: top_srcdir is required to find ruby headers
89+ "-e" ,
90+ %Q($top_srcdir=" #{ source . src_dir } ") ,
91+ # HACK: extout is required to find config.h
92+ "-e" ,
93+ %Q($extout=" #{ crossruby . build_dir } /.ext") ,
94+ # HACK: force static ext build by imitating extmk
95+ "-e" ,
96+ "$static = true; trace_var(:$static) {|v| $static = true }" ,
97+ # HACK: $0 should be extconf.rb path due to mkmf source file detection
98+ # and we want to insert some hacks before it. But -e and $0 cannot be
99+ # used together, so we rewrite $0 in -e.
100+ "-e" ,
101+ %Q($0= "#{ @srcdir } /extconf.rb") ,
102+ "-e" ,
103+ %Q(require_relative " #{ @srcdir } /extconf.rb") ,
104+ # HACK: extract "$target" from extconf.rb to get a full target name
105+ # like "cgi/escape" instead of "escape"
106+ "-e" ,
107+ %Q(require "json"; File.write(" #{ metadata_json ( crossruby ) } ", JSON.dump({target: $target}))) ,
108+ "-I #{ crossruby . build_dir } "
109+ ]
110+ # Clear RUBYOPT to avoid loading unrelated bundle setup
111+ executor . system crossruby . baseruby_path ,
108112 *extconf_args ,
109- env : extconf_env
113+ env : {
114+ "RUBYOPT" => ""
115+ }
110116 end
111117
112118 def do_install_rb ( executor , crossruby )
0 commit comments