Skip to content

Commit

Permalink
Fetch pre-compiled gem native extensions instead of building them fro…
Browse files Browse the repository at this point in the history
…m source for gRPC and protobuf. (#79)
  • Loading branch information
qingling128 committed Feb 20, 2018
1 parent 40695f7 commit 9fc7739
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
23 changes: 20 additions & 3 deletions bin/gem_downloader
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@ file_format = "%0#{(gp.target_files.length - 1).to_s.length}d-%s-%s.gem"
FileUtils.remove_dir(gp.target_dir, true)
Dir.mkdir(gp.target_dir)
Dir.chdir(gp.target_dir) {
gp.target_files.each { |n, v, an|
path = sprintf(file_format, index, n, v)
gp.target_files.each { |name, version, approach|
path = sprintf(file_format, index, name, version)
loop {
`curl -o #{path} -L http://rubygems.org/downloads/#{n}-#{v}.gem`
case approach
when :fetch
# Fetch the pre-compiled gem native extensions instead of building them
# from source.
# Expected output is in the following format:
# "Downloaded <gem_name>-<gem_version>-<gem_platform>"
download_status, gem_name_version_platform = (
`gem fetch #{name} --version #{version}`.strip.split(' '))
fail "Error downloading gem #{name}." unless
download_status == 'Downloaded'
path = sprintf(file_format, index, name, gem_name_version_platform)
`mv #{gem_name_version_platform}.gem #{path}`
when :download
# Download the native extension code and build from source.
`curl -o #{path} -L http://rubygems.org/downloads/#{name}-#{version}.gem`
else
fail "Unsupported gem approach: #{approach}."
end
`gem install --explain #{path} --no-ri --no-rdoc`
break if $?.success?
sleep 1
Expand Down
4 changes: 2 additions & 2 deletions core_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
download "oj", "3.3.10"
download "tzinfo", "1.2.2"
download "tzinfo-data", "1.2016.5"
download "google-protobuf", "3.5.1"
download "grpc", "1.8.3"
fetch "google-protobuf", "3.5.1"
fetch "grpc", "1.8.3"
6 changes: 5 additions & 1 deletion lib/gems_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def dir(path)
end

def download(name, ver)
@target_files << [name, ver]
@target_files << [name, ver, :download]
end

def fetch(name, ver)
@target_files << [name, ver, :fetch]
end
end

0 comments on commit 9fc7739

Please sign in to comment.