Skip to content

Commit

Permalink
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -333,6 +333,14 @@ def shellescape(str)
end
end

def replace_env_vars(string, env = ENV)
string.gsub(/\$([A-Z_]+)/) {
var = $1
abort "You need to set $#{var}" unless env[var]
env[var]
}
end

def sh(*args)
Dir.chdir(JRUBY_DIR) do
raw_sh(*args)
@@ -660,16 +668,12 @@ def cextc(cext_dir, *clang_opts)
config = YAML.load_file(config_file)
config_src = config['src']

if config_src.start_with?('$GEM_HOME/')
abort 'You need to set $GEM_HOME' unless ENV['GEM_HOME']
src = Dir[ENV['GEM_HOME'] + config_src['$GEM_HOME'.size..-1]]
else
src = Dir[File.join(cext_dir, config_src)]
end
src = replace_env_vars(config['src'])
src = File.expand_path(src, cext_dir)

config_cflags = config['cflags'] || ''
config_cflags = `echo #{config_cflags}`.strip
config_cflags = config_cflags.split(' ')
config_cflags = replace_env_vars(config_cflags)
config_cflags = config_cflags.split

out = File.expand_path(config['out'], cext_dir)

@@ -685,7 +689,7 @@ def cextc(cext_dir, *clang_opts)
end

config_libs = config['libs'] || ''
config_libs = `echo #{config_libs}`.strip
config_libs = replace_env_vars(conf)
config_libs = config_libs.split(' ')

if MAC

2 comments on commit 2504b6b

@chrisseaton
Copy link
Contributor

Choose a reason for hiding this comment

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

@eregon this is what broke the cext tests. If you don't see it locally it may be because of your paths by coincidence don't expose the bug.

I run

$ GEM_HOME=../jruby-truffle-gem-test-pack/gems/ jt cextc test/truffle/cexts/oily_png

So after replacing env vars the path is

../jruby-truffle-gem-test-pack/gems//gems/oily_png-1.2.0/ext/oily_png/*.c

Then you do File.expand_path(src, cext_dir), so we end up with

/Users/chrisseaton/Documents/ruby/jruby/test/truffle/cexts/jruby-truffle-gem-test-pack/gems/gems/oily_png-1.2.0/ext/oily_png/*.c

Which is wrong. Can you try to fix or revert please?

@eregon
Copy link
Member Author

@eregon eregon commented on 2504b6b Aug 11, 2016

Choose a reason for hiding this comment

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

I see, thanks for the investigation!
Generally, it's not particularly advisable to use relative paths in ENV variables (you can use

FOO=`pwd`/...

or FOO=$PWD/...).
I'll fix it for this particular case.

Please sign in to comment.