Skip to content

Commit

Permalink
Make rake gem vendor libre2 and abseil tarballs
Browse files Browse the repository at this point in the history
This increases the size of the gem from 32K to 2.4 MB, but this will
significantly reduce network transfer and avoid rate limits.
  • Loading branch information
stanhu committed Jul 12, 2023
1 parent c53adc4 commit c2f0d44
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,44 @@ CLOBBER.include FileList['**/tmp'],
FileList['tmp/']
CLOBBER.add("ports/*").exclude(%r{ports/archives$})

RE2_GEM_SPEC = Gem::Specification.load('re2.gemspec')

Rake::ExtensionTask.new('re2')

Gem::PackageTask.new(RE2_GEM_SPEC) do |p|
p.need_zip = false
p.need_tar = false
end

RSpec::Core::RakeTask.new(:spec)

def gem_build_path
File.join 'pkg', RE2_GEM_SPEC.full_name
end

def add_file_to_gem(relative_source_path)
dest_path = File.join(gem_build_path, relative_source_path)
dest_dir = File.dirname(dest_path)

mkdir_p dest_dir unless Dir.exist?(dest_dir)
rm_f dest_path if File.exist?(dest_path)
safe_ln relative_source_path, dest_path

RE2_GEM_SPEC.files << relative_source_path
end

def add_vendored_libraries
dependencies = YAML.load_file(File.join(File.dirname(__FILE__), 'dependencies.yml'))
abseil_archive = File.join('ports', 'archives', "#{dependencies['abseil']['version']}.tar.gz")
libre2_archive = File.join('ports', 'archives', "re2-#{dependencies['libre2']['version']}.tar.gz")

add_file_to_gem(abseil_archive)
add_file_to_gem(libre2_archive)
end

task gem_build_path do
add_vendored_libraries
end

task :spec => :compile
task :default => :spec

0 comments on commit c2f0d44

Please sign in to comment.