@@ -233,36 +233,43 @@ def map_dir(dir, map = nil)
233
233
end
234
234
235
235
if RUBY_ENGINE == 'truffleruby'
236
- topdir = RbConfig ::CONFIG [ 'prefix' ]
236
+ $extmk = Truffle ::Boot . get_option ( 'building.core.cexts' )
237
+ topdir = RbConfig ::CONFIG [ 'prefix' ] # the TruffleRuby home
238
+ $hdrdir = RbConfig ::CONFIG [ "rubyhdrdir" ] # lib/cext/include
239
+ $arch_hdrdir = RbConfig ::CONFIG [ "rubyarchhdrdir" ] # lib/cext/include
240
+
241
+ unless File . exist? ( "#{ $hdrdir} /ruby/ruby.h" )
242
+ abort "mkmf.rb can't find header files for ruby at #{ $hdrdir} /ruby/ruby.h"
243
+ end
244
+
245
+ if not $extmk
246
+ $topdir = $hdrdir # lib/cext/include
247
+ $top_srcdir = $hdrdir # lib/cext/include
248
+ else
249
+ $top_srcdir ||= topdir + "/lib/cext" # lib/cext
250
+ $topdir ||= RbConfig ::CONFIG [ "topdir" ] # lib/mri
251
+ end
237
252
else
238
253
topdir = File . dirname ( File . dirname ( __FILE__ ) )
239
- end
240
-
241
- path = File . expand_path ( $0)
242
- until ( dir = File . dirname ( path ) ) == path
243
- if File . identical? ( dir , topdir )
244
- if RUBY_ENGINE == 'truffleruby'
245
- $extmk = true if %r"\A (?:ext|enc|tool|test|src)\z " =~ File . basename ( path )
246
- else
254
+ path = File . expand_path ( $0)
255
+ until ( dir = File . dirname ( path ) ) == path
256
+ if File . identical? ( dir , topdir )
247
257
$extmk = true if %r"\A (?:ext|enc|tool|test)\z " =~ File . basename ( path )
248
- end
249
- break
250
- end
251
- path = dir
252
- end
253
- $extmk ||= false
254
- if not $extmk and File . exist? ( ( $hdrdir = RbConfig ::CONFIG [ "rubyhdrdir" ] ) + "/ruby/ruby.h" )
255
- $topdir = $hdrdir
256
- $top_srcdir = $hdrdir
257
- $arch_hdrdir = RbConfig ::CONFIG [ "rubyarchhdrdir" ]
258
- elsif RUBY_ENGINE != 'truffleruby' && File . exist? ( ( $hdrdir = ( $top_srcdir ||= topdir ) + "/include" ) + "/ruby.h" )
259
- $topdir ||= RbConfig ::CONFIG [ "topdir" ]
260
- $arch_hdrdir = "$(extout)/include/$(arch)"
261
- elsif RUBY_ENGINE == 'truffleruby' && File . exist? ( ( $hdrdir = ( $top_srcdir ||= topdir + "/lib/cext" ) + "/include" ) + "/ruby.h" )
262
- $topdir ||= RbConfig ::CONFIG [ "topdir" ]
263
- $arch_hdrdir = $top_srcdir + "/include"
264
- else
265
- abort "mkmf.rb can't find header files for ruby at #{ $hdrdir} /ruby.h"
258
+ break
259
+ end
260
+ path = dir
261
+ end
262
+ $extmk ||= false
263
+ if not $extmk and File . exist? ( ( $hdrdir = RbConfig ::CONFIG [ "rubyhdrdir" ] ) + "/ruby/ruby.h" )
264
+ $topdir = $hdrdir
265
+ $top_srcdir = $hdrdir
266
+ $arch_hdrdir = RbConfig ::CONFIG [ "rubyarchhdrdir" ]
267
+ elsif File . exist? ( ( $hdrdir = ( $top_srcdir ||= topdir ) + "/include" ) + "/ruby.h" )
268
+ $topdir ||= RbConfig ::CONFIG [ "topdir" ]
269
+ $arch_hdrdir = "$(extout)/include/$(arch)"
270
+ else
271
+ abort "mkmf.rb can't find header files for ruby at #{ $hdrdir} /ruby.h"
272
+ end
266
273
end
267
274
268
275
CONFTEST = "conftest" . freeze
@@ -2651,7 +2658,7 @@ def MAIN_DOES_NOTHING(*refs)
2651
2658
RbConfig ::CONFIG [ "topdir" ] = curdir
2652
2659
end
2653
2660
$configure_args[ "--topdir" ] ||= $curdir
2654
-
2661
+
2655
2662
if RUBY_ENGINE == 'truffleruby'
2656
2663
$ruby = arg_config ( "--ruby" , RbConfig . ruby )
2657
2664
else
0 commit comments