summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/spec_helper.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-27 01:58:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-27 01:58:18 +0000
commita1695d9c2cde823e3777a0ad9d87853a1cd4f15e (patch)
tree54f900b2a8881a452c72c558a2dbed66b0af377c /spec/ruby/optional/capi/spec_helper.rb
parent42c6ef00afc0164a2ac11fc344a0b379e14fddf5 (diff)
spec_helper.rb: must find libruby.so
* spec/ruby/optional/capi/spec_helper.rb (compile_extension): if libruby.so should have been built but is not found, fail early. get mtime of the library just once. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/optional/capi/spec_helper.rb')
-rw-r--r--spec/ruby/optional/capi/spec_helper.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/spec/ruby/optional/capi/spec_helper.rb b/spec/ruby/optional/capi/spec_helper.rb
index 373012a869..33e796807e 100644
--- a/spec/ruby/optional/capi/spec_helper.rb
+++ b/spec/ruby/optional/capi/spec_helper.rb
@@ -24,18 +24,21 @@ def compile_extension(name)
lib = "#{object_path}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"
ruby_header = "#{RbConfig::CONFIG['rubyhdrdir']}/ruby.h"
libruby_so = RbConfig::CONFIG['LIBRUBY_SO']
- ruby_library = "#{RbConfig::CONFIG['libdir']}/#{libruby_so}"
- unless libruby_so and File.exist?(ruby_library)
- # Statically-compiled lib in the binary, ignore this check
- ruby_library = nil
- end
- return lib if File.exist?(lib) and
- File.mtime(lib) > File.mtime("#{extension_path}/rubyspec.h") and
- File.mtime(lib) > File.mtime("#{extension_path}/#{ext}.c") and
- File.mtime(lib) > File.mtime(ruby_header) and
- (!ruby_library || File.mtime(lib) > File.mtime(ruby_library)) and
- true # sentinel
+ begin
+ mtime = File.mtime(lib)
+ rescue Errno::ENOENT
+ # not found, then compile
+ else
+ case # if lib is older than headers, source or libruby, then recompile
+ when mtime <= File.mtime("#{extension_path}/rubyspec.h")
+ when mtime <= File.mtime("#{extension_path}/#{ext}.c")
+ when mtime <= File.mtime(ruby_header)
+ when libruby_so && mtime <= File.mtime("#{RbConfig::CONFIG['libdir']}/#{libruby_so}")
+ else
+ return lib # up-to-date
+ end
+ end
# Copy needed source files to tmpdir
tmpdir = tmp("cext_#{name}")