Skip to content

Commit

Permalink
Simplify libc and libm path logics (#91)
Browse files Browse the repository at this point in the history
* Simplify libc_so and libm_so

If nil, no need to set to nil.

* Get rid of repeating inversions
  • Loading branch information
nobu committed Aug 24, 2021
1 parent cf78edd commit 4323e68
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions test/fiddle/helper.rb
Expand Up @@ -56,6 +56,8 @@
libc_so = libm_so = "#{crtname}.dll"
when /darwin/
libc_so = libm_so = "/usr/lib/libSystem.B.dylib"
# macOS 11.0+ removed libSystem.B.dylib from /usr/lib. But It works with dlopen.
rigid_path = true
when /kfreebsd/
libc_so = "/lib/libc.so.0.1"
libm_so = "/lib/libm.so.1"
Expand Down Expand Up @@ -131,12 +133,9 @@
end
end

libc_so = nil if !libc_so || (libc_so[0] == ?/ && !File.file?(libc_so))
libm_so = nil if !libm_so || (libm_so[0] == ?/ && !File.file?(libm_so))

# macOS 11.0+ removed libSystem.B.dylib from /usr/lib. But It works with dlopen.
if RUBY_PLATFORM =~ /darwin/
libc_so = libm_so = "/usr/lib/libSystem.B.dylib"
unless rigid_path
libc_so = nil if libc_so && libc_so[0] == ?/ && !File.file?(libc_so)
libm_so = nil if libm_so && libm_so[0] == ?/ && !File.file?(libm_so)
end

if !libc_so || !libm_so
Expand Down

0 comments on commit 4323e68

Please sign in to comment.