Skip to content

Commit e5a3f23

Browse files
XrXrkateinoigakukun
authored andcommitted
Use $(bindir) for path to executable in mkmf
For the macOS -bundle_loader linker option, we need a path to the Ruby exectuable. $(RUBY) is not necessarily a path since it could be a command line invocation. That happens during build with runruby.rb and can happen post installation if the user passes the --ruby option to a extconf.rb. Use $(bindir) to locate the executable instead. Before installation, $(bindir) doesn't exist, so we need to be able to override $(BUILTRUBY) in such situations so test-spec and bundled extensions could build. Use a new mkmf global, $builtruby, to do this; set it in fake.rb and in extmk.rb. Our build system is quite complex...
1 parent c69582a commit e5a3f23

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

ext/extmk.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ def $mflags.defined?(var)
417417
else
418418
$ruby = '$(topdir)/ruby' + EXEEXT
419419
end
420-
$mflags << "BUILTRUBY=#$ruby"
421420
$ruby = [$ruby]
422421
$ruby << "-I'$(topdir)'"
423422
unless CROSS_COMPILING
@@ -428,6 +427,7 @@ def $mflags.defined?(var)
428427
topruby = $ruby
429428
$ruby = topruby.join(' ')
430429
$mflags << "ruby=#$ruby"
430+
$builtruby = '$(topdir)/ruby' + EXEEXT # Must be an executable path
431431

432432
MTIMES = [__FILE__, 'rbconfig.rb', srcdir+'/lib/mkmf.rb'].collect {|f| File.mtime(f)}
433433

lib/mkmf.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,11 @@ def configuration(srcdir)
20762076
ruby_version = #{RbConfig::CONFIG['ruby_version']}
20772077
ruby = #{$ruby.sub(%r[\A#{Regexp.quote(RbConfig::CONFIG['bindir'])}(?=/|\z)]) {'$(bindir)'}}
20782078
RUBY = $(ruby#{sep})
2079-
BUILTRUBY = $(RUBY)
2079+
BUILTRUBY = #{if defined?($builtruby) && $builtruby
2080+
$builtruby
2081+
else
2082+
File.join('$(bindir)', CONFIG["RUBY_INSTALL_NAME"] + CONFIG['EXEEXT'])
2083+
end}
20802084
ruby_headers = #{headers.join(' ')}
20812085
20822086
RM = #{config_string('RM', &possible_command) || '$(RUBY) -run -e rm -- -f'}

tool/fake.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class File
4545
$extout_prefix = '$(extout)$(target_prefix)/'
4646
config = RbConfig::CONFIG
4747
mkconfig = RbConfig::MAKEFILE_CONFIG
48+
$builtruby ||= File.join(builddir, config['RUBY_INSTALL_NAME'] + config['EXEEXT'])
4849
RbConfig.fire_update!("builddir", builddir)
4950
RbConfig.fire_update!("buildlibdir", builddir)
5051
RbConfig.fire_update!("libdir", builddir)

0 commit comments

Comments
 (0)