Skip to content

Commit

Permalink
[Truffle] Use extconf make for jt test cexts
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Fish committed Nov 14, 2016
1 parent 47b98c6 commit ed07dcc
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tool/jt.rb
Expand Up @@ -760,6 +760,28 @@ def cextc(cext_dir, *clang_opts)
sulong_link '-o', out, *config_libs, *lls
end

def cextc_extconf(cext_dir, *clang_opts)
abort "You need to set SULONG_HOME" unless SULONG_HOME

# Ensure ruby.su is up-to-date
ruby_cext_api = "#{JRUBY_DIR}/truffle/src/main/c/cext"
ruby_c = "#{JRUBY_DIR}/truffle/src/main/c/cext/ruby.c"
ruby_h = "#{JRUBY_DIR}/lib/ruby/truffle/cext/ruby.h"
ruby_su = "#{JRUBY_DIR}/lib/ruby/truffle/cext/ruby.su"
if cext_dir != ruby_cext_api and (newer?(ruby_h, ruby_su) or newer?(ruby_c, ruby_su))
puts "Compiling outdated ruby.su"
cextc ruby_cext_api
end

This comment has been minimized.

Copy link
@eregon

eregon Nov 14, 2016

Member

Please, no code duplication, this file is already long and complex enough 😉 => Extract Method


gem_name = File.basename(cext_dir)
gem_dir = Dir.glob(ENV['GEM_HOME'] + "/gems/#{gem_name}*/")[0] + "ext/#{gem_name}/"
Dir.chdir(gem_dir) do
run("extconf.rb")
raw_sh("make")
FileUtils.copy_file("#{gem_name}.su", "#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}/lib/#{gem_name}/#{gem_name}.su")
end
end

def test(*args)
path, *rest = args

Expand Down Expand Up @@ -901,7 +923,12 @@ def test_cexts(*args)
unless gem_root and File.exist?(File.join(gem_root, CEXTC_CONF_FILE))
gem_root = "#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}"
end
cextc gem_root, '-Werror=implicit-function-declaration'
if gem_name == "ruby-argon2"
cextc gem_root, '-Werror=implicit-function-declaration'
else
cextc_extconf gem_root, '-Werror=implicit-function-declaration'
end

next if gem_name == 'psd_native' # psd_native is excluded just for running
run '--graal',
*dependencies.map { |d| "-I#{ENV['GEM_HOME']}/gems/#{d}/lib" },
Expand Down

2 comments on commit ed07dcc

@bjfish
Copy link
Contributor

@bjfish bjfish commented on ed07dcc Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisseaton Let me know if you see any issues. It appears to be working as far as I can tell from the output.

@chrisseaton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Can we switch to use this for building ruby.su and building all out test cexts? The minimum ones don't have extconf.rbs at the moment.

Please sign in to comment.