summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/spec_helper.rb
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-02-28 19:07:17 +0100
committerBenoit Daloze <eregontp@gmail.com>2020-02-28 19:07:17 +0100
commita0f5ff4c3cd05f8717be2bf1d79f0817f288d398 (patch)
tree441f409cf816cf8a61dacdbaf204ae9f5cbe2f18 /spec/ruby/optional/capi/spec_helper.rb
parent5d210501825e1682e68cbfc2be424fc339f382fa (diff)
Update to ruby/spec@41bf282
Diffstat (limited to 'spec/ruby/optional/capi/spec_helper.rb')
-rw-r--r--spec/ruby/optional/capi/spec_helper.rb25
1 files changed, 18 insertions, 7 deletions
diff --git a/spec/ruby/optional/capi/spec_helper.rb b/spec/ruby/optional/capi/spec_helper.rb
index eda4964b69..30e6196d05 100644
--- a/spec/ruby/optional/capi/spec_helper.rb
+++ b/spec/ruby/optional/capi/spec_helper.rb
@@ -8,12 +8,17 @@ require 'rbconfig'
OBJDIR ||= File.expand_path("../../../ext/#{RUBY_ENGINE}/#{RUBY_VERSION}", __FILE__)
def object_path
- mkdir_p(OBJDIR)
- OBJDIR
+ path = OBJDIR
+ if ENV['SPEC_CAPI_CXX'] == 'true'
+ path = "#{path}/cxx"
+ end
+ mkdir_p(path)
+ path
end
def compile_extension(name)
debug = false
+ cxx = ENV['SPEC_CAPI_CXX'] == 'true'
run_mkmf_in_process = RUBY_ENGINE == 'truffleruby'
core_ext_dir = File.expand_path("../ext", __FILE__)
@@ -54,7 +59,11 @@ def compile_extension(name)
Dir.mkdir(tmpdir)
begin
["#{core_ext_dir}/rubyspec.h", "#{spec_ext_dir}/#{ext}.c"].each do |file|
- cp file, "#{tmpdir}/#{File.basename(file)}"
+ if cxx and file.end_with?('.c')
+ cp file, "#{tmpdir}/#{File.basename(file, '.c')}.cpp"
+ else
+ cp file, "#{tmpdir}/#{File.basename(file)}"
+ end
end
Dir.chdir(tmpdir) do
@@ -64,11 +73,13 @@ def compile_extension(name)
init_mkmf unless required
create_makefile(ext, tmpdir)
else
- File.write("extconf.rb", "require 'mkmf'\n" +
- "$ruby = ENV.values_at('RUBY_EXE', 'RUBY_FLAGS').join(' ')\n" +
+ File.write("extconf.rb", <<-RUBY)
+ require 'mkmf'
+ $ruby = ENV.values_at('RUBY_EXE', 'RUBY_FLAGS').join(' ')
# MRI magic to consider building non-bundled extensions
- "$extout = nil\n" +
- "create_makefile(#{ext.inspect})\n")
+ $extout = nil
+ create_makefile(#{ext.inspect})
+ RUBY
output = ruby_exe("extconf.rb")
raise "extconf failed:\n#{output}" unless $?.success?
$stderr.puts output if debug