Skip to content

Commit

Permalink
Merge branch 'main' of github.com:fontist/extract_ttc into main
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Feb 11, 2024
2 parents 9e4db3a + d521cc0 commit 311a025
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 31 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-*
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ source "https://rubygems.org"

# Specify your gem's dependencies in extract_ttc.gemspec
gemspec

gem "rake-compiler", "~> 1.2"
gem "rake-compiler-dock", "~> 1.2"
gem "rspec", "~> 3.0"
gem "rubocop", "~> 1.5"
gem "rubocop-performance", "~> 1.10"
gem "rubocop-rails", "~> 2.9"
5 changes: 5 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
image:https://img.shields.io/gem/v/extract_ttc.svg["Gem Version", link="https://rubygems.org/gems/extract_ttc"]
image:https://github.com/fontist/extract_ttc/workflows/test-and-release/badge.svg["Build Status", link="https://github.com/fontist/extract_ttc/actions?workflow=test-and-release"]
// image:https://codeclimate.com/github/metanorma/extract_ttc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/fontist/extract_ttc"]
image:https://img.shields.io/github/issues-pr-raw/fontist/extract_ttc.svg["Pull Requests", link="https://github.com/fontist/extract_ttc/pulls"]

= ExtractTtc: Ruby gem to extract TTF from TTC

== Purpose
Expand Down
38 changes: 20 additions & 18 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,26 @@ 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
ruby_cc_version = "3.1.0"
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
]

# TODO automate build with:
# "rbsys/x86_64-linux-musl:latest" - for x86_64-linux-musl
# "*" - find/create image for aarch64-linux-musl
ext_thru_musl_cc = %w[x86_64-linux-musl aarch64-linux-musl]

# HACK: Prevent rake-compiler from overriding required_ruby_version,
Expand Down Expand Up @@ -60,31 +69,24 @@ namespace "gem" do
RCD
end

desc "build native gems with rake-compiler-dock"
task "native" => "cache" do
ext_thru_rc_dock.each do |plat|
RakeCompilerDock.sh <<~RCD, platform: plat
gem install bundler:#{bundler_ver} --no-document &&
bundle install --local &&
bundle exec rake native:#{plat} gem #{R_CC_V}
RCD
end
end
end

namespace "gem" do
ext_thru_rc_dock.each do |plat|
desc "Build native gems with rake-compiler-dock in parallel"
multitask "parallel" => plat

desc "Build the native gem for #{plat}"
task plat => "cache" do
ruby_cc_ver = if plat == "x64-mingw32"
"3.0.0"
else
ruby_cc_version
end

RakeCompilerDock.sh <<~RCD, platform: plat
gem install bundler:#{bundler_ver} --no-document &&
bundle install --local &&
bundle exec rake native:#{plat} \
pkg/#{exttask.gem_spec.full_name}-#{plat}.gem \
#{R_CC_V}
RUBY_CC_VERSION=#{ruby_cc_ver}
RCD
end
end
Expand Down
7 changes: 0 additions & 7 deletions extract_ttc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "bundler", "~> 2.3", ">= 2.3.22"
spec.add_runtime_dependency "ffi", "~> 1.0"
spec.add_runtime_dependency "rake", "~> 13"
spec.add_runtime_dependency "rake-compiler", "~> 1.2"
spec.add_runtime_dependency "rake-compiler-dock", "~> 1.2"

spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop", "~> 1.5"
spec.add_development_dependency "rubocop-performance", "~> 1.10"
spec.add_development_dependency "rubocop-rails", "~> 2.9"

spec.extensions << "ext/stripttc/extconf.rb"
spec.metadata["rubygems_mfa_required"] = "false"
Expand Down
6 changes: 3 additions & 3 deletions lib/extract_ttc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ 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_name = if File.exists?(File.join(File.dirname(__FILE__),
"stripttc.bundle"))
"stripttc.bundle"
macos_binary = "stripttc.bundle"
lib_name = if File.exist?(File.join(File.dirname(__FILE__), macos_binary))
macos_binary
else
"stripttc.so"
end
Expand Down
Binary file added lib/extract_ttc/stripttc.so
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/extract_ttc/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ExtractTtc
VERSION = "0.3.3".freeze
VERSION = "0.3.6".freeze
end

0 comments on commit 311a025

Please sign in to comment.