From 57a152299a93459d584e850e79917665c51c5821 Mon Sep 17 00:00:00 2001 From: Krzysztof Zych Date: Sun, 28 Oct 2018 12:27:01 +0100 Subject: [PATCH] Add a rake task to compress binaries with UPX. Make it a requirement of the gem packing task. It's safe to run multiple times - already-compressed files will be detected and skipped. --- Rakefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Rakefile b/Rakefile index c9a610ae..cdba7fde 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,20 @@ require 'rubygems' require 'rubygems/package_task' +task :compress_binaries do + Dir.glob(File.join(__dir__, 'bin/', '*{x86,amd64}')).each do |path| + sh "upx", "-t", path do |success| + if success + puts "#{path} already compressed, skipping" + else + sh "upx", path + end + end + end +end + +task gem: :compress_binaries + spec = eval(File.new("wkhtmltopdf-binary.gemspec").readlines.join("\n")) Gem::PackageTask.new(spec) do |pkg| pkg.need_tar = true