diff --git a/Rakefile b/Rakefile index b461e91..4f4be17 100644 --- a/Rakefile +++ b/Rakefile @@ -2,10 +2,42 @@ require 'rubygems' require 'rubygems/package_task' require 'rake/testtask' -spec = eval(File.new("wkhtmltopdf-binary.gemspec").readlines.join("\n")) +SUPPORTED_DARWIN_ARCHITECTURES = [:arm64, :x86_64] +SUPPORTED_LINUX_ARCHITECTURES = [:arm64, :aarch64, :arch64, :x86, :x86_64] +ARM64_COMPATIBLE_ARCHITECTURES = [:aarch64, :arch64] -Gem::PackageTask.new(spec) do |pkg| - pkg.need_tar = true +def file_architecture(architecture) + if ARM64_COMPATIBLE_ARCHITECTURES.include?(architecture) + :arm64 + else + architecture + end +end + +GEMSPEC = eval(File.new("wkhtmltopdf-binary.gemspec").readlines.join("\n")) + +SUPPORTED_DARWIN_ARCHITECTURES.each do |architecture| + GEMSPEC.dup.tap do |gemspec| + platform = "#{architecture}-darwin" + gemspec.platform = platform + gemspec.files = ['bin/wkhtmltopdf_macos_cocoa.gz'] + + gem_path = Gem::PackageTask.new(gemspec).define + desc "Package #{architecture} Darwin gem" + task "gem:#{platform}" => [gem_path] + end +end + +SUPPORTED_LINUX_ARCHITECTURES.each do |architecture| + GEMSPEC.dup.tap do |gemspec| + platform = "#{architecture}-linux" + gemspec.platform = platform + gemspec.files = Dir["bin/wkhtmltopdf_*_#{file_architecture(architecture)}.gz"] + + gem_path = Gem::PackageTask.new(gemspec).define + desc "Package #{architecture} Linux gem" + task "gem:#{platform}" => [gem_path] + end end Rake::TestTask.new do |t| diff --git a/bin/wkhtmltopdf b/bin/wkhtmltopdf index 66ed804..f169971 100755 --- a/bin/wkhtmltopdf +++ b/bin/wkhtmltopdf @@ -11,13 +11,11 @@ require 'rbconfig' require 'zlib' def architecture - case RbConfig::CONFIG['host_cpu'] - when *%w[arm64 aarch64 arch64] + host_cpu = RbConfig::CONFIG['host_cpu'] + if %w[arm64 aarch64 arch64].include?(host_cpu) 'arm64' - when 'x86_64' - 'amd64' else - 'i386' + host_cpu end end @@ -38,7 +36,7 @@ suffix = case RbConfig::CONFIG['host_os'] os = 'ubuntu_20.04' if os.start_with?('ubuntu_20.') || os.start_with?('linuxmint_20.') - + os = 'ubuntu_21.10' if os.start_with?('ubuntu_21.') || os.start_with?('linuxmint_21.') diff --git a/bin/wkhtmltopdf_archlinux_amd64.gz b/bin/wkhtmltopdf_archlinux_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_archlinux_amd64.gz rename to bin/wkhtmltopdf_archlinux_x86_64.gz diff --git a/bin/wkhtmltopdf_centos_6_i386.gz b/bin/wkhtmltopdf_centos_6_x86.gz similarity index 100% rename from bin/wkhtmltopdf_centos_6_i386.gz rename to bin/wkhtmltopdf_centos_6_x86.gz diff --git a/bin/wkhtmltopdf_centos_6_amd64.gz b/bin/wkhtmltopdf_centos_6_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_centos_6_amd64.gz rename to bin/wkhtmltopdf_centos_6_x86_64.gz diff --git a/bin/wkhtmltopdf_centos_7_i386.gz b/bin/wkhtmltopdf_centos_7_x86.gz similarity index 100% rename from bin/wkhtmltopdf_centos_7_i386.gz rename to bin/wkhtmltopdf_centos_7_x86.gz diff --git a/bin/wkhtmltopdf_centos_7_amd64.gz b/bin/wkhtmltopdf_centos_7_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_centos_7_amd64.gz rename to bin/wkhtmltopdf_centos_7_x86_64.gz diff --git a/bin/wkhtmltopdf_centos_8_amd64.gz b/bin/wkhtmltopdf_centos_8_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_centos_8_amd64.gz rename to bin/wkhtmltopdf_centos_8_x86_64.gz diff --git a/bin/wkhtmltopdf_debian_10_i386.gz b/bin/wkhtmltopdf_debian_10_x86.gz similarity index 100% rename from bin/wkhtmltopdf_debian_10_i386.gz rename to bin/wkhtmltopdf_debian_10_x86.gz diff --git a/bin/wkhtmltopdf_debian_10_amd64.gz b/bin/wkhtmltopdf_debian_10_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_debian_10_amd64.gz rename to bin/wkhtmltopdf_debian_10_x86_64.gz diff --git a/bin/wkhtmltopdf_debian_11_i386.gz b/bin/wkhtmltopdf_debian_11_x86.gz similarity index 100% rename from bin/wkhtmltopdf_debian_11_i386.gz rename to bin/wkhtmltopdf_debian_11_x86.gz diff --git a/bin/wkhtmltopdf_debian_11_amd64.gz b/bin/wkhtmltopdf_debian_11_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_debian_11_amd64.gz rename to bin/wkhtmltopdf_debian_11_x86_64.gz diff --git a/bin/wkhtmltopdf_debian_12_i386.gz b/bin/wkhtmltopdf_debian_12_x86.gz similarity index 100% rename from bin/wkhtmltopdf_debian_12_i386.gz rename to bin/wkhtmltopdf_debian_12_x86.gz diff --git a/bin/wkhtmltopdf_debian_12_amd64.gz b/bin/wkhtmltopdf_debian_12_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_debian_12_amd64.gz rename to bin/wkhtmltopdf_debian_12_x86_64.gz diff --git a/bin/wkhtmltopdf_debian_9_i386.gz b/bin/wkhtmltopdf_debian_9_x86.gz similarity index 100% rename from bin/wkhtmltopdf_debian_9_i386.gz rename to bin/wkhtmltopdf_debian_9_x86.gz diff --git a/bin/wkhtmltopdf_debian_9_amd64.gz b/bin/wkhtmltopdf_debian_9_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_debian_9_amd64.gz rename to bin/wkhtmltopdf_debian_9_x86_64.gz diff --git a/bin/wkhtmltopdf_ubuntu_16.04_i386.gz b/bin/wkhtmltopdf_ubuntu_16.04_x86.gz similarity index 100% rename from bin/wkhtmltopdf_ubuntu_16.04_i386.gz rename to bin/wkhtmltopdf_ubuntu_16.04_x86.gz diff --git a/bin/wkhtmltopdf_ubuntu_16.04_amd64.gz b/bin/wkhtmltopdf_ubuntu_16.04_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_ubuntu_16.04_amd64.gz rename to bin/wkhtmltopdf_ubuntu_16.04_x86_64.gz diff --git a/bin/wkhtmltopdf_ubuntu_18.04_i386.gz b/bin/wkhtmltopdf_ubuntu_18.04_x86.gz similarity index 100% rename from bin/wkhtmltopdf_ubuntu_18.04_i386.gz rename to bin/wkhtmltopdf_ubuntu_18.04_x86.gz diff --git a/bin/wkhtmltopdf_ubuntu_18.04_amd64.gz b/bin/wkhtmltopdf_ubuntu_18.04_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_ubuntu_18.04_amd64.gz rename to bin/wkhtmltopdf_ubuntu_18.04_x86_64.gz diff --git a/bin/wkhtmltopdf_ubuntu_20.04_amd64.gz b/bin/wkhtmltopdf_ubuntu_20.04_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_ubuntu_20.04_amd64.gz rename to bin/wkhtmltopdf_ubuntu_20.04_x86_64.gz diff --git a/bin/wkhtmltopdf_ubuntu_21.10_amd64.gz b/bin/wkhtmltopdf_ubuntu_21.10_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_ubuntu_21.10_amd64.gz rename to bin/wkhtmltopdf_ubuntu_21.10_x86_64.gz diff --git a/bin/wkhtmltopdf_ubuntu_22.04_amd64.gz b/bin/wkhtmltopdf_ubuntu_22.04_x86_64.gz similarity index 100% rename from bin/wkhtmltopdf_ubuntu_22.04_amd64.gz rename to bin/wkhtmltopdf_ubuntu_22.04_x86_64.gz diff --git a/wkhtmltopdf-binary.gemspec b/wkhtmltopdf-binary.gemspec index 07c5180..c1a66ce 100644 --- a/wkhtmltopdf-binary.gemspec +++ b/wkhtmltopdf-binary.gemspec @@ -8,14 +8,14 @@ Gem::Specification.new do |s| s.email = "zakird@gmail.com" s.platform = Gem::Platform::RUBY s.summary = "Provides binaries for WKHTMLTOPDF project in an easily accessible package." - s.files = Dir['bin/*'] - s.executables << "wkhtmltopdf" + s.executables << 'wkhtmltopdf' s.require_path = '.' + s.required_ruby_version = '>= 3.0' s.homepage = 'https://github.com/zakird/wkhtmltopdf_binary_gem' s.metadata['source_code_uri'] = s.homepage s.metadata['changelog_uri'] = "#{s.homepage}/blob/master/CHANGELOG.md" - s.add_development_dependency "minitest" - s.add_development_dependency "rake" + s.add_development_dependency 'minitest', '~> 5.23' + s.add_development_dependency 'rake', '~> 13.2' end