From 5d61fbc9bf3e250e33c8954487bcf3fb6085eee0 Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 13 Feb 2023 10:32:27 +0100 Subject: [PATCH 1/9] #14 add ruby 3.2 to test matrix --- .github/workflows/test-and-release.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index 642f77f..d2f3531 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -18,21 +18,29 @@ env: # https://github.com/rubygems/rubygems/pull/4488 jobs: + prepare: + uses: metanorma/ci/.github/workflows/prepare-rake.yml@main + test: - name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }} + name: Test on Ruby ${{ matrix.ruby.version }} ${{ matrix.os }} runs-on: ${{ matrix.os }} + + needs: prepare + if: needs.prepare.outputs.push-for-tag != 'true' + + continue-on-error: ${{ matrix.ruby.experimental }} strategy: fail-fast: false - matrix: - ruby: [ '2.7', '3.0', '3.1' ] - os: [ ubuntu-latest, windows-latest, macos-latest ] + max-parallel: 5 + matrix: ${{ fromJson(needs.prepare.outputs.matrix) }} steps: - uses: actions/checkout@v3 - uses: ruby/setup-ruby@master with: - ruby-version: ${{ matrix.ruby }} + ruby-version: ${{ matrix.ruby.version }} + rubygems: ${{ matrix.ruby.rubygems }} bundler: ${{ env.BUNDLER_VER }} bundler-cache: true From 0444b1518f159bb89efc0999aa10d9d828f4454d Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 13 Feb 2023 10:37:44 +0100 Subject: [PATCH 2/9] #14 use File.exist? instead exists? to support ruby 3.2 --- lib/extract_ttc.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/extract_ttc.rb b/lib/extract_ttc.rb index 27946e8..315742f 100644 --- a/lib/extract_ttc.rb +++ b/lib/extract_ttc.rb @@ -16,8 +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_name = if File.exists?(File.join(File.dirname(__FILE__), - "stripttc.bundle")) + lib_name = if File.exist?(File.join(File.dirname(__FILE__), + "stripttc.bundle")) "stripttc.bundle" else "stripttc.so" From 225bc984bb61ac87774e3cc6276f07dc6668aa2f Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 13 Feb 2023 11:35:53 +0100 Subject: [PATCH 3/9] fix stripttc.bundle for gems with prebuilt extension --- lib/extract_ttc.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/extract_ttc.rb b/lib/extract_ttc.rb index 315742f..37dbc2a 100644 --- a/lib/extract_ttc.rb +++ b/lib/extract_ttc.rb @@ -16,8 +16,18 @@ 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.exist?(File.join(File.dirname(__FILE__), - "stripttc.bundle")) + lib_name = if File.exist?( + File.join( + File.dirname(__FILE__), + RUBY_VERSION.split(".").first(2).join("."), + "stripttc.bundle", + ), + ) || File.exist?( + File.join( + File.dirname(__FILE__), + "stripttc.bundle", + ), + ) "stripttc.bundle" else "stripttc.so" From 59d39d394620f107f2e65b775541813bf5dd85ad Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 13 Feb 2023 12:33:43 +0100 Subject: [PATCH 4/9] Bump extract_ttc to 0.3.4 --- lib/extract_ttc/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/extract_ttc/version.rb b/lib/extract_ttc/version.rb index 125b570..03c12bc 100644 --- a/lib/extract_ttc/version.rb +++ b/lib/extract_ttc/version.rb @@ -1,3 +1,3 @@ module ExtractTtc - VERSION = "0.3.3".freeze + VERSION = "0.3.4".freeze end From 5f5779ab8454e5c2f02a95b7c99454a60feef00f Mon Sep 17 00:00:00 2001 From: Alex Babrykovich Date: Mon, 13 Feb 2023 12:45:35 +0100 Subject: [PATCH 5/9] Add GHA badges --- README.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.adoc b/README.adoc index c8c9e68..c03e9a0 100644 --- a/README.adoc +++ b/README.adoc @@ -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 From 8fa4620228c9190022b0ff26f91cbd80b1ad69d5 Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 13 Feb 2023 13:37:17 +0100 Subject: [PATCH 6/9] fix stripttc.bundle for gems with prebuilt extension v2 --- lib/extract_ttc.rb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/extract_ttc.rb b/lib/extract_ttc.rb index 37dbc2a..f400c7a 100644 --- a/lib/extract_ttc.rb +++ b/lib/extract_ttc.rb @@ -16,19 +16,14 @@ 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__), - RUBY_VERSION.split(".").first(2).join("."), - "stripttc.bundle", - ), - ) || File.exist?( - File.join( - File.dirname(__FILE__), - "stripttc.bundle", - ), + File.join(File.dirname(__FILE__), lib_subdir, macos_binary), ) - "stripttc.bundle" + File.join(lib_subdir, macos_binary) + elsif File.exist?(File.join(File.dirname(__FILE__), macos_binary)) + macos_binary else "stripttc.so" end From b023fcb86955ccb66dd967e53c57109f199f6873 Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 13 Feb 2023 13:54:02 +0100 Subject: [PATCH 7/9] Bump extract_ttc to 0.3.5 --- lib/extract_ttc/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/extract_ttc/version.rb b/lib/extract_ttc/version.rb index 03c12bc..cb8f541 100644 --- a/lib/extract_ttc/version.rb +++ b/lib/extract_ttc/version.rb @@ -1,3 +1,3 @@ module ExtractTtc - VERSION = "0.3.4".freeze + VERSION = "0.3.5".freeze end From b050fdb1adfd70f53a5cfed2ea3808a619daa7b9 Mon Sep 17 00:00:00 2001 From: Alex Babrykovich Date: Mon, 27 Mar 2023 00:14:37 -0700 Subject: [PATCH 8/9] #17 build native extesion independent of ruby version (#18) * #17 build native extesion independent of ruby version * Fix Don't know how to build task 'native:x64-mingw-ucrt' issue * Move development gems for Gemfile * Force ruby_cc_version to 3.0.0 for x64-mingw32 * Remove unnecessary native task & fix ruby version for x64-mingw --- .gitignore | 6 ++++-- Gemfile | 7 +++++++ Rakefile | 38 ++++++++++++++++++++------------------ extract_ttc.gemspec | 7 ------- lib/extract_ttc.rb | 7 +------ 5 files changed, 32 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 8756e0d..8aa9991 100644 --- a/.gitignore +++ b/.gitignore @@ -8,8 +8,10 @@ /spec/reports/ /tmp/ /Gemfile.lock -**/*.so -**/*.o + +/lib/*.so +/lib/*.bundle +/ext/*.o # remote file cache .rubocop-* diff --git a/Gemfile b/Gemfile index 978bf46..97b3e3a 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/Rakefile b/Rakefile index 9f38b52..9cb3112 100644 --- a/Rakefile +++ b/Rakefile @@ -20,7 +20,7 @@ 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 @@ -28,9 +28,18 @@ 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, @@ -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 diff --git a/extract_ttc.gemspec b/extract_ttc.gemspec index 5a2c9da..6a14558 100644 --- a/extract_ttc.gemspec +++ b/extract_ttc.gemspec @@ -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" diff --git a/lib/extract_ttc.rb b/lib/extract_ttc.rb index f400c7a..6c4efec 100644 --- a/lib/extract_ttc.rb +++ b/lib/extract_ttc.rb @@ -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" From d521cc05fcc623d17fe2157bcb13026b5233877f Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 27 Mar 2023 09:24:44 +0200 Subject: [PATCH 9/9] Bump extract_ttc to 0.3.6 --- lib/extract_ttc/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/extract_ttc/version.rb b/lib/extract_ttc/version.rb index cb8f541..eba0811 100644 --- a/lib/extract_ttc/version.rb +++ b/lib/extract_ttc/version.rb @@ -1,3 +1,3 @@ module ExtractTtc - VERSION = "0.3.5".freeze + VERSION = "0.3.6".freeze end