Skip to content

Commit

Permalink
#17 build native extesion independent of ruby version
Browse files Browse the repository at this point in the history
  • Loading branch information
CAMOBAP committed Mar 24, 2023
1 parent b023fcb commit 620ef3b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
/spec/reports/
/tmp/
/Gemfile.lock
**/*.so
**/*.o

/lib/*.so
/lib/*.bundle
/ext/*.o

# remote file cache
.rubocop-*
14 changes: 11 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,24 @@ rescue LoadError
end
# -- Allow rake-compiler-dock configuration without dev. dependencies

R_CC_V = "RUBY_CC_VERSION=3.1.0:3.0.0:2.7.0".freeze
# Keep only one version in R_CC_V because libstripttc doesn depende on libruby
# we don't need different variation per each minor version of ruby
R_CC_V = "RUBY_CC_VERSION=2.7.0".freeze
bundler_ver = ENV["BUNDLER_VER"] || "2.3.22"

task default: :spec
task spec: :compile

spec = Gem::Specification.load("extract_ttc.gemspec")

ext_thru_rc_dock = %w[x86_64-linux aarch64-linux] +
%w[x64-mingw32 x64-mingw-ucrt x86_64-darwin arm64-darwin]
ext_thru_rc_dock = %w[
x86_64-linux
aarch64-linux
x64-mingw32
x64-mingw-ucrt
x86_64-darwin
arm64-darwin
]

ext_thru_musl_cc = %w[x86_64-linux-musl aarch64-linux-musl]

Expand Down
7 changes: 1 addition & 6 deletions lib/extract_ttc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ class UnknownResultError < Error; end
extend FFI::Library
# NOTE: ffi doesn't support bundles out of box https://github.com/ffi/ffi/issues/42#issuecomment-750031554
# NOTE: rake-compiler doesn't support dylib generation https://github.com/rake-compiler/rake-compiler/issues/183
lib_subdir = RUBY_VERSION.split(".").first(2).join(".")
macos_binary = "stripttc.bundle"
lib_name = if File.exist?(
File.join(File.dirname(__FILE__), lib_subdir, macos_binary),
)
File.join(lib_subdir, macos_binary)
elsif File.exist?(File.join(File.dirname(__FILE__), macos_binary))
lib_name = if File.exist?(File.join(File.dirname(__FILE__), macos_binary))
macos_binary
else
"stripttc.so"
Expand Down

0 comments on commit 620ef3b

Please sign in to comment.