Skip to content

Commit

Permalink
Merge pull request #1344 from paddor/master
Browse files Browse the repository at this point in the history
Problem: Ruby binding can't find lib without devel package installed
  • Loading branch information
sappo authored Nov 22, 2024
2 parents 294bcdd + 02fa414 commit fb37ced
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions zproject_ruby.gsl
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,21 @@ module $(project.RubyName:)
end

begin
lib_name = '$(project.libname)'
lib_dirs = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
env_name = "#{lib_name.upcase}_PATH"
lib_dirs = [*ENV[env_name].split(':'), *lib_dirs] if ENV[env_name]
lib_paths = lib_dirs.map { |path| "#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}" }
ffi_lib lib_paths + [lib_name]
lib_name = '$(project.libname)'
major_version = '$(project->version.major)'
lib_dirs = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64', '/usr/lib']
lib_dirs = [*ENV['LD_LIBRARY_PATH'].split(':'), *lib_dirs] if ENV['LD_LIBRARY_PATH']
lib_dirs = [*ENV["#{lib_name.upcase}_PATH"].split(':'), *lib_dirs] if ENV["#{lib_name.upcase}_PATH"]
lib_paths = lib_dirs.map do |path|
[
"#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}",
"#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}.#{major_version}"
]
end.flatten

lib_paths.concat [lib_name, "#{lib_name}.#{::FFI::Platform::LIBSUFFIX}.#{major_version}"]

ffi_lib lib_paths
@available = true
rescue LoadError
warn ""
Expand Down

0 comments on commit fb37ced

Please sign in to comment.