Skip to content

Commit

Permalink
Implement a workaround for FFI
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLunn committed Jul 14, 2023
1 parent 8fca842 commit b7f3e97
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ruby/private/bundle/create_bundle_build_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/specifications/#{gem_name}-#{gem_version}*.gemspec").first
end

HERE = File.absolute_path '.'

require 'bundler'
require 'json'
require 'stringio'
Expand Down Expand Up @@ -261,7 +263,14 @@ def register_gem(spec, template_out, bundle_lib_paths, bundle_binaries)
# Usually, registering the directory paths listed in the `require_paths` of gemspecs is sufficient, but
# some gems also require additional paths to be included in the load paths.
require_paths += include_array(spec.name)
gem_lib_paths = require_paths.map { |require_path| File.join(gem_path, require_path) }
gem_lib_paths = require_paths.map do |require_path|
# Gems with native extensions (like ffi) will sometimes have elements of
# require_paths that are absolute rather than gem-path relative paths.
# It is incorrect to prepend those paths with the gem_path and Bazel will
# only allow relative paths as inputs to its glob() function.
pathname = Pathname.new(require_path)
pathname.absolute? ? pathname.relative_path_from(HERE).to_s : File.join(gem_path, require_path)
end
bundle_lib_paths.push(*gem_lib_paths)

# paths to search for executables
Expand Down

0 comments on commit b7f3e97

Please sign in to comment.