Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smaller gems #172

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +19 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the gems for each architecture built using commands like rake gem:x86_64-darwin? I think it would be useful to have a command that builds all the necessary gems at once or pushes them to rubygems.org in one go.

end

Rake::TestTask.new do |t|
Expand Down
10 changes: 4 additions & 6 deletions bin/wkhtmltopdf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.')

Expand Down
Loading