lib/thermite/package.rb in thermite-0.9.0 vs lib/thermite/package.rb in thermite-0.10.0
- old
+ new
@@ -31,10 +31,11 @@
# Builds a tarball of the Rust-compiled shared library.
#
def build_package
filename = config.tarball_filename(config.toml[:package][:version])
relative_library_path = config.ruby_extension_path.sub("#{config.ruby_toplevel_dir}/", '')
+ prepare_built_library
Zlib::GzipWriter.open(filename) do |tgz|
Dir.chdir(config.ruby_toplevel_dir) do
Archive::Tar::Minitar.pack(relative_library_path, tgz)
end
end
@@ -53,10 +54,23 @@
end
end
end
end
+ # :nocov:
+
+ def prepare_downloaded_library
+ return unless config.target_os.start_with?('darwin')
+
+ libruby_path = Shellwords.escape(config.libruby_path)
+ library_path = Shellwords.escape(config.ruby_extension_path)
+ `install_name_tool -id #{library_path} #{library_path}`
+ `install_name_tool -change @libruby_path@ #{libruby_path} #{library_path}`
+ end
+
+ # :nocov:
+
private
def each_compressed_file(tgz)
Zlib::GzipReader.wrap(tgz) do |gz|
Gem::Package::TarReader.new(gz) do |tar|
@@ -65,8 +79,18 @@
next if path.end_with?('/')
yield path, entry
end
end
end
+ end
+
+ # :nocov:
+
+ def prepare_built_library
+ return unless config.target_os.start_with?('darwin')
+
+ libruby_path = Shellwords.escape(config.libruby_path)
+ library_path = Shellwords.escape(config.ruby_extension_path)
+ `install_name_tool -change #{libruby_path} @libruby_path@ #{library_path}`
end
end
end